소스 검색

Easier to understand css offenders

Gaël Métais 10 년 전
부모
커밋
604857648b
1개의 변경된 파일12개의 추가작업 그리고 3개의 파일을 삭제
  1. 12 3
      lib/metadata/policies.js

+ 12 - 3
lib/metadata/policies.js

@@ -390,11 +390,20 @@ var policies = {
             return {
             return {
                 count: offenders.length,
                 count: offenders.length,
                 list: offenders.map(function(offender) {
                 list: offenders.map(function(offender) {
+                    if (offender === '[inline CSS] (Empty CSS was provided)') {
+                        return {
+                            error: 'Empty style tag',
+                            file: null,
+                            line: null,
+                            column: null
+                        };
+                    }
+
                     var parts = /^(?:(?:<([^ \(]*)>|\[inline CSS\]) ?)?(?:\((((?! @ ).)*)(?: @ (\d+):(\d+))?\))?$/.exec(offender);
                     var parts = /^(?:(?:<([^ \(]*)>|\[inline CSS\]) ?)?(?:\((((?! @ ).)*)(?: @ (\d+):(\d+))?\))?$/.exec(offender);
 
 
                     if (parts) {
                     if (parts) {
                         return {
                         return {
-                            error: parts[2],
+                            error: parts[2] || 'Unknown parsing error',
                             file: parts[1] || null,
                             file: parts[1] || null,
                             line: (parts[4] && parts[5]) ? parseInt(parts[4], 10) : null,
                             line: (parts[4] && parts[5]) ? parseInt(parts[4], 10) : null,
                             column: (parts[4] && parts[5]) ? parseInt(parts[5], 10) : null
                             column: (parts[4] && parts[5]) ? parseInt(parts[5], 10) : null
@@ -406,11 +415,11 @@ var policies = {
 
 
                     if (parts) {
                     if (parts) {
                         return {
                         return {
-                            error: parts[1],
+                            error: parts[1] || 'Unknown parsing error',
                             file: parts[2] || null,
                             file: parts[2] || null,
                             line: parseInt(parts[3], 10),
                             line: parseInt(parts[3], 10),
                             column: parseInt(parts[4], 10)
                             column: parseInt(parts[4], 10)
-                        }
+                        };
                     }
                     }