sparklemotion/nokogiri

View on GitHub

Showing 533 of 533 total issues

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

  @Override
  protected Iterator<Attr>
  handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
  throws CanonicalizationException
  {
Severity: Major
Found in ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java and 1 other location - About 4 hrs to fix
ext/java/nokogiri/internals/c14n/Canonicalizer11.java on lines 225..278

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

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

File XmlSchema.java has 355 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package nokogiri;

import static nokogiri.internals.NokogiriHelpers.adjustSystemIdIfNecessary;
import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;

Severity: Minor
Found in ext/java/nokogiri/XmlSchema.java - About 4 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 lookupNamespaceURI has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

        public String
        lookupNamespaceURI(String specifiedPrefix)
        {
          short type = this.getNodeType();
          switch (type) {

      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 getDTMHandleFromNode has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

        @Override
        public /* synchronized */ int
        getDTMHandleFromNode(org.w3c.dom.Node node)
        {
          //if (node == null) // "node must be non-null for getDTMHandleFromNode!");
      Severity: Minor
      Found in ext/java/nokogiri/internals/XalanDTMManagerPatch.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

      Method removeDotSegments has 101 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private static String
        removeDotSegments(String path)
        {
      
          // 1. The input buffer is initialized with the now-appended path
      Severity: Major
      Found in ext/java/nokogiri/internals/c14n/Canonicalizer11.java - About 4 hrs to fix

        Method visit_function has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

              def visit_function(node)
                msg = :"visit_function_#{node.value.first.gsub(/[(]/, "")}"
                return send(msg, node) if respond_to?(msg)
        
                case node.value.first
        Severity: Minor
        Found in lib/nokogiri/css/xpath_visitor.rb - 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

        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

          Class NodeSet has 31 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class NodeSet
                include Nokogiri::XML::Searchable
                include Enumerable
          
                # The Document this NodeSet is associated with
          Severity: Minor
          Found in lib/nokogiri/xml/node_set.rb - About 3 hrs to fix

            Method process_recipe has 92 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def process_recipe(name, version, static_p, cross_p, cacheable_p = true)
              require "rubygems"
              gem("mini_portile2", REQUIRED_MINI_PORTILE_VERSION) # gemspec is not respected at install time
              require "mini_portile2"
              message("Using mini_portile version #{MiniPortile::VERSION}\n")
            Severity: Major
            Found in ext/nokogiri/extconf.rb - About 3 hrs to fix

              XmlNodeSet has 30 methods (exceeds 20 allowed). Consider refactoring.
              Open

              @JRubyClass(name = "Nokogiri::XML::NodeSet")
              public class XmlNodeSet extends RubyObject implements NodeList
              {
                private static final long serialVersionUID = 1L;
              
              
              Severity: Minor
              Found in ext/java/nokogiri/XmlNodeSet.java - About 3 hrs to fix

                Method canonicalizeSubTree has 91 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  protected final void
                  canonicalizeSubTree(
                    Node currentNode, NameSpaceSymbTable ns, Node endnode, int documentLevel, CanonicalFilter filter
                  ) throws CanonicalizationException, IOException
                  {
                Severity: Major
                Found in ext/java/nokogiri/internals/c14n/CanonicalizerBase.java - About 3 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

                  ReaderNode has 29 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  public abstract class ReaderNode
                  {
                  
                    final Ruby ruby;
                    public ReaderAttributeList attributeList;
                  Severity: Minor
                  Found in ext/java/nokogiri/internals/ReaderNode.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 handleAttributesSubtree has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                    Open

                      @Override
                      protected Iterator<Attr>
                      handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
                      throws CanonicalizationException
                      {
                    Severity: Minor
                    Found in ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.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 parse has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def parse(string_or_io, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML)
                              options = Nokogiri::XML::ParseOptions.new(options) if Integer === options
                              yield options if block_given?
                    
                              url ||= string_or_io.respond_to?(:path) ? string_or_io.path : nil
                    Severity: Minor
                    Found in lib/nokogiri/html4/document.rb - 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 startElement has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                    Open

                      @Override
                      public void
                      startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException
                      {
                        final Ruby runtime = this.runtime;
                    Severity: Minor
                    Found in ext/java/nokogiri/internals/NokogiriHandler.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

                    File NameSpaceSymbTable.java has 302 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/NameSpaceSymbTable.java - About 3 hrs to fix

                      NokogiriHandler has 27 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      public class NokogiriHandler extends DefaultHandler2 implements XmlDeclHandler
                      {
                      
                        StringBuilder charactersBuilder;
                        private final Ruby runtime;
                      Severity: Minor
                      Found in ext/java/nokogiri/internals/NokogiriHandler.java - About 3 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language