sparklemotion/nokogiri

View on GitHub

Showing 400 of 537 total issues

Avoid deeply nested control flow statements.
Open

            if (rewriteTable == null) { rewriteTable = new HashMap<CharSequence, CharSequence>(8, 1); }
Severity: Major
Found in ext/java/nokogiri/XmlDocumentFragment.java - About 45 mins to fix

    Method resolveResource has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        public LSInput
        resolveResource(String type,
                        String namespaceURI,
                        String publicId,
    Severity: Minor
    Found in ext/java/nokogiri/XmlSchema.java - About 45 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 getAttrsOfAncestors has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      private void
      getAttrsOfAncestors(Node parent, List<Attr> namespaces, List<Attr> attributes)
      {
        if (parent == null) { return; }
        NamedNodeMap attrs = parent.getAttributes();
    Severity: Minor
    Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 45 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 findNamespaceHref has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      private String
      findNamespaceHref(ThreadContext context, String prefix)
      {
        XmlNode currentNode = this;
        final XmlDocument doc = document(context.runtime);
    Severity: Minor
    Found in ext/java/nokogiri/XmlNode.java - About 45 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 deeply nested control flow statements.
    Open

                if (prefix != null && !(prefix.equals(XML) || prefix.equals(XMLNS))) {
                  visiblyUtilized.add(prefix);
                }
    Severity: Major
    Found in ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java - About 45 mins to fix

      Method getNodeValue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        public String
        getNodeValue(int nodeHandle)
        {
          // The _type(nodeHandle) call was taking the lion's share of our
          // time, and was wrong anyway since it wasn't converting handle to
      Severity: Minor
      Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 45 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 deeply nested control flow statements.
      Open

                  if (!m_processedFirstElement
                      && "xmlns:xml".equals(attrs.item(i).getNodeName())) {
                    m_processedFirstElement = true;
                  }
      Severity: Major
      Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 45 mins to fix

        Method getStrFromNode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          public static String
          getStrFromNode(Node xpathnode)
          {
            if (xpathnode.getNodeType() == Node.TEXT_NODE) {
              // we iterate over all siblings of the context node because eventually,
        Severity: Minor
        Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 45 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 deeply nested control flow statements.
        Open

                          mk.sub!(/^PREFIX\s*=\s*$/, "PREFIX = #{host}-") if cross_build_p
        Severity: Major
        Found in ext/nokogiri/extconf.rb - About 45 mins to fix

          Method configure has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                      def configure
                        Dir.chdir(work_path) do
                          mk = File.read("win32/Makefile.gcc")
                          File.open("win32/Makefile.gcc", "wb") do |f|
                            f.puts "BINARY_PATH = #{path}/bin"
          Severity: Minor
          Found in ext/nokogiri/extconf.rb - About 45 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_attribute_condition has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def visit_attribute_condition(node)
                  attribute = node.value.first.accept(self)
                  return attribute if node.value.length == 1
          
                  value = node.value.last
          Severity: Minor
          Found in lib/nokogiri/css/xpath_visitor.rb - About 45 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 fromRubyToObject has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            private static Object
            fromRubyToObject(final Ruby runtime, IRubyObject obj)
            {
              if (obj instanceof RubyString) { return obj.asJavaString(); }
              if (obj instanceof RubyBoolean) { return obj.toJava(Boolean.class); }
          Severity: Minor
          Found in ext/java/nokogiri/internals/NokogiriXPathFunction.java - About 45 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 stabilizeAttrs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            private static void
            stabilizeAttrs(Node node)
            {
              if (node.hasAttributes()) {
                NamedNodeMap nodeMap = node.getAttributes();
          Severity: Minor
          Found in ext/java/nokogiri/Html4Document.java - About 45 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 deeply nested control flow statements.
          Open

                        if darwin?
                          # needed as of zlib 1.2.13
                          Dir.chdir(work_path) do
                            makefile = File.read("Makefile").gsub(/^AR=.*$/, "AR=#{host}-libtool")
                            File.open("Makefile", "w") { |m| m.write(makefile) }
          Severity: Major
          Found in ext/nokogiri/extconf.rb - About 45 mins to fix

            Method inspect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def inspect
                      # handle the case where an exception is thrown during object construction
                      if respond_to?(:data_ptr?) && !data_ptr?
                        return "#<#{self.class}:#{format("0x%x", object_id)} (no data)>"
                      end
            Severity: Minor
            Found in lib/nokogiri/xml/pp/node.rb - About 45 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 read_and_encode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def read_and_encode(string, encoding)
                    # Read the string with the given encoding.
                    if string.respond_to?(:read)
                      string = if encoding.nil?
                        string.read
            Severity: Minor
            Found in lib/nokogiri/html5.rb - About 45 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

            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

              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] || XML::Node::SaveOptions::FORMAT
              Severity: Major
              Found in lib/nokogiri/html5/node.rb - About 40 mins to fix

                Method resolveResource has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    resolveResource(String type,
                                    String namespaceURI,
                                    String publicId,
                                    String systemId,
                                    String baseURI)
                Severity: Minor
                Found in ext/java/nokogiri/XmlSchema.java - About 35 mins to fix

                  Method canonicalizeSubTree has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      Node currentNode, NameSpaceSymbTable ns, Node endnode, int documentLevel, CanonicalFilter filter
                  Severity: Minor
                  Found in ext/java/nokogiri/internals/c14n/CanonicalizerBase.java - About 35 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language