adobe/brackets

View on GitHub
src/language/HTMLSimpleDOM.js

Summary

Maintainability
F
1 wk
Test Coverage

Function build has 148 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    Builder.prototype.build = function (strict, markCache) {
        var self = this;
        var token, lastClosedTag, lastTextNode;
        var stack = this.stack;
        var attributeName = null;
Severity: Major
Found in src/language/HTMLSimpleDOM.js - About 5 hrs to fix

    File HTMLSimpleDOM.js has 353 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * Copyright (c) 2013 - 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/HTMLSimpleDOM.js - About 4 hrs to fix

      Avoid deeply nested control flow statements.
      Open

                          if (token.type === "selfclosingtag" && stack.length && stack[stack.length - 1] === this.currentTag) {
                              // This must have been a self-closing tag that we didn't identify as a void element
                              // (e.g. an SVG tag). Pop it off the stack as if we had encountered its close tag.
                              closeTag(token.end, token.endPos);
                          } else {
      Severity: Major
      Found in src/language/HTMLSimpleDOM.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        if (!voidElements.hasOwnProperty(closeTagName)) {
                            // Find the topmost item on the stack that matches. If we can't find one, assume
                            // this is just a dangling closing tag and ignore it.
                            var i;
                            for (i = stack.length - 1; i >= 0; i--) {
        Severity: Major
        Found in src/language/HTMLSimpleDOM.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      } else if (token.type === "attribname") {
                          attributeName = token.contents.toLowerCase();
                          // Set the value to the empty string in case this is an empty attribute. If it's not,
                          // it will get overwritten by the attribvalue later.
                          this.currentTag.attributes[attributeName] = "";
          Severity: Major
          Found in src/language/HTMLSimpleDOM.js - About 45 mins to fix

            Avoid too many return statements within this function.
            Open

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

              Avoid too many return statements within this function.
              Open

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

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

                            } else if (token.type === "opentagname") {
                                var newTagName = token.contents.toLowerCase(),
                                    newTag;
                
                                if (openImpliesClose.hasOwnProperty(newTagName)) {
                Severity: Major
                Found in src/language/HTMLSimpleDOM.js and 1 other location - About 2 days to fix
                src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js on lines 304..443

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

                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

                    SimpleNode.prototype = {
                
                        /**
                         * Updates signatures used to optimize the number of comparisons done during
                         * diffing. This is important to call if you change:
                Severity: Major
                Found in src/language/HTMLSimpleDOM.js and 1 other location - About 2 days to fix
                src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js on lines 128..187

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

                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

                            } else if (token.type === "closetag") {
                                // If this is a self-closing element, ignore the close tag.
                                var closeTagName = token.contents.toLowerCase();
                                if (!voidElements.hasOwnProperty(closeTagName)) {
                                    // Find the topmost item on the stack that matches. If we can't find one, assume
                Severity: Major
                Found in src/language/HTMLSimpleDOM.js and 1 other location - About 1 day to fix
                src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js on lines 370..443

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

                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 _dumpDOM(root) {
                        var result = "",
                            indent = "";
                
                        function walk(node) {
                Severity: Major
                Found in src/language/HTMLSimpleDOM.js and 1 other location - About 1 day to fix
                src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js on lines 522..541

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

                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

                    Builder.prototype._logError = function (token) {
                        var error       = { token: token },
                            startPos    = token ? (token.startPos || token.endPos) : this.startOffsetPos,
                            endPos      = token ? token.endPos : this.startOffsetPos;
                
                
                Severity: Major
                Found in src/language/HTMLSimpleDOM.js and 1 other location - About 6 hrs to fix
                src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js on lines 245..258

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

                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

                    var voidElements = {
                        area: true,
                        base: true,
                        basefont: true,
                        br: true,
                Severity: Major
                Found in src/language/HTMLSimpleDOM.js and 1 other location - About 3 hrs to fix
                src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js on lines 91..112

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

                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 Builder(text, startOffset, startOffsetPos) {
                        this.stack = [];
                        this.text = text;
                        this.t = new Tokenizer(text);
                        this.currentTag = null;
                Severity: Major
                Found in src/language/HTMLSimpleDOM.js and 1 other location - About 3 hrs to fix
                src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js on lines 236..243

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

                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

                    function getTextNodeID(textNode) {
                        var childIndex = textNode.parent.children.indexOf(textNode);
                        if (childIndex === 0) {
                            return textNode.parent.tagID + ".0";
                        }
                Severity: Major
                Found in src/language/HTMLSimpleDOM.js and 1 other location - About 2 hrs to fix
                src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js on lines 198..204

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

                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

                        function closeTag(endIndex, endPos) {
                            lastClosedTag = stack[stack.length - 1];
                            stack.pop();
                            lastClosedTag.update();
                
                
                Severity: Major
                Found in src/language/HTMLSimpleDOM.js and 1 other location - About 2 hrs to fix
                src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js on lines 282..289

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

                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 _addPos(pos1, pos2) {
                        return {line: pos1.line + pos2.line, ch: (pos2.line === 0 ? pos1.ch + pos2.ch : pos2.ch)};
                    }
                Severity: Major
                Found in src/language/HTMLSimpleDOM.js and 1 other location - About 1 hr to fix
                src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js on lines 211..213

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

                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 (i >= 0) {
                                        do {
                                            // For all tags we're implicitly closing (before we hit the matching tag), we want the
                                            // implied end to be the beginning of the close tag (which is two characters, "</", before
                                            // the start of the tagname). For the actual tag we're explicitly closing, we want the
                Severity: Minor
                Found in src/language/HTMLSimpleDOM.js and 1 other location - About 45 mins to fix
                src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js on lines 389..411

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

                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

                                    for (i = stack.length - 1; i >= 0; i--) {
                                        if (stack[i].tag === closeTagName) {
                                            break;
                                        }
                                    }
                Severity: Minor
                Found in src/language/HTMLSimpleDOM.js and 1 other location - About 40 mins to fix
                src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js on lines 377..381

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

                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 (token.type === "error") {
                                PerfUtils.finalizeMeasurement(timerBuildFull);  // discard
                                PerfUtils.addMeasurement(timerBuildPart);       // use
                                this._logError(token);
                                return null;
                Severity: Minor
                Found in src/language/HTMLSimpleDOM.js and 1 other location - About 40 mins to fix
                src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js on lines 299..443

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

                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