Disabling eval count because it can cause JS errors

This commit is contained in:
Gaël Métais
2014-12-30 15:29:11 +01:00
parent 909ffc1aac
commit fb4d6afb07
2 changed files with 8 additions and 9 deletions
-1
View File
@@ -23,7 +23,6 @@
"label": "Bad JavaScript",
"policies": {
"jsErrors": 2,
"evalCalls": 1,
"documentWriteCalls": 2,
"consoleMessages": 0.5,
"globalVariables": 0.5
@@ -7,11 +7,11 @@
*/
/* global document: true, window: true */
exports.version = '0.1';
exports.version = '0.1.a';
exports.module = function(phantomas) {
'use strict';
phantomas.setMetric('documentWriteCalls'); //@desc number of calls to either document.write or document.writeln
phantomas.setMetric('evalCalls'); // @desc number of calls to eval (either direct or via setTimeout / setInterval)
@@ -25,23 +25,23 @@ exports.module = function(phantomas) {
}
// spy calls to eval()
phantomas.spy(window, 'eval', function(code) {
/*phantomas.spy(window, 'eval', function(code) {
report('eval() called directly', phantomas.getCaller(), phantomas.getBacktrace(), 'evalCalls');
phantomas.log('eval\'ed code: ' + (code || '').substring(0, 150) + '(...)');
});
});*/
// spy calls to setTimeout / setInterval with string passed instead of a function
phantomas.spy(window, 'setTimeout', function(fn, interval) {
/*phantomas.spy(window, 'setTimeout', function(fn, interval) {
if (typeof fn !== 'string') return;
report('eval() called via setTimeout("' + fn + '")', phantomas.getCaller(), phantomas.getBacktrace(), 'evalCalls');
});
});*/
phantomas.spy(window, 'setInterval', function(fn, interval) {
/*phantomas.spy(window, 'setInterval', function(fn, interval) {
if (typeof fn !== 'string') return;
report('eval() called via setInterval("' + fn + '")', phantomas.getCaller(), phantomas.getBacktrace(), 'evalCalls');
});
});*/
// spy document.write(ln)
phantomas.spy(document, 'write', function(arg) {