neyric/wireit

View on GitHub
sandbox/grouping/examples/sawire/xml/dom.js

Summary

Maintainability
F
5 days
Test Coverage

File dom.js has 414 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright 2005 Google Inc.
// All Rights Reserved
//
// Author: Steffen Meschkat <mesch@google.com>
//
Severity: Minor
Found in sandbox/grouping/examples/sawire/xml/dom.js - About 5 hrs to fix

    Function xmlParse has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

    function xmlParse(xml) {
      var regex_empty = /\/$/;
    
      var regex_tagname;
      var regex_attribute;
    Severity: Minor
    Found in sandbox/grouping/examples/sawire/xml/dom.js - About 5 hrs 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 xmlParse has 98 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function xmlParse(xml) {
      var regex_empty = /\/$/;
    
      var regex_tagname;
      var regex_attribute;
    Severity: Major
    Found in sandbox/grouping/examples/sawire/xml/dom.js - About 3 hrs to fix

      Function replaceChild has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      XNode.prototype.replaceChild = function(newNode, oldNode) {
        if (oldNode == newNode) {
          return;
        }
      
      
      Severity: Minor
      Found in sandbox/grouping/examples/sawire/xml/dom.js - About 2 hrs 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 removeChild has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      XNode.prototype.removeChild = function(node) {
        var newChildren = [];
        for (var i = 0; i < this.childNodes.length; ++i) {
          var c = this.childNodes[i];
          if (c != node) {
      Severity: Minor
      Found in sandbox/grouping/examples/sawire/xml/dom.js - About 2 hrs 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 xmlResolveEntities has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function xmlResolveEntities(s) {
      
        var parts = stringSplit(s, '&');
      
        var ret = parts[0];
      Severity: Minor
      Found in sandbox/grouping/examples/sawire/xml/dom.js - About 1 hr to fix

        Function domTraverseElements has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        function domTraverseElements(node, opt_pre, opt_post) {
          var ret;
          if (opt_pre) {
            ret = opt_pre.call(null, node);
            if (typeof ret == 'boolean' && !ret) {
        Severity: Minor
        Found in sandbox/grouping/examples/sawire/xml/dom.js - About 1 hr 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 insertBefore has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        XNode.prototype.insertBefore = function(newNode, oldNode) {
          if (oldNode == newNode) {
            return;
          }
        
        
        Severity: Minor
        Found in sandbox/grouping/examples/sawire/xml/dom.js - About 1 hr 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 replaceChild has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        XNode.prototype.replaceChild = function(newNode, oldNode) {
          if (oldNode == newNode) {
            return;
          }
        
        
        Severity: Minor
        Found in sandbox/grouping/examples/sawire/xml/dom.js - About 1 hr to fix

          Function insertBefore has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          XNode.prototype.insertBefore = function(newNode, oldNode) {
            if (oldNode == newNode) {
              return;
            }
          
          
          Severity: Minor
          Found in sandbox/grouping/examples/sawire/xml/dom.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                  if (end != -1) {
                    var data = x[i].substring(start, end);
                    var node = domCreateComment(xmldoc, data);
                    domAppendChild(parent, node);
                  } else {
            Severity: Major
            Found in sandbox/grouping/examples/sawire/xml/dom.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                  } else if (tag.charAt(0) == '/') {
                    stack.pop();
                    parent = stack[stack.length-1];
              
                  } else if (tag.charAt(0) == '?') {
              Severity: Major
              Found in sandbox/grouping/examples/sawire/xml/dom.js - About 45 mins to fix

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

                    } else if (tag.indexOf('!--') == 0) {
                      var start = '!--'.length;
                      var end = x[i].indexOf('-->');
                      if (end != -1) {
                        var data = x[i].substring(start, end);
                Severity: Major
                Found in sandbox/grouping/examples/sawire/xml/dom.js and 1 other location - About 6 hrs to fix
                sandbox/grouping/examples/sawire/xml/dom.js on lines 144..202

                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

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

                    } else if (tag.indexOf('![CDATA[') == 0) {
                      var start = '![CDATA['.length;
                      var end = x[i].indexOf(']]>');
                      if (end != -1) {
                        var data = x[i].substring(start, end);
                Severity: Major
                Found in sandbox/grouping/examples/sawire/xml/dom.js and 1 other location - About 6 hrs to fix
                sandbox/grouping/examples/sawire/xml/dom.js on lines 161..202

                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

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

                  for (var a = 0; a < node.attributes.length; ++a) {
                    XNode.recycle(node.attributes[a]);
                  }
                Severity: Minor
                Found in sandbox/grouping/examples/sawire/xml/dom.js and 1 other location - About 45 mins to fix
                sandbox/grouping/examples/sawire/xml/dom.js on lines 306..308

                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

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

                  for (var c = 0; c < node.childNodes.length; ++c) {
                    XNode.recycle(node.childNodes[c]);
                  }
                Severity: Minor
                Found in sandbox/grouping/examples/sawire/xml/dom.js and 1 other location - About 45 mins to fix
                sandbox/grouping/examples/sawire/xml/dom.js on lines 303..305

                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

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

                  if (opt_post) {
                    ret = opt_post.call(null, node);
                    if (typeof ret == 'boolean' && !ret) {
                      return false;
                    }
                Severity: Minor
                Found in sandbox/grouping/examples/sawire/xml/dom.js and 1 other location - About 30 mins to fix
                sandbox/grouping/examples/sawire/xml/dom.js on lines 236..241

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

                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 (opt_pre) {
                    ret = opt_pre.call(null, node);
                    if (typeof ret == 'boolean' && !ret) {
                      return false;
                    }
                Severity: Minor
                Found in sandbox/grouping/examples/sawire/xml/dom.js and 1 other location - About 30 mins to fix
                sandbox/grouping/examples/sawire/xml/dom.js on lines 252..257

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

                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