sparklemotion/nokogiri

View on GitHub
ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java

Summary

Maintainability
F
1 wk
Test Coverage

Method nextNode has a Cognitive Complexity of 99 (exceeds 5 allowed). Consider refactoring.
Open

  protected boolean
  nextNode()
  {
    // Non-recursive one-fetch-at-a-time depth-first traversal with
    // attribute/namespace nodes and white-space stripping.
Severity: Minor
Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 1 day 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 DOM2DTM.java has 783 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: Major
Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 1 day to fix

    DOM2DTM has 38 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class DOM2DTM extends DTMDefaultBaseIterators
    {
    //    static final boolean JJK_DEBUG=false;
    //    static final boolean JJK_NEWCODE=true;
    
    
    Severity: Minor
    Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 5 hrs to fix

      Method nextNode has 112 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        protected boolean
        nextNode()
        {
          // Non-recursive one-fetch-at-a-time depth-first traversal with
          // attribute/namespace nodes and white-space stripping.
      Severity: Major
      Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 4 hrs to fix

        Method addNode has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

          protected int
          addNode(Node node, int parentIndex,
                  int previousSibling, int forceNodeType)
          {
            int nodeIndex = m_nodes.size();
        Severity: Minor
        Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.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 addNode has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          protected int
          addNode(Node node, int parentIndex,
                  int previousSibling, int forceNodeType)
          {
            int nodeIndex = m_nodes.size();
        Severity: Major
        Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 2 hrs to fix

          Method getAttributeNode has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            public int
            getAttributeNode(int nodeHandle, String namespaceURI,
                             String name)
            {
          
          
          Severity: Minor
          Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - 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

          Method getUnparsedEntityURI has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            public String
            getUnparsedEntityURI(String name)
            {
          
              String url = "";
          Severity: Minor
          Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - 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

          Method getHandleOfNode has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            public int
            getHandleOfNode(Node node)
            {
              if (null != node) {
                // Is Node actually within the same document? If not, don't search!
          Severity: Minor
          Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - 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

          Method getElementById has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            public int
            getElementById(String elementId)
            {
          
              Document doc = (m_root.getNodeType() == Node.DOCUMENT_NODE)
          Severity: Minor
          Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - 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

          Method logicalNextDOMTextNode has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            private Node
            logicalNextDOMTextNode(Node n)
            {
              Node p = n.getNextSibling();
              if (p == null) {
          Severity: Minor
          Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - 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

          Method getStringValue has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            public XMLString
            getStringValue(int nodeHandle)
            {
          
              int type = getNodeType(nodeHandle);
          Severity: Minor
          Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - 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

          Method getHandleFromNode has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            public int
            getHandleFromNode(Node node)
            {
              if (null != node) {
                int len = m_nodes.size();
          Severity: Minor
          Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - 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

          Method dispatchNodeData has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            @SuppressWarnings("fallthrough")
            protected static void
            dispatchNodeData(Node node,
                             org.xml.sax.ContentHandler ch,
                             int depth)
          Severity: Minor
          Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 1 hr to fix

            Method logicalNextDOMTextNode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private Node
              logicalNextDOMTextNode(Node n)
              {
                Node p = n.getNextSibling();
                if (p == null) {
            Severity: Minor
            Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 1 hr to fix

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

                public void
                dispatchCharactersEvents(
                  int nodeHandle, org.xml.sax.ContentHandler ch,
                  boolean normalize)
                throws org.xml.sax.SAXException
              Severity: Minor
              Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.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 getLocalName has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                public String
                getLocalName(int nodeHandle)
                {
              //        if(JJK_NEWCODE)
              //        {
              Severity: Minor
              Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.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 dispatchNodeData has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                @SuppressWarnings("fallthrough")
                protected static void
                dispatchNodeData(Node node,
                                 org.xml.sax.ContentHandler ch,
                                 int depth)
              Severity: Minor
              Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.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 (!m_processedFirstElement
                              && "xmlns:xml".equals(attrs.item(i).getNodeName())) {
                            m_processedFirstElement = true;
                          }
              Severity: Major
              Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 45 mins to fix

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

                  public String
                  getNodeValue(int nodeHandle)
                  {
                    // The _type(nodeHandle) call was taking the lion's share of our
                    // time, and was wrong anyway since it wasn't converting handle to
                Severity: Minor
                Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.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 (node == elem) {
                              elemHandle = getHandleFromNode(elem);
                              break;
                            }
                Severity: Major
                Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 45 mins to fix

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

                    public String
                    getDocumentTypeDeclarationSystemIdentifier()
                    {
                  
                      Document doc;
                  Severity: Major
                  Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java and 1 other location - About 1 hr to fix
                  ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java on lines 1263..1284

                  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

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

                    public String
                    getDocumentTypeDeclarationPublicIdentifier()
                    {
                  
                      Document doc;
                  Severity: Major
                  Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java and 1 other location - About 1 hr to fix
                  ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java on lines 1232..1253

                  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