sparklemotion/nokogiri

View on GitHub

Showing 400 of 537 total issues

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

      def to_xml(*args)
        if Nokogiri.jruby?
          options = args.first.is_a?(Hash) ? args.shift : {}
          unless options[:save_with]
            options[:save_with] = Node::SaveOptions::AS_BUILDER
Severity: Minor
Found in lib/nokogiri/xml/builder.rb - 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 set_metadata_element has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def set_metadata_element(element) # rubocop:disable Naming/AccessorMethodName
        if (head = at_xpath("//head"))
          head << element
        elsif (html = at_xpath("//html"))
          head = html.prepend_child(XML::Node.new("head", self))
Severity: Minor
Found in lib/nokogiri/html4/document.rb - 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 extract_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def extract_params(params) # :nodoc:
        handler = params.find do |param|
          ![Hash, String, Symbol].include?(param.class)
        end
        params -= [handler] if handler
Severity: Minor
Found in lib/nokogiri/html5/document_fragment.rb - 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 try_link_iconv has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def try_link_iconv(using = nil)
  checking_for(using ? "iconv using #{using}" : "iconv") do
    ["", "-liconv"].any? do |opt|
      preserving_globals do
        yield if block_given?
Severity: Minor
Found in ext/nokogiri/extconf.rb - 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 extract_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def extract_params(params) # :nodoc:
        handler = params.find do |param|
          ![Hash, String, Symbol].include?(param.class)
        end
        params -= [handler] if handler
Severity: Minor
Found in lib/nokogiri/xml/searchable.rb - 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 visit_pseudo_class has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def visit_pseudo_class(node)
        if node.value.first.is_a?(Nokogiri::CSS::Node) && (node.value.first.type == :FUNCTION)
          node.value.first.accept(self)
        else
          msg = :"visit_pseudo_class_#{node.value.first.gsub(/[(]/, "")}"
Severity: Minor
Found in lib/nokogiri/css/xpath_visitor.rb - 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 attr has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def attr(key, value = nil, &block)
        unless key.is_a?(Hash) || (key && (value || block))
          return first&.attribute(key)
        end

Severity: Minor
Found in lib/nokogiri/xml/node_set.rb - 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 [] has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def [](ns)
        if @parent != @doc
          @ns = @parent.namespace_definitions.find { |x| x.prefix == ns.to_s }
        end
        return self if @ns
Severity: Minor
Found in lib/nokogiri/xml/builder.rb - 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 xmlDtd;
Severity: Major
Found in ext/java/nokogiri/internals/NokogiriHelpers.java - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        return NokogiriHelpers.nkf(context, encoding, str);
    Severity: Major
    Found in ext/java/nokogiri/internals/NokogiriHelpers.java - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return enter((ProcessingInstruction)node);
      Severity: Major
      Found in ext/java/nokogiri/internals/SaveContextVisitor.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 (attr0.getLocalName()).compareTo(attr1.getLocalName());
          Severity: Major
          Found in ext/java/nokogiri/internals/c14n/AttrCompare.java - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return xmlProcessingInstruction;
            Severity: Major
            Found in ext/java/nokogiri/internals/NokogiriHelpers.java - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return;
              Severity: Major
              Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return false;

                  Avoid too many return statements within this method.
                  Open

                        return;
                  Severity: Major
                  Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return;
                    Severity: Major
                    Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                          return s;
                      Severity: Major
                      Found in ext/java/nokogiri/internals/NokogiriEntityResolver.java - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                              return ATTR0_BEFORE_ATTR1;
                        Severity: Major
                        Found in ext/java/nokogiri/internals/c14n/AttrCompare.java - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language