sparklemotion/nokogiri

View on GitHub

Showing 533 of 533 total issues

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

    outer:
    for (int i = 0; i < other.length; i++) {
      IRubyObject n = other[i];

      for (int j = 0; j < curr.length; j++) {
Severity: Major
Found in ext/java/nokogiri/XmlNodeSet.java and 1 other location - About 1 hr to fix
ext/java/nokogiri/XmlNodeSet.java on lines 261..272

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

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

Method handleParent has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  @Override
  protected void
  handleParent(Element e, NameSpaceSymbTable ns)
  {
    if (!e.hasAttributes() && e.getNamespaceURI() == null) {
Severity: Minor
Found in ext/java/nokogiri/internals/c14n/Canonicalizer11.java - About 1 hr to fix

    Method handleParent has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      @Override
      protected void
      handleParent(Element e, NameSpaceSymbTable ns)
      {
        if (!e.hasAttributes() && e.getNamespaceURI() == null) {
    Severity: Minor
    Found in ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java - About 1 hr to fix

      Method serializeAttrTextContent has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private static CharSequence
        serializeAttrTextContent(String str, boolean htmlDoc)
        {
          if (str == null || str.length() == 0) { return ""; }
      
      
      Severity: Minor
      Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 1 hr to fix

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

          private Schema
          getSchema(Source source, ThreadContext context)
          {
            InputStream is;
            VerifierFactory factory = new com.thaiopensource.relaxng.jarv.VerifierFactoryImpl();
        Severity: Minor
        Found in ext/java/nokogiri/XmlRelaxng.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 setUrl has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          public static void
          setUrl(ThreadContext context, InputSource source, IRubyObject url)
          {
            String path = rubyStringToString(url);
            // Dir.chdir might be called at some point before this.
        Severity: Minor
        Found in ext/java/nokogiri/internals/ParserContext.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 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 extractDecls has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          protected void
          extractDecls(ThreadContext context)
          {
            Ruby runtime = context.runtime;
        
        
        Severity: Minor
        Found in ext/java/nokogiri/XmlDtd.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

        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

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

              def ancestors(selector = nil)
                return NodeSet.new(document) unless respond_to?(:parent)
                return NodeSet.new(document) unless parent
        
                parents = [parent]
        Severity: Minor
        Found in lib/nokogiri/xml/node.rb - 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

        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

        Method extractDecls has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          protected void
          extractDecls(ThreadContext context)
          {
            Ruby runtime = context.runtime;
        
        
        Severity: Minor
        Found in ext/java/nokogiri/XmlDtd.java - About 1 hr to fix

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

              if source_dir
                recipe.source_directory = source_dir
              else
                minor_version = Gem::Version.new(recipe.version).segments.take(2).join(".")
                recipe.files = [{
          Severity: Major
          Found in ext/nokogiri/extconf.rb and 1 other location - About 1 hr to fix
          ext/nokogiri/extconf.rb on lines 945..953

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

              if source_dir
                recipe.source_directory = source_dir
              else
                minor_version = Gem::Version.new(recipe.version).segments.take(2).join(".")
                recipe.files = [{
          Severity: Major
          Found in ext/nokogiri/extconf.rb and 1 other location - About 1 hr to fix
          ext/nokogiri/extconf.rb on lines 889..897

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

          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

          Method writeCharToUtf8 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public static void
            writeCharToUtf8(final char c, final OutputStream out) throws IOException
            {
              if (c < 0x80) {
                out.write(c);
          Severity: Minor
          Found in ext/java/nokogiri/internals/c14n/UtfHelpper.java - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language