diff --git a/lib/metadata/policies.js b/lib/metadata/policies.js index d88da7a..b9cb910 100644 --- a/lib/metadata/policies.js +++ b/lib/metadata/policies.js @@ -55,7 +55,8 @@ var policies = { "message": "

This is the number of queries that could be avoided by removing all duplicated queries.

Simply save the result of a query in a variable. Ok it is not always simple, especially with third-party scripts, but at least do it with your own code.

", "isOkThreshold": 0, "isBadThreshold": 200, - "isAbnormalThreshold": 500 + "isAbnormalThreshold": 500, + "takeOffendersFrom": "DOMqueriesDuplicated" }, "eventsBound": { "tool": "phantomas", diff --git a/lib/rulesChecker.js b/lib/rulesChecker.js index 1fab084..bbbae49 100644 --- a/lib/rulesChecker.js +++ b/lib/rulesChecker.js @@ -23,6 +23,11 @@ var RulesChecker = function() { policy: policy }; + // Take DOMqueriesAvoidable's offenders from DOMqueriesDuplicated. + if (policy.takeOffendersFrom) { + data.toolsResults[policy.tool].offenders[metricName] = data.toolsResults[policy.tool].offenders[policy.takeOffendersFrom]; + } + if (data.toolsResults[policy.tool].offenders && data.toolsResults[policy.tool].offenders[metricName] && data.toolsResults[policy.tool].offenders[metricName].length > 0) { diff --git a/test/fixtures/rulesCheckerOutput.json b/test/fixtures/rulesCheckerOutput.json index d482344..ef696af 100644 --- a/test/fixtures/rulesCheckerOutput.json +++ b/test/fixtures/rulesCheckerOutput.json @@ -21,9 +21,11 @@ "message": "A great message", "isOkThreshold": 1000, "isBadThreshold": 3000, - "isAbnormalThreshold": 5000 + "isAbnormalThreshold": 5000, + "takeOffendersFrom": "metric3" }, "value": 222, + "offenders": ["offender1", "offender2"], "bad": false, "abnormal": false, "score": 100, diff --git a/test/fixtures/rulesCheckerPolicies.json b/test/fixtures/rulesCheckerPolicies.json index 3cadee3..9c2f064 100644 --- a/test/fixtures/rulesCheckerPolicies.json +++ b/test/fixtures/rulesCheckerPolicies.json @@ -13,7 +13,8 @@ "message": "A great message", "isOkThreshold": 1000, "isBadThreshold": 3000, - "isAbnormalThreshold": 5000 + "isAbnormalThreshold": 5000, + "takeOffendersFrom": "metric3" }, "metric3": { "tool": "tool1",