erikroyall/hilo

View on GitHub
src/sizzle.js

Summary

Maintainability
F
4 mos
Test Coverage

Function sizzle has a Cognitive Complexity of 595 (exceeds 5 allowed). Consider refactoring.
Open

  var sizzle = (function() {

    if (feature.qsa3 === true) {
      return;
    }
Severity: Minor
Found in src/sizzle.js - About 1 wk to fix

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;
    }
Severity: Major
Found in src/sizzle.js - About 6 days to fix

    File sizzle.js has 1347 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    
      // querySelector pollyfill using Sizzle
    
      var sizzle = (function() {
    
    
    Severity: Major
    Found in src/sizzle.js - About 3 days to fix

      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
      Severity: Major
      Found in src/sizzle.js - About 1 day to fix

        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;
        
        
        Severity: Major
        Found in src/sizzle.js - About 3 hrs to fix

          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,
          Severity: Major
          Found in src/sizzle.js - About 2 hrs to fix

            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]) {
            Severity: Major
            Found in src/sizzle.js - About 2 hrs to fix

              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",
              Severity: Major
              Found in src/sizzle.js - About 2 hrs to fix

                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";
                
                
                Severity: Major
                Found in src/sizzle.js - About 2 hrs to fix

                  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];
                  Severity: Critical
                  Found in src/sizzle.js - About 2 hrs to fix

                    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) {
                    Severity: Minor
                    Found in src/sizzle.js - About 1 hr to fix

                      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 + " "];
                      
                      
                      Severity: Minor
                      Found in src/sizzle.js - About 1 hr to fix

                        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[" "],
                        Severity: Minor
                        Found in src/sizzle.js - About 1 hr to fix

                          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++;
                          
                          
                          Severity: Minor
                          Found in src/sizzle.js - About 1 hr to fix

                            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 {
                            Severity: Critical
                            Found in src/sizzle.js - About 1 hr to fix

                              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, 
                              Severity: Major
                              Found in src/sizzle.js - About 1 hr to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                  if ((data = cache[1]) === true || data === cachedruns) {
                                                    return data === true;
                                                  }
                                Severity: Major
                                Found in src/sizzle.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                    if (cache[1] === true) {
                                                      return true;
                                                    }
                                  Severity: Major
                                  Found in src/sizzle.js - About 45 mins to fix

                                    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));
                                                    }
                                    Severity: Major
                                    Found in src/sizzle.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                    if (Expr.relative[tokens[j].type]) {
                                                      break;
                                                    }
                                      Severity: Major
                                      Found in src/sizzle.js - About 45 mins to fix

                                        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;
                                                      }
                                        Severity: Major
                                        Found in src/sizzle.js - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                        if ((seed = find(
                                                          token.matches[0].replace(runescape, funescape),
                                                          rsibling.test(tokens[0].type) && context.parentNode || context
                                                       ))) {
                                          
                                          
                                          Severity: Major
                                          Found in src/sizzle.js - About 45 mins to fix

                                            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];
                                                                  }
                                            Severity: Major
                                            Found in src/sizzle.js - About 45 mins to fix

                                              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);
                                              Severity: Major
                                              Found in src/sizzle.js - About 45 mins to fix

                                                Function setMatcher has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                Open

                                                    function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) {
                                                Severity: Minor
                                                Found in src/sizzle.js - About 45 mins to fix

                                                  Avoid deeply nested control flow statements.
                                                  Open

                                                                    if (!(unmatched[i] || setMatched[i])) {
                                                                      setMatched[i] = pop.call(results);
                                                                    }
                                                  Severity: Major
                                                  Found in src/sizzle.js - About 45 mins to fix

                                                    Avoid deeply nested control flow statements.
                                                    Open

                                                                          if (ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) {
                                                                            return false;
                                                                          }
                                                    Severity: Major
                                                    Found in src/sizzle.js - About 45 mins to fix

                                                      Consider simplifying this complex logical expression.
                                                      Open

                                                            if (support.matchesSelector && documentIsHTML &&
                                                              (!rbuggyMatches || !rbuggyMatches.test(expr)) &&
                                                              (!rbuggyQSA     || !rbuggyQSA.test(expr))) {
                                                      
                                                              try {
                                                      Severity: Major
                                                      Found in src/sizzle.js - About 40 mins to fix

                                                        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]) {
                                                        Severity: Major
                                                        Found in src/sizzle.js - About 40 mins to fix

                                                          Function CHILD has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                          Open

                                                                  "CHILD": function(type, what, argument, first, last) {
                                                          Severity: Minor
                                                          Found in src/sizzle.js - About 35 mins to fix

                                                            Function condense has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                            Open

                                                                function condense(unmatched, map, filter, context, xml) {
                                                            Severity: Minor
                                                            Found in src/sizzle.js - About 35 mins to fix

                                                              Function superMatcher has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                              Open

                                                                      superMatcher = function(seed, context, xml, results, expandContext) {
                                                              Severity: Minor
                                                              Found in src/sizzle.js - About 35 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                                return results;
                                                                Severity: Major
                                                                Found in src/sizzle.js - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                              return results;
                                                                  Severity: Major
                                                                  Found in src/sizzle.js - About 30 mins to fix

                                                                    Avoid too many return statements within this function.
                                                                    Open

                                                                              return compare & 4 ? -1 : 1;
                                                                    Severity: Major
                                                                    Found in src/sizzle.js - About 30 mins to fix

                                                                      Avoid too many return statements within this function.
                                                                      Open

                                                                                    return results;
                                                                      Severity: Major
                                                                      Found in src/sizzle.js - About 30 mins to fix

                                                                        Avoid too many return statements within this function.
                                                                        Open

                                                                                return a.compareDocumentPosition ? -1 : 1;
                                                                        Severity: Major
                                                                        Found in src/sizzle.js - About 30 mins to fix

                                                                          Avoid too many return statements within this function.
                                                                          Open

                                                                                      return results;
                                                                          Severity: Major
                                                                          Found in src/sizzle.js - About 30 mins to fix

                                                                            Avoid too many return statements within this function.
                                                                            Open

                                                                                  return select(selector.replace(rtrim, "$1"), context, results, seed);
                                                                            Severity: Major
                                                                            Found in src/sizzle.js - About 30 mins to fix

                                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                                              Open

                                                                                var sizzle = (function() {
                                                                              
                                                                                  if (feature.qsa3 === true) {
                                                                                    return;
                                                                                  }
                                                                              Severity: Major
                                                                              Found in src/sizzle.js and 1 other location - About 3 mos to fix
                                                                              build/hilo-legacy.js on lines 1076..3093

                                                                              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

                                                                              Further Reading

                                                                              There are no issues that match your filters.

                                                                              Category
                                                                              Status