|
@@ -35,7 +35,7 @@ var policies = {
|
|
|
"isOkThreshold": 3,
|
|
|
"isBadThreshold": 15,
|
|
|
"isAbnormalThreshold": 30,
|
|
|
- "hasOffenders": false
|
|
|
+ "hasOffenders": true
|
|
|
},
|
|
|
"DOMidDuplicated": {
|
|
|
"tool": "phantomas",
|
|
@@ -378,45 +378,12 @@ var policies = {
|
|
|
"isOkThreshold": 1000,
|
|
|
"isBadThreshold": 3000,
|
|
|
"isAbnormalThreshold": 4500,
|
|
|
- "hasOffenders": true,
|
|
|
- "offendersTransformFn": function(offenders) {
|
|
|
- var hasInline = false;
|
|
|
- var inlineCount = 0;
|
|
|
- var files = [];
|
|
|
-
|
|
|
- offenders.forEach(function(line) {
|
|
|
- if (line.indexOf('[inline CSS]: ') === 0) {
|
|
|
- hasInline = true;
|
|
|
- inlineCount += parseInt(line.substr(14));
|
|
|
- } else {
|
|
|
- var parts = /^<(.*)>: (\d+)$/.exec(line);
|
|
|
-
|
|
|
- if (parts) {
|
|
|
- files.push({
|
|
|
- file: parts[1],
|
|
|
- rules: parseInt(parts[2], 10)
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- if (hasInline) {
|
|
|
- files.push({
|
|
|
- file: 'inline CSS',
|
|
|
- rules: inlineCount
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- return {
|
|
|
- count: files.length,
|
|
|
- list: files
|
|
|
- };
|
|
|
- }
|
|
|
+ "hasOffenders": true
|
|
|
},
|
|
|
"cssComplexSelectors": {
|
|
|
"tool": "phantomas",
|
|
|
"label": "Complex selectors",
|
|
|
- "message": "<p>Complex selectors are CSS selectors with 4 or more expressions, like \"#header ul li .foo\".</p><p>They are adding more work for the browser, and this could be avoided by simplifying selectors. The <a href=\"http://getbem.com\" target=\"_blank\">B.E.M. methodology</a> is an useful way to simplify your CSS.</p>",
|
|
|
+ "message": "<p>Complex selectors are CSS selectors with 4 or more expressions, like \"#header ul li .foo\".</p><p>They are adding more work for the browser, and this could be avoided by simplifying selectors. The <a href=\"http://getbem.com\" target=\"_blank\">B.E.M. methodology</a> is a useful way to simplify your CSS.</p>",
|
|
|
"isOkThreshold": 0,
|
|
|
"isBadThreshold": 800,
|
|
|
"isAbnormalThreshold": 2000,
|
|
@@ -442,10 +409,10 @@ var policies = {
|
|
|
var deduplicatedObj = {};
|
|
|
|
|
|
offenders.map(function(offender) {
|
|
|
- var parts = /^([^ ]*) \((\d+) times\)$/.exec(offender);
|
|
|
+ var parts = /^([^ ]*) \((\d+) times\)$/.exec(offender.value.message);
|
|
|
|
|
|
if (!parts) {
|
|
|
- debug('cssColors offenders transform function error with "%s"', offender);
|
|
|
+ debug('cssColors offenders transform function error with "%s"', offender.value.message);
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -553,7 +520,7 @@ var policies = {
|
|
|
"hasOffenders": true,
|
|
|
"offendersTransformFn": function(offenders) {
|
|
|
var parsedOffenders = offenders.map(function(offender) {
|
|
|
- var parts = /^(.*) \((\d+) times\) ?<(.*)>$/.exec(offender);
|
|
|
+ var parts = /^(.*) \((\d+) times\)$/.exec(offender.value.message);
|
|
|
|
|
|
if (!parts) {
|
|
|
debug('cssDuplicatedSelectors offenders transform function error with "%s"', offender);
|
|
@@ -565,7 +532,7 @@ var policies = {
|
|
|
return {
|
|
|
rule: parts[1],
|
|
|
occurrences: parseInt(parts[2], 10),
|
|
|
- file: parts[3]
|
|
|
+ file: offender.value.url
|
|
|
};
|
|
|
});
|
|
|
|
|
@@ -911,27 +878,7 @@ var policies = {
|
|
|
"isOkThreshold": 10,
|
|
|
"isBadThreshold": 25,
|
|
|
"isAbnormalThreshold": 50,
|
|
|
- "hasOffenders": true,
|
|
|
- "offendersTransformFn": function(offenders) {
|
|
|
- return {
|
|
|
- count: offenders.length,
|
|
|
- list: offenders.map(function(offender) {
|
|
|
- var parts = /^([^ ]*): (\d+) request\(s\)$/.exec(offender);
|
|
|
-
|
|
|
- if (!parts) {
|
|
|
- debug('domains offenders transform function error with "%s"', offender);
|
|
|
- return {
|
|
|
- file: offender
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- return {
|
|
|
- domain: parts[1],
|
|
|
- requests: parseInt(parts[2])
|
|
|
- };
|
|
|
- })
|
|
|
- };
|
|
|
- }
|
|
|
+ "hasOffenders": true
|
|
|
},
|
|
|
"notFound": {
|
|
|
"tool": "phantomas",
|
|
@@ -1095,22 +1042,7 @@ var policies = {
|
|
|
return {
|
|
|
count: offenders.length,
|
|
|
list: offenders
|
|
|
- .map(function(offender) {
|
|
|
- var parts = /^([^ ]*) cached for (-?\d+(\.\d+)?) s$/.exec(offender);
|
|
|
-
|
|
|
- if (!parts) {
|
|
|
- debug('cachingTooShort offenders transform function error with "%s"', offender);
|
|
|
- return {
|
|
|
- file: offender
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- return {
|
|
|
- file: parts[1],
|
|
|
- ttl: Math.round(parseFloat(parts[2]))
|
|
|
- };
|
|
|
-
|
|
|
- }).sort(function(a, b) {
|
|
|
+ .sort(function(a, b) {
|
|
|
|
|
|
return a.ttl - b.ttl;
|
|
|
|