Function JSLINT
has a Cognitive Complexity of 2546 (exceeds 5 allowed). Consider refactoring. Open
var JSLINT = (function () {
var adsafe_id, // The widget's ADsafe id.
adsafe_may, // The widget may load approved scripts.
adsafe_went, // ADSAFE.go has been called.
anonname, // The guessed name for anonymous functions.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function JSLINT
has 5047 lines of code (exceeds 25 allowed). Consider refactoring. Open
var JSLINT = (function () {
var adsafe_id, // The widget's ADsafe id.
adsafe_may, // The widget may load approved scripts.
adsafe_went, // ADSAFE.go has been called.
anonname, // The guessed name for anonymous functions.
File jslint.js
has 5086 lines of code (exceeds 250 allowed). Consider refactoring. Open
// jslint.js
// 2010-11-18
/*
Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
Function lex
has 689 lines of code (exceeds 25 allowed). Consider refactoring. Open
var lex = (function lex() {
var character, from, line, s;
// Private lex methods
Function token
has 583 lines of code (exceeds 25 allowed). Consider refactoring. Open
token: function () {
var b, c, captures, d, depth, high, i, l, low, q, t;
function match(x) {
var r = x.exec(s), r1;
Function html
has 195 lines of code (exceeds 25 allowed). Consider refactoring. Open
function html() {
var a, attributes, e, n, q, t, v, w = option.white, wmode;
xmode = 'html';
xquote = '';
stack = null;
Function itself
has 141 lines of code (exceeds 25 allowed). Consider refactoring. Open
var itself = function (s, o) {
var a, i;
JSLINT.errors = [];
predefined = Object.create(standard);
if (o) {
Function doTag
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
function doTag(n, a) {
var i, t = htmltag[n], x;
src = false;
if (!t) {
error("Unrecognized tag '<{a}>'.",
Function styleSelector
has 116 lines of code (exceeds 25 allowed). Consider refactoring. Open
function styleSelector() {
if (nexttoken.identifier) {
if (!is_own(htmltag, option.cap ?
nexttoken.value.toLowerCase() : nexttoken.value)) {
warning("Expected a tagName, and instead saw {a}.",
Function string
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
function string(x) {
var c, j, r = '';
if (jsonmode && x !== '"') {
warningAt("Strings must use doublequote.",
Function report
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
itself.report = function (option) {
var data = itself.data();
var a = [], c, e, err, f, i, k, l, m = '', n, o = [], s;
Function doOption
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
function doOption() {
var b, obj, filter, o = nexttoken.value, t, v;
switch (o) {
case '*/':
error("Unbegun comment.");
Function labelled
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
blockstmt('switch', function () {
var t = nexttoken,
g = false;
funct['(breakage)'] += 1;
advance('(');
Function jsonValue
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
function jsonValue() {
function jsonObject() {
var o = {}, t = nexttoken;
advance('{');
Function nud
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
nud: function () {
var v = this.value,
s = scope[v],
f;
if (typeof s === 'function') {
Function labelled
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
blockstmt('for', function () {
var f = option.forin, s, t = nexttoken;
funct['(breakage)'] += 1;
funct['(loopage)'] += 1;
advance('(');
Function nud
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
x.nud = function () {
var b, f, i, j, p, seen = {}, t;
b = token.line !== nexttoken.line;
if (b) {
indent += option.indent;
Function data
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
itself.data = function () {
var data = {functions: []}, fu, globals, implieds = [], f, i, j,
members = [], n, unused = [], v;
if (itself.errors.length) {
Function statements
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
function statements(begin) {
var a = [], f, p;
if (begin && !use_strict() && option.strict) {
warning('Missing "use strict" statement.', nexttoken);
}
Function exps
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
infix('(', function (left, that) {
if (prevtoken.id !== '}' && prevtoken.id !== ')') {
nobreak(prevtoken, token);
}
nospace();
Consider simplifying this complex logical expression. Open
if ((i.id === '(number)' && /[.+\-Ee]/.test(i.value)) ||
(i.id === '-' && !i.right) ||
i.id === '(string)' || i.id === '[' ||
i.id === '{' || i.id === 'true' ||
i.id === 'false' ||
Function styleValue
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
function styleValue(v) {
var i = 0,
n,
once,
match,
Function doAttribute
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
function doAttribute(n, a, v) {
var u, x;
if (a === 'id') {
u = typeof v === 'string' ? v.toUpperCase() : '';
if (ids[u] === true) {
Function cssColor
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
function cssColor() {
var i, number, value;
if (nexttoken.identifier) {
value = nexttoken.value;
if (value === 'rgb' || value === 'rgba') {
Function advance
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
function advance(id, t) {
switch (token.id) {
case '(number)':
if (nexttoken.id === '.') {
warning(
Function statement
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function statement(noindent) {
var i = indent, r, s = scope, t = nexttoken;
// We don't like the empty statement.
Function cssCounter
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function cssCounter() {
if (nexttoken.identifier && nexttoken.value === 'counter') {
advance();
advance('(');
advance();
Function parse
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parse(rbp, initial) {
var left;
if (nexttoken.id === '(end)') {
error("Unexpected early end of program.", token);
}
Function styles
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function styles() {
var i;
while (nexttoken.id === '@') {
i = peek();
advance('@');
Function assignop
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function assignop(s, f) {
symbol(s, 20).exps = true;
return infix(s, function (left, that) {
var l;
that.left = left;
Function varstatement
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
var varstatement = function varstatement(prefix) {
// JavaScript does not have block scope. It only has function scope. So,
// declaring a variable in a block can have unexpected consequences.
Function it
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function it(type, value) {
var i, t;
if (type === '(color)' || type === '(range)') {
t = {type: type};
} else if (type === '(punctuator)' ||
Function styleAttribute
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function styleAttribute() {
var v;
while (nexttoken.id === '*' || nexttoken.id === '#' ||
nexttoken.value === '_') {
if (!option.css) {
Function substyle
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function substyle() {
var v;
for (;;) {
if (nexttoken.id === '}' || nexttoken.id === '(end)' ||
xquote && nexttoken.id === xquote) {
Function block
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function block(f) {
var a, b = inblock, old_indent = indent, s = scope, t;
inblock = f;
scope = Object.create(scope);
nonadjacent(token, nexttoken);
Function jsonObject
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function jsonObject() {
var o = {}, t = nexttoken;
advance('{');
if (nexttoken.id !== '}') {
for (;;) {
Function warning
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function warning(m, t, a, b, c, d) {
var ch, l, w;
t = t || nexttoken;
if (t.id === '(end)') { // `~
t = token;
Function cssUrl
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function cssUrl() {
var c, url;
if (nexttoken.identifier && nexttoken.value === 'url') {
nexttoken = lex.range('(', ')');
url = nexttoken.value;
Consider simplifying this complex logical expression. Open
if (!left.identifier && left.id !== '.' && left.id !== '[' &&
left.id !== '(' && left.id !== '&&' && left.id !== '||' &&
left.id !== '?') {
warning("Bad invocation.", left);
}
Function warningAt
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
function warningAt(m, l, ch, a, b, c, d) {
Function errorAt
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
function errorAt(m, l, ch, a, b, c, d) {
Avoid deeply nested control flow statements. Open
if (option.adsafe) {
if (adsafe_id) {
if (v.slice(0, adsafe_id.length) !== adsafe_id) {
warning("ADsafe violation: An id must have a '{a}' prefix",
nexttoken, adsafe_id);
Avoid deeply nested control flow statements. Open
if (nexttoken.id === ')') {
warning("Use the array literal notation [].", token);
} else {
i = parse(0);
c.dimension = i;
Avoid deeply nested control flow statements. Open
if (!nexttoken.identifier || cssMedia[nexttoken.value] === true) {
error("Expected a CSS media type, and instead saw '{a}'.", nexttoken, nexttoken.id);
}
Avoid deeply nested control flow statements. Open
if (!nextLine()) {
errorAt("Unclosed comment.", line, character);
} else {
if (option.safe && ax.test(s)) {
warningAt("ADsafe comment violation.",
Avoid deeply nested control flow statements. Open
if (i < a.length - 1) {
n += ', ';
}
Avoid deeply nested control flow statements. Open
if (nexttoken.id === '(end)' || nexttoken.id === '(error)') {
error("Missing '>'.", nexttoken);
}
Avoid deeply nested control flow statements. Open
} else if (a === 'name') {
if (option.adsafe && v.indexOf('_') >= 0) {
warning("ADsafe name violation.");
}
}
Avoid deeply nested control flow statements. Open
if (v === 'unused') {
unused.push({
name: n,
line: f['(line)'],
'function': f['(name)']
Avoid deeply nested control flow statements. Open
if (!option.on) {
warning("Avoid HTML event handlers.");
}
Avoid deeply nested control flow statements. Open
if (d.isDigit()) {
if (token.id !== '.' && xmode !== 'styleproperty') {
warningAt("Don't use extra leading zeros '{a}'.",
line, character, t);
}
Avoid deeply nested control flow statements. Open
if (t.length !== 4 && t.length !== 7) {
warningAt("Bad hex color '{a}'.", line,
from + l, t);
}
Avoid deeply nested control flow statements. Open
if (nexttoken.id !== q) {
error("Missing close quote on script attribute.");
}
Avoid deeply nested control flow statements. Open
if (!nextLine()) {
errorAt("Unclosed HTML comment.", l, c);
}
Avoid deeply nested control flow statements. Open
if (nexttoken.id !== '>') {
warning("Expected '{a}' and instead saw '{b}'.",
nexttoken, '>', nexttoken.value);
}
Avoid deeply nested control flow statements. Open
for (;;) {
b = true;
c = s.charAt(l);
l += 1;
switch (c) {
Avoid deeply nested control flow statements. Open
switch (s[v]) {
case 'function':
case 'unction':
this['function'] = true;
s[v] = 'closure';
Avoid deeply nested control flow statements. Open
for (;;) {
c = s.charAt(0);
character += 1;
s = s.substr(1);
if (c === ';') {
Avoid deeply nested control flow statements. Open
if (i <= 0) {
error("A '<{a}>' must be within '<{b}>'.",
token, n, 'body');
}
Avoid deeply nested control flow statements. Open
if (option.newcap && (i < 'A' || i > 'Z')) {
warning(
"A constructor name should start with an uppercase letter.",
token);
}
Avoid deeply nested control flow statements. Open
if (data.member[k] === 1) {
n = '<i>' + n + '</i>';
}
Avoid deeply nested control flow statements. Open
if (nexttoken.id !== ',') {
break;
}
Function warning
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function warning(m, t, a, b, c, d) {
Avoid deeply nested control flow statements. Open
if (i >= 0) {
break;
}
Avoid deeply nested control flow statements. Open
for (;;) {
c = s.charAt(0);
if ((c < '0' || c > '9') &&
(c < 'a' || c > 'f') &&
(c < 'A' || c > 'F')) {
Avoid deeply nested control flow statements. Open
} else if (a === 'style') {
xmode = 'scriptstring';
advance('=');
q = nexttoken.id;
if (q !== '"' && q !== "'") {
Avoid deeply nested control flow statements. Open
if (l + n.length > 72) {
o.push(m + '<br>');
m = ' ';
l = 1;
}
Avoid deeply nested control flow statements. Open
if (xmode === 'html') {
if (option.safe) {
warningAt("ADsafe string violation.",
line, character + j);
}
Avoid deeply nested control flow statements. Open
if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
Math.floor(b) !== b) {
error("Expected a small integer and instead saw '{a}'.",
v, v.value);
}
Avoid deeply nested control flow statements. Open
} else if (t.value === 'maxlen' && o === '/*jslint') {
b = +v.value;
if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
Math.floor(b) !== b) {
error("Expected a small integer and instead saw '{a}'.",
Avoid deeply nested control flow statements. Open
if (q !== '"' && q !== "'") {
error("Missing quote.");
}
Function error
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function error(m, t, a, b, c, d) {
Avoid deeply nested control flow statements. Open
if (i >= 0) {
break;
}
Avoid deeply nested control flow statements. Open
if (nexttoken.id === '%') {
advance('%');
if (number > 100) {
warning("Expected a percentage and instead saw '{a}'",
token, number);
Avoid deeply nested control flow statements. Open
if (left.value === 'Math') {
warning("Math is not a function.", left);
} else if (option.newcap) {
warning(
"Missing 'new' prefix when invoking a constructor.", left);
Avoid deeply nested control flow statements. Open
if (i >= 0) {
errorAt("Nested HTML comment.",
line, character + i);
}
Avoid deeply nested control flow statements. Open
if (option.undef) {
warning("'{a}' is not defined.", token, v);
} else {
funct[v] = true;
}
Avoid deeply nested control flow statements. Open
if (nexttoken.id !== ',') {
break;
}
Consider simplifying this complex logical expression. Open
} else if (a === 'href' || a === 'background' ||
a === 'content' || a === 'data' ||
a.indexOf('src') >= 0 || a.indexOf('url') >= 0) {
if (option.safe && ux.test(v)) {
error("ADsafe URL violation.");
Consider simplifying this complex logical expression. Open
if (nexttoken.id === '=' || nexttoken.value === '~=' ||
nexttoken.value === '$=' ||
nexttoken.value === '|=' ||
nexttoken.id === '*=' ||
nexttoken.id === '^=') {
Consider simplifying this complex logical expression. Open
if (!nexttoken.identifier &&
nexttoken.id !== '"' &&
nexttoken.id !== '\'' &&
nexttoken.type !== '(string)' &&
nexttoken.type !== '(number)' &&
Consider simplifying this complex logical expression. Open
if ((c < '0' || c > '9') &&
(c < 'a' || c > 'f') &&
(c < 'A' || c > 'F')) {
break;
}
Avoid too many return
statements within this function. Open
return it('(color)', t);
Avoid too many return
statements within this function. Open
return match;
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
return it('(punctuator)', t);
Avoid too many return
statements within this function. Open
return it('(punctuator)', t);
Avoid too many return
statements within this function. Open
return it('(punctuator)', t);
Avoid too many return
statements within this function. Open
return it('(regexp)', c);
Avoid too many return
statements within this function. Open
return it('(regexp)', c);
Avoid too many return
statements within this function. Open
return it('(number)', t);
Identical blocks of code found in 2 locations. Consider refactoring. Open
var JSLINT = (function () {
var adsafe_id, // The widget's ADsafe id.
adsafe_may, // The widget may load approved scripts.
adsafe_went, // ADSAFE.go has been called.
anonname, // The guessed name for anonymous functions.
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 38052.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
(function(a) {
var input="";
var line="";
var blankcount="0";
while (blankcount < 10){
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 321.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76