sparklemotion/nokogiri

View on GitHub

Showing 400 of 533 total issues

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

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

      def add_child(node_or_tags)
        raise "A document may not have multiple root nodes." if (root && root.name != "nokogiri_text_wrapper") && !(node_or_tags.comment? || node_or_tags.processing_instruction?)

        node_or_tags = coerce(node_or_tags)
        if node_or_tags.is_a?(XML::NodeSet)
Severity: Minor
Found in lib/nokogiri/xml/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

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

        if (iter.isNull()) { return; }
    Severity: Major
    Found in ext/java/nokogiri/XmlElementContent.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 a;
        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 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 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 name0.compareTo(name1);
              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 ATTR0_BEFORE_ATTR1;
                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 (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 null;

                        Avoid too many return statements within this method.
                        Open

                              return enter((Comment)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 false;
                          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;
                              Severity: Major
                              Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language