sparklemotion/nokogiri

View on GitHub
ext/java/nokogiri/XmlNode.java

Summary

Maintainability
F
1 wk
Test Coverage

File XmlNode.java has 1399 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package nokogiri;

import static java.lang.Math.max;
import static nokogiri.internals.NokogiriHelpers.*;

Severity: Major
Found in ext/java/nokogiri/XmlNode.java - About 3 days to fix

    XmlNode has 104 methods (exceeds 20 allowed). Consider refactoring.
    Open

    @JRubyClass(name = "Nokogiri::XML::Node")
    public class XmlNode extends RubyObject
    {
      private static final long serialVersionUID = 1L;
    
    
    Severity: Major
    Found in ext/java/nokogiri/XmlNode.java - About 2 days to fix

      Method relink_namespace has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

        public void
        relink_namespace(ThreadContext context)
        {
          if (!(node instanceof Element)) {
            return;
      Severity: Minor
      Found in ext/java/nokogiri/XmlNode.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 count has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        private boolean
        count(Node node, int[] counter)
        {
          if (node == this.node) {
            return true;
      Severity: Minor
      Found in ext/java/nokogiri/XmlNode.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 relink_namespace has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public void
        relink_namespace(ThreadContext context)
        {
          if (!(node instanceof Element)) {
            return;
      Severity: Major
      Found in ext/java/nokogiri/XmlNode.java - About 2 hrs to fix

        Method node_type has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          @JRubyMethod(name = {"node_type", "type"})
          public IRubyObject
          node_type(ThreadContext context)
          {
            String type;
        Severity: Major
        Found in ext/java/nokogiri/XmlNode.java - About 2 hrs to fix

          Method adoptAs has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            protected IRubyObject
            adoptAs(ThreadContext context, AdoptScheme scheme, IRubyObject other_)
            {
              final XmlNode other = asXmlNode(context, other_);
              // this.doc might be null since this node can be empty node.
          Severity: Major
          Found in ext/java/nokogiri/XmlNode.java - About 2 hrs to fix

            Method adoptAs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              protected IRubyObject
              adoptAs(ThreadContext context, AdoptScheme scheme, IRubyObject other_)
              {
                final XmlNode other = asXmlNode(context, other_);
                // this.doc might be null since this node can be empty node.
            Severity: Minor
            Found in ext/java/nokogiri/XmlNode.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 in_context has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              @JRubyMethod(required = 2, visibility = Visibility.PRIVATE)
              public IRubyObject
              in_context(ThreadContext context, IRubyObject str, IRubyObject options)
              {
                RubyClass klass;
            Severity: Minor
            Found in ext/java/nokogiri/XmlNode.java - About 1 hr to fix

              Method add_namespace_definition has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                @JRubyMethod(name = {"add_namespace_definition", "add_namespace"})
                public IRubyObject
                add_namespace_definition(ThreadContext context, IRubyObject prefix, IRubyObject href)
                {
                  String hrefStr, prefixStr = prefix.isNil() ? null : prefix.convertToString().decodeString();
              Severity: Minor
              Found in ext/java/nokogiri/XmlNode.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 namespace_scopes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                @JRubyMethod
                public RubyArray<?>
                namespace_scopes(ThreadContext context)
                {
                  final XmlDocument doc = document(context.runtime);
              Severity: Minor
              Found in ext/java/nokogiri/XmlNode.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 in_context has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                @JRubyMethod(required = 2, visibility = Visibility.PRIVATE)
                public IRubyObject
                in_context(ThreadContext context, IRubyObject str, IRubyObject options)
                {
                  RubyClass klass;
              Severity: Minor
              Found in ext/java/nokogiri/XmlNode.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 key_p has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                @JRubyMethod(name = {"key?", "has_attribute?"})
                public IRubyObject
                key_p(ThreadContext context, IRubyObject rbkey)
                {
                  if (node instanceof Element) {
              Severity: Minor
              Found in ext/java/nokogiri/XmlNode.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 add_namespace_definition has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                @JRubyMethod(name = {"add_namespace_definition", "add_namespace"})
                public IRubyObject
                add_namespace_definition(ThreadContext context, IRubyObject prefix, IRubyObject href)
                {
                  String hrefStr, prefixStr = prefix.isNil() ? null : prefix.convertToString().decodeString();
              Severity: Minor
              Found in ext/java/nokogiri/XmlNode.java - About 1 hr to fix

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

                  @JRubyMethod(required = 4, visibility = Visibility.PRIVATE)
                  public IRubyObject
                  native_write_to(ThreadContext context, IRubyObject[] args)
                  {
                
                
                Severity: Minor
                Found in ext/java/nokogiri/XmlNode.java - About 1 hr to fix

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

                    @JRubyMethod(name = {"node_type", "type"})
                    public IRubyObject
                    node_type(ThreadContext context)
                    {
                      String type;
                  Severity: Minor
                  Found in ext/java/nokogiri/XmlNode.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 findNamespaceHref has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private String
                    findNamespaceHref(ThreadContext context, String prefix)
                    {
                      XmlNode currentNode = this;
                      final XmlDocument doc = document(context.runtime);
                  Severity: Minor
                  Found in ext/java/nokogiri/XmlNode.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

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

                    protected static void
                    coalesceTextNodes(ThreadContext context,
                                      IRubyObject anchorNode,
                                      AdoptScheme scheme)
                    {
                  Severity: Minor
                  Found in ext/java/nokogiri/XmlNode.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

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

                    public CharSequence
                    getContentImpl()
                    {
                      if (!node.hasChildNodes() && node.getNodeValue() == null &&
                          (node.getNodeType() == Node.TEXT_NODE || node.getNodeType() == Node.CDATA_SECTION_NODE)) {
                  Severity: Minor
                  Found in ext/java/nokogiri/XmlNode.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

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

                    private void
                    setAttribute(ThreadContext context, String key, String val)
                    {
                      Element element = (Element) node;
                  
                  
                  Severity: Minor
                  Found in ext/java/nokogiri/XmlNode.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

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

                    private Node[]
                    adoptAsChild(final Node parent, Node otherNode)
                    {
                      /*
                       * This is a bit of a hack.  C-Nokogiri allows adding a bare text node as the root element.
                  Severity: Minor
                  Found in ext/java/nokogiri/XmlNode.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

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

                    private static StringBuilder
                    getTextContentRecursively(StringBuilder buffer, Node currentNode)
                    {
                      CharSequence textContent = currentNode.getNodeValue();
                      if (textContent != null && NokogiriHelpers.shouldDecode(currentNode)) {
                  Severity: Minor
                  Found in ext/java/nokogiri/XmlNode.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

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

                    private static List<Node>
                    getElements(Node node, final boolean firstOnly)
                    {
                      NodeList children = node.getChildNodes();
                      if (children.getLength() == 0) {
                  Severity: Minor
                  Found in ext/java/nokogiri/XmlNode.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

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

                    void
                    acceptChildren(ThreadContext context, IRubyObject[] nodes, SaveContextVisitor visitor)
                    {
                      if (nodes.length > 0) {
                        for (int i = 0; i < nodes.length; i++) {
                  Severity: Minor
                  Found in ext/java/nokogiri/XmlNode.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

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

                    @JRubyMethod(visibility = Visibility.PRIVATE)
                    public IRubyObject
                    compare(ThreadContext context, IRubyObject other)
                    {
                      if (!(other instanceof XmlNode)) {
                  Severity: Minor
                  Found in ext/java/nokogiri/XmlNode.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

                  Avoid too many return statements within this method.
                  Open

                          return context.runtime.newFixnum(-1);
                  Severity: Major
                  Found in ext/java/nokogiri/XmlNode.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return context.runtime.newFixnum(-2);
                    Severity: Major
                    Found in ext/java/nokogiri/XmlNode.java - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                            return context.runtime.newFixnum(-2);
                      Severity: Major
                      Found in ext/java/nokogiri/XmlNode.java - About 30 mins to fix

                        Method findPreviousElement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                          private Node
                          findPreviousElement(Node n)
                          {
                            Node previous = n.getPreviousSibling() == null ? n.getParentNode() : n.getPreviousSibling();
                            if (previous == null || previous.getNodeType() == Node.DOCUMENT_NODE) { return null; }
                        Severity: Minor
                        Found in ext/java/nokogiri/XmlNode.java - About 25 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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                          @JRubyMethod(visibility = Visibility.PRIVATE)
                          public IRubyObject
                          get(ThreadContext context, IRubyObject rbkey)
                          {
                            if (node instanceof Element) {
                        Severity: Minor
                        Found in ext/java/nokogiri/XmlNode.java - About 25 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

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

                          @JRubyMethod
                          public IRubyObject
                          create_external_subset(ThreadContext context,
                                                 IRubyObject name,
                                                 IRubyObject external_id,
                        Severity: Major
                        Found in ext/java/nokogiri/XmlNode.java and 1 other location - About 1 hr to fix
                        ext/java/nokogiri/XmlNode.java on lines 1045..1067

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

                        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

                          @JRubyMethod
                          public IRubyObject
                          create_internal_subset(ThreadContext context,
                                                 IRubyObject name,
                                                 IRubyObject external_id,
                        Severity: Major
                        Found in ext/java/nokogiri/XmlNode.java and 1 other location - About 1 hr to fix
                        ext/java/nokogiri/XmlNode.java on lines 1085..1104

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

                        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

                          @JRubyMethod
                          public IRubyObject
                          next_element(ThreadContext context)
                          {
                            Node nextNode = node.getNextSibling();
                        Severity: Major
                        Found in ext/java/nokogiri/XmlNode.java and 1 other location - About 1 hr to fix
                        ext/java/nokogiri/XmlNode.java on lines 1644..1656

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

                        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

                          @JRubyMethod
                          public IRubyObject
                          previous_element(ThreadContext context)
                          {
                            Node prevNode = node.getPreviousSibling();
                        Severity: Major
                        Found in ext/java/nokogiri/XmlNode.java and 1 other location - About 1 hr to fix
                        ext/java/nokogiri/XmlNode.java on lines 1630..1642

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

                        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

                          @JRubyMethod
                          public IRubyObject
                          internal_subset(ThreadContext context)
                          {
                            Document document = getOwnerDocument();
                        Severity: Minor
                        Found in ext/java/nokogiri/XmlNode.java and 1 other location - About 50 mins to fix
                        ext/java/nokogiri/XmlNode.java on lines 1069..1083

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

                        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

                          @JRubyMethod
                          public IRubyObject
                          external_subset(ThreadContext context)
                          {
                            Document document = getOwnerDocument();
                        Severity: Minor
                        Found in ext/java/nokogiri/XmlNode.java and 1 other location - About 50 mins to fix
                        ext/java/nokogiri/XmlNode.java on lines 1029..1043

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

                        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 (shouldMergeN && n != null && n.getNodeType() == Node.TEXT_NODE) {
                              xa.setContent(a.getNodeValue() + n.getNodeValue());
                              parent.removeChild(n);
                              xn.assimilateXmlNode(context, xa);
                            }
                        Severity: Minor
                        Found in ext/java/nokogiri/XmlNode.java and 1 other location - About 50 mins to fix
                        ext/java/nokogiri/XmlNode.java on lines 169..173

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

                        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 (shouldMergeP && p != null && p.getNodeType() == Node.TEXT_NODE) {
                              xp.setContent(p.getNodeValue() + a.getNodeValue());
                              parent.removeChild(a);
                              xa.assimilateXmlNode(context, xp);
                            }
                        Severity: Minor
                        Found in ext/java/nokogiri/XmlNode.java and 1 other location - About 50 mins to fix
                        ext/java/nokogiri/XmlNode.java on lines 164..168

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

                        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 (int i = 0; i < nodes.length; i++) {
                              if (nodes[i] instanceof XmlNode) {
                                ((XmlNode) nodes[i]).relink_namespace(context);
                              }
                            }
                        Severity: Minor
                        Found in ext/java/nokogiri/XmlNode.java and 1 other location - About 40 mins to fix
                        ext/java/nokogiri/XmlNodeSet.java on lines 432..436

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

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

                        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

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

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

                        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