adobe/brackets

View on GitHub
src/language/CSSUtils.js

Summary

Maintainability
F
1 wk
Test Coverage

File CSSUtils.js has 1138 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2012 - present Adobe Systems Incorporated. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
Severity: Major
Found in src/language/CSSUtils.js - About 2 days to fix

    Function extractAllSelectors has 414 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function extractAllSelectors(text, documentMode) {
            var state, lines, lineCount,
                token, style, stream, line,
                selectors              = [],
                mode                   = CodeMirror.getMode({indentUnit: 2}, documentMode || "css"),
    Severity: Major
    Found in src/language/CSSUtils.js - About 2 days to fix

      Function findSelectorAtDocumentPos has 118 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function findSelectorAtDocumentPos(editor, pos) {
              var cm = editor._codeMirror;
              var ctx = TokenUtils.getInitialContext(cm, $.extend({}, pos));
              var selector = "", foundChars = false;
              var isPreprocessorDoc = isCSSPreprocessorFile(editor.document.file.fullPath);
      Severity: Major
      Found in src/language/CSSUtils.js - About 4 hrs to fix

        Function _parseSelector has 75 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                function _parseSelector(start, level) {
        
                    currentSelector = "";
                    selectorStartChar = start;
                    selectorStartLine = line;
        Severity: Major
        Found in src/language/CSSUtils.js - About 3 hrs to fix

          Function _getRuleInfoStartingFromPropValue has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function _getRuleInfoStartingFromPropValue(ctx, editorParam) {
                  var editor      = editorParam._codeMirror || editorParam,
                      contextDoc  = editor.document || editor.doc,
                      propNamePos = $.extend({}, ctx.pos),
                      backwardPos = $.extend({}, ctx.pos),
          Severity: Major
          Found in src/language/CSSUtils.js - About 2 hrs to fix

            Function _parseDeclarationList has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function _parseDeclarationList(level) {
            
                        var j;
                        declListStartLine = Math.min(line, lineCount - 1);
                        declListStartChar = stream.start;
            Severity: Major
            Found in src/language/CSSUtils.js - About 2 hrs to fix

              Function _getPropNameInfo has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function _getPropNameInfo(ctx) {
                      var propName = "",
                          offset = TokenUtils.offsetInToken(ctx),
                          tokenString = ctx.token.string,
                          excludedCharacters = [";", "{", "}"];
              Severity: Minor
              Found in src/language/CSSUtils.js - About 1 hr to fix

                Function _getImportUrlInfo has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function _getImportUrlInfo(ctx, editor) {
                        var backwardPos = $.extend({}, ctx.pos),
                            forwardPos  = $.extend({}, ctx.pos),
                            backwardCtx,
                            forwardCtx,
                Severity: Minor
                Found in src/language/CSSUtils.js - About 1 hr to fix

                  Function _getSucceedingPropValues has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function _getSucceedingPropValues(ctx, currentValue) {
                          var lastValue = currentValue,
                              propValues = [];
                  
                          while (ctx.token.string !== ";" && ctx.token.string !== "}" && TokenUtils.moveNextToken(ctx)) {
                  Severity: Minor
                  Found in src/language/CSSUtils.js - About 1 hr to fix

                    Function _parseAtRule has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            function _parseAtRule(level) {
                    
                                // reset these fields to ignore comments preceding @rules
                                ruleStartLine = -1;
                                ruleStartChar = -1;
                    Severity: Minor
                    Found in src/language/CSSUtils.js - About 1 hr to fix

                      Function _getPrecedingPropValues has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function _getPrecedingPropValues(ctx) {
                              var lastValue = "",
                                  curValue,
                                  propValues = [];
                              while (ctx.token.string !== ":" && TokenUtils.movePrevToken(ctx)) {
                      Severity: Minor
                      Found in src/language/CSSUtils.js - About 1 hr to fix

                        Function _findAllMatchingSelectorsInText has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            function _findAllMatchingSelectorsInText(text, selector, mode) {
                                var allSelectors = extractAllSelectors(text, mode);
                                var result = [];
                        
                                // For now, we only match the rightmost simple selector, and ignore
                        Severity: Minor
                        Found in src/language/CSSUtils.js - About 1 hr to fix

                          Function createInfo has 7 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              function createInfo(context, offset, name, index, values, isNewItem, range) {
                          Severity: Major
                          Found in src/language/CSSUtils.js - About 50 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if (isPreprocessorDoc && !/^\s*@/.test(selector)) {
                                                        selectorArray.push(selector);
                                                    }
                            Severity: Major
                            Found in src/language/CSSUtils.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if (!isPreprocessorDoc && _hasNonWhitespace(ctx.token.string)) {
                                                      foundChars = true;
                                                  }
                              Severity: Major
                              Found in src/language/CSSUtils.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if (state.state === "top") {
                                                            break;
                                                        }
                                Severity: Major
                                Found in src/language/CSSUtils.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      } else if (ctx.token.string === "}" || ctx.token.string === ";") {
                                                          break;
                                                      }
                                  Severity: Major
                                  Found in src/language/CSSUtils.js - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        if (!_parseRule(level === undefined ? 0 : level) && level > 0) {
                                                            return false;
                                                        }
                                    Severity: Major
                                    Found in src/language/CSSUtils.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                          if (isPreprocessorDoc) {
                                                              if (!skipPrevSibling && !/^\s*@/.test(selector)) {
                                                                  selectorArray.unshift(selector);
                                                              }
                                                              if (skipPrevSibling) {
                                      Severity: Major
                                      Found in src/language/CSSUtils.js - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                            if (level > 0) {
                                                                return true;
                                                            }
                                        Severity: Major
                                        Found in src/language/CSSUtils.js - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                              if (!_skipProperty()) {
                                                                  // We found a "{" or "}" while skipping a property. Return false to handle the
                                                                  // opening or closing of a block properly.
                                                                  return false;
                                                              }
                                          Severity: Major
                                          Found in src/language/CSSUtils.js - About 45 mins to fix

                                            Consider simplifying this complex logical expression.
                                            Open

                                                    if ((!selector && !foundChars && !isPreprocessorDoc) ||
                                                            (isPreprocessorDoc && (ctx.token.string === "" || /\s+/.test(ctx.token.string)))) {
                                                        if (TokenUtils.moveNextToken(ctx) && ctx.token.type !== "comment" && _hasNonWhitespace(ctx.token.string)) {
                                                            foundChars = true;
                                                            ctx = TokenUtils.getInitialContext(cm, $.extend({}, pos));
                                            Severity: Major
                                            Found in src/language/CSSUtils.js - About 40 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                          return true;
                                              Severity: Major
                                              Found in src/language/CSSUtils.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                        return createInfo();
                                                Severity: Major
                                                Found in src/language/CSSUtils.js - About 30 mins to fix

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

                                                              var testPos = {ch: ctx.pos.ch + 1, line: ctx.pos.line},
                                                                  testToken = ctx.editor.getTokenAt(testPos, true);
                                                  Severity: Major
                                                  Found in src/language/CSSUtils.js and 1 other location - About 1 hr to fix
                                                  src/language/HTMLUtils.js on lines 343..344

                                                  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 55.

                                                  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

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

                                                          function _nextTokenSkippingWhitespace() {
                                                              if (!_nextToken()) {
                                                                  return false;
                                                              }
                                                              while (!_hasNonWhitespace(token)) {
                                                  Severity: Minor
                                                  Found in src/language/CSSUtils.js and 1 other location - About 55 mins to fix
                                                  src/language/CSSUtils.js on lines 800..810

                                                  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 54.

                                                  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

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

                                                          function _firstTokenSkippingWhitespace() {
                                                              if (!_firstToken()) {
                                                                  return false;
                                                              }
                                                              while (!_hasNonWhitespace(token)) {
                                                  Severity: Minor
                                                  Found in src/language/CSSUtils.js and 1 other location - About 55 mins to fix
                                                  src/language/CSSUtils.js on lines 812..822

                                                  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 54.

                                                  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

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

                                                              if (TokenUtils.moveNextToken(ctx) &&
                                                                      (ctx.token.type === "property" || ctx.token.type === "property error" ||
                                                                      ctx.token.type === "tag")) {
                                                  Severity: Minor
                                                  Found in src/language/CSSUtils.js and 1 other location - About 35 mins to fix
                                                  src/language/HTMLUtils.js on lines 394..396

                                                  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 46.

                                                  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