sparklemotion/nokogiri

View on GitHub

Showing 533 of 533 total issues

Method nkf has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  private static CharSequence
  nkf(ThreadContext context, Charset encoding, CharSequence str)
  {
    final Ruby runtime = context.getRuntime();
    final ByteList opt;
Severity: Minor
Found in ext/java/nokogiri/internals/NokogiriHelpers.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 meta_encoding= has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def meta_encoding=(encoding)
        if (meta = meta_content_type)
          meta["content"] = format("text/html; charset=%s", encoding)
          encoding
        elsif (meta = at_xpath("//meta[@charset]"))
Severity: Minor
Found in lib/nokogiri/html4/document.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

Method write_to has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def write_to(io, *options)
        options = options.first.is_a?(Hash) ? options.shift : {}
        encoding = options[:encoding] || options[0] || document.encoding
        if Nokogiri.jruby?
          save_options = options[:save_with] || options[1]
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

Method related_class has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def related_class(class_name)
      klass = nil
      inspecting = self.class

      while inspecting
Severity: Minor
Found in lib/nokogiri/class_resolver.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

Method method_missing has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def method_missing(method, *args, &block)
          opts = args.last.is_a?(Hash) ? args.pop : {}
          case method.to_s
          when /^(.*)!$/
            @node["id"] = Regexp.last_match(1)
Severity: Minor
Found in lib/nokogiri/xml/builder.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

Method index has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def index(node = nil)
        if node
          warn("given block not used") if block_given?
          each_with_index { |member, j| return j if member == node }
        elsif block_given?
Severity: Minor
Found in lib/nokogiri/xml/node_set.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

Method method_missing has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def method_missing(method, *args, &block) # :nodoc:
        if @context&.respond_to?(method)
          @context.send(method, *args, &block)
        else
          node = @doc.create_element(method.to_s.sub(/[_!]$/, ""), *args) do |n|
Severity: Minor
Found in lib/nokogiri/xml/builder.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

Method engineCanonicalizeSubTree has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  protected byte[]
  engineCanonicalizeSubTree(Node rootNode, Node excludeNode, CanonicalFilter filter)
  throws CanonicalizationException
  {
    this.excludeNode = excludeNode;
Severity: Minor
Found in ext/java/nokogiri/internals/c14n/CanonicalizerBase.java - About 1 hr to fix

    Method outputTextToWriter has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      protected static final void
      outputTextToWriter(
        final String text, final OutputStream writer
      ) throws IOException
      {
    Severity: Minor
    Found in ext/java/nokogiri/internals/c14n/CanonicalizerBase.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 logicalNextDOMTextNode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Method createElementNode has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            createElementNode(Ruby ruby, String uri, String localName, String qName, XMLAttributes attrs, int depth,
                              Stack<String> langStack, Stack<String> xmlBaseStack)
          Severity: Major
          Found in ext/java/nokogiri/internals/ReaderNode.java - About 1 hr to fix

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

              @JRubyMethod(meta = true, required = 4)
              public static IRubyObject
              read_io(ThreadContext context, IRubyObject klass, IRubyObject[] args)
              {
                XmlDomParserContext ctx = new XmlDomParserContext(context.runtime, args[2], args[3]);
            Severity: Major
            Found in ext/java/nokogiri/XmlDocument.java and 3 other locations - About 1 hr to fix
            ext/java/nokogiri/Html4Document.java on lines 140..147
            ext/java/nokogiri/Html4Document.java on lines 149..156
            ext/java/nokogiri/XmlDocument.java on lines 360..367

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

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

              @JRubyMethod(meta = true, required = 4)
              public static IRubyObject
              read_memory(ThreadContext context, IRubyObject klass, IRubyObject[] args)
              {
                XmlDomParserContext ctx = new XmlDomParserContext(context.runtime, args[2], args[3]);
            Severity: Major
            Found in ext/java/nokogiri/XmlDocument.java and 3 other locations - About 1 hr to fix
            ext/java/nokogiri/Html4Document.java on lines 140..147
            ext/java/nokogiri/Html4Document.java on lines 149..156
            ext/java/nokogiri/XmlDocument.java on lines 351..358

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

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

              @JRubyMethod(meta = true, required = 4)
              public static IRubyObject
              read_memory(ThreadContext context, IRubyObject klass, IRubyObject[] args)
              {
                HtmlDomParserContext ctx = new HtmlDomParserContext(context.runtime, args[2], args[3]);
            Severity: Major
            Found in ext/java/nokogiri/Html4Document.java and 3 other locations - About 1 hr to fix
            ext/java/nokogiri/Html4Document.java on lines 140..147
            ext/java/nokogiri/XmlDocument.java on lines 351..358
            ext/java/nokogiri/XmlDocument.java on lines 360..367

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

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

              @JRubyMethod(meta = true, required = 4)
              public static IRubyObject
              read_io(ThreadContext context, IRubyObject klass, IRubyObject[] args)
              {
                HtmlDomParserContext ctx = new HtmlDomParserContext(context.runtime, args[2], args[3]);
            Severity: Major
            Found in ext/java/nokogiri/Html4Document.java and 3 other locations - About 1 hr to fix
            ext/java/nokogiri/Html4Document.java on lines 149..156
            ext/java/nokogiri/XmlDocument.java on lines 351..358
            ext/java/nokogiri/XmlDocument.java on lines 360..367

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

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

              protected byte[]
              engineCanonicalizeSubTree(Node rootNode, Node excludeNode, CanonicalFilter filter)
              throws CanonicalizationException
              {
                this.excludeNode = excludeNode;
            Severity: Minor
            Found in ext/java/nokogiri/internals/c14n/CanonicalizerBase.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 evaluate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              @JRubyMethod
              public IRubyObject
              evaluate(ThreadContext context, IRubyObject rbQuery, IRubyObject handler)
              {
                String query = rbQuery.convertToString().asJavaString();
            Severity: Minor
            Found in ext/java/nokogiri/XmlXpathContext.java - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

              public static boolean
              isDescendantOrSelf(Node ctx, Node descendantOrSelf)
              {
                if (ctx == descendantOrSelf) {
                  return true;
            Severity: Minor
            Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            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

            Severity
            Category
            Status
            Source
            Language