sparklemotion/nokogiri

View on GitHub
ext/java/nokogiri/internals/c14n/XMLUtils.java

Summary

Maintainability
F
3 days
Test Coverage

Method circumventBug2650internal has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

  @SuppressWarnings("fallthrough")
  private static void
  circumventBug2650internal(Node node)
  {
    Node parent = null;
Severity: Minor
Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 6 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

Method protectAgainstWrappingAttack has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

  public static boolean
  protectAgainstWrappingAttack(Node startNode, String value)
  {
    Node startParent = startNode.getParentNode();
    Node processedNode;
Severity: Minor
Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 4 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

File XMLUtils.java has 327 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
Severity: Minor
Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 3 hrs to fix

    Method protectAgainstWrappingAttack has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      public static boolean
      protectAgainstWrappingAttack(
        Node startNode, Element knownElement, String value
      )
      {
    Severity: Minor
    Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 3 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

    Method circumventBug2650internal has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      @SuppressWarnings("fallthrough")
      private static void
      circumventBug2650internal(Node node)
      {
        Node parent = null;
    Severity: Minor
    Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 2 hrs to fix

      Method protectAgainstWrappingAttack has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public static boolean
        protectAgainstWrappingAttack(Node startNode, String value)
        {
          Node startParent = startNode.getParentNode();
          Node processedNode;
      Severity: Minor
      Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 1 hr to fix

        Method protectAgainstWrappingAttack has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public static boolean
          protectAgainstWrappingAttack(
            Node startNode, Element knownElement, String value
          )
          {
        Severity: Minor
        Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 1 hr to fix

          Method getOwnerDocument has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            public static Document
            getOwnerDocument(Set<Node> xpathNodeSet)
            {
              NullPointerException npe = null;
              for (Node node : xpathNodeSet) {
          Severity: Minor
          Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 55 mins 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

          Method isDescendantOrSelf has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            public static boolean
            isDescendantOrSelf(Node ctx, Node descendantOrSelf)
            {
              if (ctx == descendantOrSelf) {
                return true;
          Severity: Minor
          Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 55 mins 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

          Avoid deeply nested control flow statements.
          Open

                      if (attr.isId() && id.equals(attr.getValue()) && se != knownElement) {
                        //log.debug("Multiple elements with the same 'Id' attribute value!");
                        return false;
                      }
          Severity: Major
          Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            if (!namespaceNs.equals(currentAttr.getNamespaceURI())) {
                              continue;
                            }
            Severity: Major
            Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          if (attr.isId() && id.equals(attr.getValue())) {
                            if (foundElement == null) {
                              // Continue searching to find duplicates
                              foundElement = attr.getOwnerElement();
                            } else {
              Severity: Major
              Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 45 mins to fix

                Method getStrFromNode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  public static String
                  getStrFromNode(Node xpathnode)
                  {
                    if (xpathnode.getNodeType() == Node.TEXT_NODE) {
                      // we iterate over all siblings of the context node because eventually,
                Severity: Minor
                Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 45 mins 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

                Avoid deeply nested control flow statements.
                Open

                                if (childElement.hasAttributeNS(namespaceNs,
                                                                currentAttr.getLocalName())) {
                                  continue;
                                }
                Severity: Major
                Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 45 mins to fix

                  Method selectNode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    public static Element
                    selectNode(Node sibling, String uri, String nodeName, int number)
                    {
                      while (sibling != null) {
                        if (sibling.getNamespaceURI() != null && sibling.getNamespaceURI().equals(uri)
                  Severity: Minor
                  Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 35 mins 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

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

                        while (startNode == null) {
                          processedNode = processedNode.getParentNode();
                          if (processedNode == startParent) {
                            return true;
                          }
                  Severity: Minor
                  Found in ext/java/nokogiri/internals/c14n/XMLUtils.java and 1 other location - About 35 mins to fix
                  ext/java/nokogiri/internals/c14n/XMLUtils.java on lines 528..535

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

                  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

                        while (startNode == null) {
                          processedNode = processedNode.getParentNode();
                          if (processedNode == startParent) {
                            return true;
                          }
                  Severity: Minor
                  Found in ext/java/nokogiri/internals/c14n/XMLUtils.java and 1 other location - About 35 mins to fix
                  ext/java/nokogiri/internals/c14n/XMLUtils.java on lines 471..478

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

                  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 3 locations. Consider refactoring.
                  Open

                        if (parent.getNodeType() == Node.ATTRIBUTE_NODE) {
                          parent = ((Attr) parent).getOwnerElement();
                        } else {
                          parent = parent.getParentNode();
                        }
                  Severity: Minor
                  Found in ext/java/nokogiri/internals/c14n/XMLUtils.java and 2 other locations - About 30 mins to fix
                  ext/java/nokogiri/XmlNode.java on lines 608..612
                  ext/java/nokogiri/XmlNode.java on lines 1206..1210

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

                  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