Browse Source

Add DOMqueriesWithoutResults as a rule

Gaël Métais 10 years ago
parent
commit
6fe61a041e
2 changed files with 9 additions and 0 deletions
  1. 8 0
      lib/metadata/policies.js
  2. 1 0
      lib/metadata/scoreProfileGeneric.json

+ 8 - 0
lib/metadata/policies.js

@@ -58,6 +58,14 @@ var policies = {
         "isAbnormalThreshold": 500,
         "isAbnormalThreshold": 500,
         "takeOffendersFrom": "DOMqueriesDuplicated"
         "takeOffendersFrom": "DOMqueriesDuplicated"
     },
     },
+    "DOMqueriesWithoutResults": {
+        "tool": "phantomas",
+        "label": "DOM queries without result",
+        "message": "<p>Number of queries that return no result.</p><p>It suggests the query is not used on the page, probably because it is some dead code.</p><p>Or maybe the code is trying to find an HTML block that is not always here. Look at the JS Timeline to see if the scripts correctly figures out the HTML block is not here and immediatly stops interacting further with the DOM.</p>",
+        "isOkThreshold": 0,
+        "isBadThreshold": 100,
+        "isAbnormalThreshold": 200
+    },
     "eventsBound": {
     "eventsBound": {
         "tool": "phantomas",
         "tool": "phantomas",
         "label": "Events bound",
         "label": "Events bound",

+ 1 - 0
lib/metadata/scoreProfileGeneric.json

@@ -14,6 +14,7 @@
             "policies": {
             "policies": {
                 "DOMinserts": 2,
                 "DOMinserts": 2,
                 "DOMqueries": 1,
                 "DOMqueries": 1,
+                "DOMqueriesWithoutResults": 2,
                 "DOMqueriesAvoidable": 2,
                 "DOMqueriesAvoidable": 2,
                 "eventsBound": 1
                 "eventsBound": 1
             }
             }