Permalink
Browse files

Remove complexity

  • Loading branch information...
1 parent 3ef6fcb commit 996246308b755df665bd6c4f3ae59d655ae0a97e @douglascrockford committed Dec 22, 2011
Showing with 4 additions and 76 deletions.
  1. +4 −76 jslint.js
View
@@ -1,5 +1,5 @@
// jslint.js
-// 2011-12-19
+// 2011-12-21
// Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
@@ -204,7 +204,7 @@
/*properties
'\b': string, '\t': string, '\n': string, '\f': string, '\r': string,
'!=': boolean, '!==': boolean, '"': string, '%': boolean, '\'': string,
- '(begin)', '(breakage)': number, '(complexity)', '(confusion)': boolean,
+ '(begin)', '(breakage)': number, '(confusion)': boolean,
'(context)': object, '(error)', '(identifier)', '(line)': number,
'(loopage)': number, '(name)', '(old_property_type)', '(params)',
'(scope)': object, '(token)', '(vars)', '(verb)', '*': boolean,
@@ -794,7 +794,7 @@ var JSLINT = (function () {
},
funct, // The current function, including the labels used in
- // the function, as well as (breakage), (complexity),
+ // the function, as well as (breakage),
// (context), (loopage), (name), (params), (token),
// (vars), (verb)
@@ -4065,75 +4065,6 @@ klass: do {
}
- function complexity(exp) {
- var score = 0;
- if (exp) {
- if (Array.isArray(exp)) {
- exp.forEach(function (tok) {
- score += complexity(tok);
- });
- } else {
- switch (exp.arity) {
- case 'statement':
- switch (exp.id) {
- case 'if':
- score += complexity(exp.first) + complexity(exp.block) +
- complexity(exp['else']) + 1;
- break;
- case 'while':
- case 'do':
- if (exp.first.id !== 'true' && exp.first.number !== 1) {
- score += 1;
- }
- score += complexity(exp.first) + complexity(exp.block);
- break;
- case 'for':
- if (exp.second !== undefined &&
- exp.second.id !== 'true' &&
- exp.second.number !== 1) {
- score += 1;
- }
- score += complexity(exp.first) + complexity(exp.second) +
- complexity(exp.third) + complexity(exp.block);
- break;
- case 'switch':
- score += complexity(exp.first) +
- complexity(exp.second) + exp.second.length;
- if (exp.second[exp.second.length - 1].id === 'default') {
- score -= 1;
- }
- break;
- case 'try':
- if (exp.second) {
- score += 1;
- }
- if (exp.third) {
- score += 1;
- }
- score += complexity(exp.first) + complexity(exp.second) +
- complexity(exp.third) + complexity(exp.block);
- break;
- }
- break;
- case 'prefix':
- score += complexity(exp.first);
- break;
- case 'case':
- case 'infix':
- score += complexity(exp.first) + complexity(exp.second);
- if (exp.id === '&&' || exp.id === '||') {
- score += 1;
- }
- break;
- case 'ternary':
- score += complexity(exp.first) + complexity(exp.second) + complexity(exp.third);
- break;
- }
- }
- }
- return score;
- }
-
function do_function(func, name) {
var old_funct = funct,
@@ -4163,7 +4094,6 @@ klass: do {
property_type = funct['(old_property_type)'];
delete funct['(old_property_type)'];
}
- funct['(complexity)'] = complexity(func.block) + 1;
if (option.confusion) {
funct['(confusion)'] = true;
}
@@ -6733,7 +6663,6 @@ klass: do {
function_data.name = the_function['(name)'];
function_data.params = the_function['(params)'];
function_data.line = the_function['(line)'];
- function_data['(complexity)'] = the_function['(complexity)'];
data.functions.push(function_data);
}
@@ -6862,7 +6791,6 @@ klass: do {
detail('Outer', the_function.outer);
detail('Global', the_function.global);
detail('Label', the_function.label);
- detail('Complexity', the_function['(complexity)']);
}
if (data.member) {
@@ -6939,7 +6867,7 @@ klass: do {
};
itself.jslint = itself;
- itself.edition = '2011-12-19';
+ itself.edition = '2011-12-21';
return itself;
}());

0 comments on commit 9962463

Please sign in to comment.