sparklemotion/nokogiri

View on GitHub
lib/nokogiri/xml/node.rb

Summary

Maintainability
D
2 days
Test Coverage
A
99%

Class Node has 69 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Node
      include Nokogiri::XML::PP::Node
      include Nokogiri::XML::Searchable
      include Enumerable

Severity: Major
Found in lib/nokogiri/xml/node.rb - About 1 day to fix

    File node.rb has 438 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'stringio'
    require 'nokogiri/xml/node/save_options'
    
    module Nokogiri
      module XML
    Severity: Minor
    Found in lib/nokogiri/xml/node.rb - About 6 hrs to fix

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

            def parse string_or_io, options = nil
              ##
              # When the current node is unparented and not an element node, use the
              # document as the parsing context instead. Otherwise, the in-context
              # parser cannot find an element or a document node.
      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 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

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

            def add_sibling next_or_previous, node_or_tags
              impl = (next_or_previous == :next) ? :add_next_sibling_node : :add_previous_sibling_node
              iter = (next_or_previous == :next) ? :reverse_each          : :each
      
              node_or_tags = coerce node_or_tags
      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

      Consider simplifying this complex logical expression.
      Open

              if Nokogiri.jruby?
                save_options  = options[:save_with] || options[1]
                indent_times  = options[:indent] || 0
              else
                save_options  = options[:save_with] || options[1] || SaveOptions::FORMAT
      Severity: Major
      Found in lib/nokogiri/xml/node.rb - About 40 mins to fix

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

              def write_to io, *options
                options       = options.first.is_a?(Hash) ? options.shift : {}
                encoding      = options[:encoding] || options[0]
                if Nokogiri.jruby?
                  save_options  = options[:save_with] || options[1]
        Severity: Minor
        Found in lib/nokogiri/xml/node.rb - 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 prepend_child has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def prepend_child node_or_tags
                if first = children.first
                  # Mimic the error add_child would raise.
                  raise RuntimeError, "Document already has a root node" if document? && !(node_or_tags.comment? || node_or_tags.processing_instruction?)
                  first.__send__(:add_sibling, :previous, node_or_tags)
        Severity: Minor
        Found in lib/nokogiri/xml/node.rb - 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

        There are no issues that match your filters.

        Category
        Status