Function sizzle
has a Cognitive Complexity of 595 (exceeds 5 allowed). Consider refactoring. Open
var sizzle = (function() {
if (feature.qsa3 === true) {
return;
}
- 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 sizzle
has 1345 lines of code (exceeds 25 allowed). Consider refactoring. Open
var sizzle = (function() {
if (feature.qsa3 === true) {
return;
}
File sizzle.js
has 1347 lines of code (exceeds 250 allowed). Consider refactoring. Open
// querySelector pollyfill using Sizzle
var sizzle = (function() {
Function setDocument
has 200 lines of code (exceeds 25 allowed). Consider refactoring. Open
setDocument = Sizzle.setDocument = function(node) {
var doc = node ? node.ownerDocument || node : preferredDoc,
parent = doc.defaultView;
// If no document and documentElement is available, return
Function Sizzle
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Sizzle(selector, context, results, seed) {
var match, elem, m, nodeType,
// QSA vars
i, groups, old, nid, newContext, newSelector;
Function matcherFromGroupMatchers
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
function matcherFromGroupMatchers(elementMatchers, setMatchers) {
// A counter to specify which element is currently being matched
var matcherCachedRuns = 0,
bySet = setMatchers.length > 0,
byElement = elementMatchers.length > 0,
Function setMatcher
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) {
if (postFilter && !postFilter[expando]) {
postFilter = setMatcher(postFilter);
}
if (postFinder && !postFinder[expando]) {
Function superMatcher
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
superMatcher = function(seed, context, xml, results, expandContext) {
var elem, j, matcher,
setMatched = [],
matchedCount = 0,
i = "0",
Function CHILD
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
"CHILD": function(type, what, argument, first, last) {
var simple = type.slice(0, 3) !== "nth",
forward = type.slice(-4) !== "last",
ofType = what === "of-type";
Consider simplifying this complex logical expression. Open
if (forward && useCache) {
// Seek `elem` from a previously-cached index
outerCache = parent[expando] || (parent[expando] = {});
cache = outerCache[type] || [];
nodeIndex = cache[0] === dirruns && cache[1];
Function select
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function select(selector, context, results, seed) {
var i, tokens, token, type, find,
match = tokenize(selector);
if (!seed) {
Function tokenize
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function tokenize(selector, parseOnly) {
var matched, match, tokens, type,
soFar, groups, preFilters,
cached = tokenCache[selector + " "];
Function matcherFromTokens
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function matcherFromTokens(tokens) {
var checkContext, matcher, j,
len = tokens.length,
leadingRelative = Expr.relative[tokens[0].type],
implicitRelative = leadingRelative || Expr.relative[" "],
Function addCombinator
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function addCombinator(matcher, combinator, base) {
var dir = combinator.dir,
checkNonElements = base && dir === "parentNode",
doneName = done++;
Consider simplifying this complex logical expression. Open
} else if (useCache && (cache = (elem[expando] || (elem[expando] = {}))[type]) && cache[0] === dirruns) {
diff = cache[1];
// xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
} else {
Consider simplifying this complex logical expression. Open
if (tokens.length > 2 && (token = tokens[0]).type === "ID" &&
support.getById && context.nodeType === 9 && documentIsHTML &&
Expr.relative[tokens[1].type]) {
context = (Expr.find["ID"](token.matches[0].replace(runescape,
Avoid deeply nested control flow statements. Open
if ((data = cache[1]) === true || data === cachedruns) {
return data === true;
}
Avoid deeply nested control flow statements. Open
if (cache[1] === true) {
return true;
}
Avoid deeply nested control flow statements. Open
if ((elem = matcherOut[i])) {
// Restore matcherIn since elem is not yet a final match
temp.push((matcherIn[i] = elem));
}
Avoid deeply nested control flow statements. Open
if (Expr.relative[tokens[j].type]) {
break;
}
Avoid deeply nested control flow statements. Open
if (context.ownerDocument && (elem = context.ownerDocument.getElementById(m)) &&
contains(context, elem) && elem.id === m) {
results.push(elem);
return results;
}
Avoid deeply nested control flow statements. Open
if ((seed = find(
token.matches[0].replace(runescape, funescape),
rsibling.test(tokens[0].type) && context.parentNode || context
))) {
Avoid deeply nested control flow statements. Open
if ((ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) && ++diff) {
// Cache the index of each encountered element
if (useCache) {
(node[expando] || (node[expando] = {}))[type] = [dirruns, diff];
}
Avoid deeply nested control flow statements. Open
if (elem && elem.parentNode) {
// Handle the case where IE, Opera, and Webkit return items
// by name instead of ID
if (elem.id === m) {
results.push(elem);
Function setMatcher
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) {
Avoid deeply nested control flow statements. Open
if (!(unmatched[i] || setMatched[i])) {
setMatched[i] = pop.call(results);
}
Avoid deeply nested control flow statements. Open
if (ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) {
return false;
}
Consider simplifying this complex logical expression. Open
if (support.matchesSelector && documentIsHTML &&
(!rbuggyMatches || !rbuggyMatches.test(expr)) &&
(!rbuggyQSA || !rbuggyQSA.test(expr))) {
try {
Consider simplifying this complex logical expression. Open
if (matcher[expando]) {
// Find the next relative operator (if any) for proper handling
j = ++i;
for (; j < len; j++) {
if (Expr.relative[tokens[j].type]) {
Function CHILD
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
"CHILD": function(type, what, argument, first, last) {
Function condense
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function condense(unmatched, map, filter, context, xml) {
Function superMatcher
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
superMatcher = function(seed, context, xml, results, expandContext) {
Avoid too many return
statements within this function. Open
return results;
Avoid too many return
statements within this function. Open
return results;
Avoid too many return
statements within this function. Open
return compare & 4 ? -1 : 1;
Avoid too many return
statements within this function. Open
return results;
Avoid too many return
statements within this function. Open
return a.compareDocumentPosition ? -1 : 1;
Avoid too many return
statements within this function. Open
return results;
Avoid too many return
statements within this function. Open
return select(selector.replace(rtrim, "$1"), context, results, seed);
Similar blocks of code found in 2 locations. Consider refactoring. Open
var sizzle = (function() {
if (feature.qsa3 === true) {
return;
}
- 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 14143.
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