adobe/brackets

View on GitHub
src/language/HTMLUtils.js

Summary

Maintainability
D
3 days
Test Coverage

Function getTagInfo has 102 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function getTagInfo(editor, constPos, isHtmlMode) {
        // We're going to be changing pos a lot, but we don't want to mess up
        // the pos the caller passed in so we use extend to make a safe copy of it.
        var pos = $.extend({}, constPos),
            ctx = TokenUtils.getInitialContext(editor._codeMirror, pos),
Severity: Major
Found in src/language/HTMLUtils.js - About 4 hrs to fix

    File HTMLUtils.js has 310 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: Minor
    Found in src/language/HTMLUtils.js - About 3 hrs to fix

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

          function _extractAttrVal(ctx) {
              var attrValue = ctx.token.string,
                  startChar = attrValue.charAt(0),
                  endChar = attrValue.charAt(attrValue.length - 1),
                  offset = TokenUtils.offsetInToken(ctx),
      Severity: Minor
      Found in src/language/HTMLUtils.js - About 1 hr to fix

        Function getTagAttributes has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function getTagAttributes(editor, pos) {
                var attrs       = [],
                    backwardCtx = TokenUtils.getInitialContext(editor._codeMirror, pos),
                    forwardCtx  = $.extend({}, backwardCtx);
        
        
        Severity: Minor
        Found in src/language/HTMLUtils.js - About 1 hr to fix

          Function findBlocks has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function findBlocks(editor, modeName) {
                  // Start scanning from beginning of file
                  var ctx = TokenUtils.getInitialContext(editor._codeMirror, {line: 0, ch: 0}),
                      blocks = [],
                      currentBlock = null,
          Severity: Minor
          Found in src/language/HTMLUtils.js - About 1 hr to fix

            Function _getTagInfoStartingFromAttrValue has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function _getTagInfoStartingFromAttrValue(ctx) {
                    // Assume we in the attr value
                    // and validate that by going backwards
                    var attrInfo = _extractAttrVal(ctx),
                        attrVal = attrInfo.val,
            Severity: Minor
            Found in src/language/HTMLUtils.js - About 1 hr to fix

              Function createTagInfo has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  function createTagInfo(tokenType, offset, tagName, attrName, attrValue, valueAssigned, quoteChar, hasEndQuote) {
              Severity: Major
              Found in src/language/HTMLUtils.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                                    } else if (forwardCtx.token.type === "error") {
                                        if (forwardCtx.token.string.indexOf("<") === 0 || forwardCtx.token.string.indexOf(">") === 0) {
                                            break;
                                        }
                                        // If we type the first letter of the next attribute, it comes as an error
                Severity: Major
                Found in src/language/HTMLUtils.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if (offset === 0) {
                                              TokenUtils.moveNextToken(ctx);
                                          }
                  Severity: Major
                  Found in src/language/HTMLUtils.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if (forwardCtx.token.string.indexOf("<") === 0) {
                                                break;
                                            }
                    Severity: Major
                    Found in src/language/HTMLUtils.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if (ctx.token.string === "</") {
                                                  tokenType = CLOSING_TAG;
                                                  offset -= 2;
                                              } else {
                                                  offset = 0;
                      Severity: Major
                      Found in src/language/HTMLUtils.js - About 45 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                                    if (isPriorAttr &&
                                            (!ctx.token.type ||
                                            (ctx.token.type && ctx.token.type !== "attribute" &&
                                                ctx.token.type.indexOf("error") === -1 &&
                                                ctx.token.string.indexOf("<") !== -1))) {
                        Severity: Major
                        Found in src/language/HTMLUtils.js - About 40 mins to fix

                          Avoid too many return statements within this function.
                          Open

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

                            Avoid too many return statements within this function.
                            Open

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

                              Avoid too many return statements within this function.
                              Open

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

                                Avoid too many return statements within this function.
                                Open

                                                return createTagInfo(tokenType, offset, _extractTagName(ctx));
                                Severity: Major
                                Found in src/language/HTMLUtils.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

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

                                    Avoid too many return statements within this function.
                                    Open

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

                                      Avoid too many return statements within this function.
                                      Open

                                              return createTagInfo(ATTR_NAME, offset, tagName, attrName, attrVal, true, quoteChar, hasEndQuote);
                                      Severity: Major
                                      Found in src/language/HTMLUtils.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                                return createTagInfo(ATTR_NAME, 0, tagInfo.tagName);
                                        Severity: Major
                                        Found in src/language/HTMLUtils.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

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

                                            Avoid too many return statements within this function.
                                            Open

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

                                              Avoid too many return statements within this function.
                                              Open

                                                      return tagInfo;
                                              Severity: Major
                                              Found in src/language/HTMLUtils.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 = editor._codeMirror.getTokenAt(testPos, true);
                                                Severity: Major
                                                Found in src/language/HTMLUtils.js and 1 other location - About 1 hr to fix
                                                src/language/CSSUtils.js on lines 246..247

                                                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

                                                                            (tagPrefixedRegExp.test(ctx.token.type) &&
                                                                            (ctx.token.string === ">" || ctx.token.string === "/>" ||
                                                                                ctx.token.string === "</"))) {
                                                Severity: Minor
                                                Found in src/language/HTMLUtils.js and 1 other location - About 35 mins to fix
                                                src/language/CSSUtils.js on lines 237..239

                                                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