adobe/brackets

View on GitHub
src/language/JSONUtils.js

Summary

Maintainability
D
2 days
Test Coverage

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

    function getContextInfo(editor, constPos, requireParent, requireNextToken) {
        var pos, ctx, ctxPrev, ctxNext, offset, keyName, valueName, parentKeyName,
            isArray, exclusionList, hasColon, hasComma, hasBracket, shouldReplace;

        pos = $.extend({}, constPos);
Severity: Major
Found in src/language/JSONUtils.js - About 3 hrs to fix

    Function _getExclusionList has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function _getExclusionList(editor, constPos) {
            var ctxPrev, ctxNext, exclusionList = [], pos, braceParity;
    
            // Move back to find exclusions.
            pos = $.extend({}, constPos);
    Severity: Minor
    Found in src/language/JSONUtils.js - About 1 hr to fix

      Function _createContextInfo has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          function _createContextInfo(token, tokenType, offset, keyName, valueName, parentKeyName, isArray, exclusionList, shouldReplace) {
      Severity: Major
      Found in src/language/JSONUtils.js - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                            if (ctxPrev.token.string === ":") {
                                hasColon = true;
                            } else if (ctxPrev.token.string === ",") {
                                hasComma = true;
                            } else if (ctxPrev.token.string === "[") {
        Severity: Major
        Found in src/language/JSONUtils.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                          } else if (!hasComma) {
                              return null;
                          }
          Severity: Major
          Found in src/language/JSONUtils.js - About 45 mins to fix

            Avoid too many return statements within this function.
            Open

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

              Avoid too many return statements within this function.
              Open

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

                Avoid too many return statements within this function.
                Open

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

                  Avoid too many return statements within this function.
                  Open

                              return _createContextInfo((shouldReplace) ? ctxNext.token : ctx.token, TOKEN_VALUE, offset, keyName, valueName, parentKeyName, isArray, null, shouldReplace);
                  Severity: Major
                  Found in src/language/JSONUtils.js - About 30 mins to fix

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

                            while (TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctxPrev)) {
                                if (ctxPrev.token.type === null) {
                                    if (ctxPrev.token.string === "}") {
                                        braceParity++;
                                    } else if (ctxPrev.token.string === "{") {
                    Severity: Major
                    Found in src/language/JSONUtils.js and 1 other location - About 5 hrs to fix
                    src/language/JSONUtils.js on lines 163..177

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

                    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

                            while (TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctxNext)) {
                                if (ctxNext.token.type === null) {
                                    if (ctxNext.token.string === "{") {
                                        braceParity++;
                                    } else if (ctxNext.token.string === "}") {
                    Severity: Major
                    Found in src/language/JSONUtils.js and 1 other location - About 5 hrs to fix
                    src/language/JSONUtils.js on lines 143..157

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

                    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

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

                                if (ctx.token.type === "string" && /^['"]$/.test(ctx.token.string.substr(-1, 1)) &&
                                        ctx.token.string.length !== 1 && ctx.token.end === pos.ch) {
                                    return null;
                                }
                    Severity: Major
                    Found in src/language/JSONUtils.js and 1 other location - About 2 hrs to fix
                    src/language/XMLUtils.js on lines 257..262

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

                    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