sparklemotion/nokogiri

View on GitHub

Showing 383 of 515 total issues

Method getHandleOfNode has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public int getHandleOfNode(Node node)
    {
        if (null != node)
        {
            // Is Node actually within the same document? If not, don't search!
Severity: Minor
Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 2 hrs 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_function has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def visit_function node

        msg = :"visit_function_#{node.value.first.gsub(/[(]/, '')}"
        return self.send(msg, node) if self.respond_to?(msg)

Severity: Major
Found in lib/nokogiri/css/xpath_visitor.rb - About 2 hrs to fix

    Method handleParent has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        protected void handleParent(Element e, NameSpaceSymbTable ns) {
            if (!e.hasAttributes() && e.getNamespaceURI() == null) {
                return;
            }
    Severity: Minor
    Found in ext/java/nokogiri/internals/c14n/Canonicalizer11.java - About 2 hrs 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 getAttributesWithPropagated has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        private void getAttributesWithPropagated(List<Attr> attributes, Attr attr) {
            boolean newAttribute = true;
            Iterator<Attr[]> iter = c14nAttrStack.iterator();
            while (iter.hasNext()) {
                Attr[] parentAttr = iter.next();
    Severity: Minor
    Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 2 hrs 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 writeStringToUtf8 has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public static void writeStringToUtf8(
            final String str,
            final OutputStream out
        ) throws IOException{       
            final int length = str.length();
    Severity: Minor
    Found in ext/java/nokogiri/internals/c14n/UtfHelpper.java - About 2 hrs 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 getXmlBaseUri has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

            private String getXmlBaseUri(String n, String v, Stack<String> xmlBaseStack) {
                if ("xml:base".equals(n)) {
                    if (v.startsWith("http://")) {
                        return v;
                    } else if (v.startsWith("/") && v.endsWith("/")) {
    Severity: Minor
    Found in ext/java/nokogiri/internals/ReaderNode.java - About 2 hrs 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_hash has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_hash
          {}.tap do |vi|
            vi["warnings"] = []
            vi["nokogiri"] = Nokogiri::VERSION
            vi["ruby"] = {}.tap do |ruby|
    Severity: Minor
    Found in lib/nokogiri/version.rb - About 2 hrs 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 pretty_print has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

            def pretty_print pp # :nodoc:
              nice_name = self.class.name.split('::').last
              pp.group(2, "#(#{nice_name}:#{sprintf("0x%x", object_id)} {", '})') do
    
                pp.breakable
    Severity: Minor
    Found in lib/nokogiri/xml/pp/node.rb - About 2 hrs 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 nth has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def nth node, options={}
            raise ArgumentError, "expected an+b node to contain 4 tokens, but is #{node.value.inspect}" unless node.value.size == 4
    
            a, b = read_a_and_positive_b node.value
            position = if options[:child]
    Severity: Minor
    Found in lib/nokogiri/css/xpath_visitor.rb - About 2 hrs 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 adoptAs has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected IRubyObject adoptAs(ThreadContext context, AdoptScheme scheme, IRubyObject other_) {
            final XmlNode other = asXmlNode(context, other_);
            // this.doc might be null since this node can be empty node.
            if (doc != null) other.setDocument(context, doc);
    
    
    Severity: Major
    Found in ext/java/nokogiri/XmlNode.java - About 2 hrs to fix

      File NameSpaceSymbTable.java has 252 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
       * Licensed to the Apache Software Foundation (ASF) under one
       * or more contributor license agreements. See the NOTICE file
       * distributed with this work for additional information
       * regarding copyright ownership. The ASF licenses this file
      Severity: Minor
      Found in ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java - About 2 hrs to fix

        Method getStringInUtf8 has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static byte[] getStringInUtf8(final String str) {
                final int length = str.length();
                boolean expanded = false;
                byte[] result = new byte[length];
                int i = 0;
        Severity: Major
        Found in ext/java/nokogiri/internals/c14n/UtfHelpper.java - About 2 hrs to fix

          Method circumventBug2650internal has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @SuppressWarnings("fallthrough")
              private static void circumventBug2650internal(Node node) {
                  Node parent = null;
                  Node sibling = null;
                  final String namespaceNs = Constants.NamespaceSpecNS;
          Severity: Minor
          Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 2 hrs to fix

            Method canonicalize has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @JRubyMethod(optional=3)
                public IRubyObject canonicalize(ThreadContext context, IRubyObject[] args, Block block) {
                    int mode = 0;
                    String inclusive_namespace = null;
                    Boolean with_comments = false;
            Severity: Minor
            Found in ext/java/nokogiri/XmlDocument.java - About 1 hr to fix

              Method lookupNamespaceURI has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public String lookupNamespaceURI(String specifiedPrefix) {
                      short type = this.getNodeType();
                      switch (type) {
                      case Node.ELEMENT_NODE : {
              
              

                Method createXmlModule has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private RubyClass createXmlModule(Ruby ruby, RubyModule xmlModule) {
                        RubyClass node = xmlModule.defineClassUnder("Node", ruby.getObject(), XML_NODE_ALLOCATOR);
                        node.defineAnnotatedMethods(XmlNode.class);
                        
                        RubyClass attr = xmlModule.defineClassUnder("Attr", node, XML_ATTR_ALLOCATOR);
                Severity: Minor
                Found in ext/java/nokogiri/NokogiriService.java - About 1 hr to fix

                  Method relink_namespace has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public void relink_namespace(ThreadContext context) {
                          if (!(node instanceof Element)) {
                              return;
                          }
                  
                  
                  Severity: Minor
                  Found in ext/java/nokogiri/XmlNode.java - About 1 hr to fix

                    Method compare has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public int compare(Attr attr0, Attr attr1) {
                            String namespaceURI0 = attr0.getNamespaceURI();      
                            String namespaceURI1 = attr1.getNamespaceURI();
                          
                            boolean isNamespaceAttr0 = XMLNS.equals(namespaceURI0);
                    Severity: Minor
                    Found in ext/java/nokogiri/internals/c14n/AttrCompare.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 handleParent has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        @Override
                        protected void handleParent(Element e, NameSpaceSymbTable ns) {
                            if (!e.hasAttributes() && e.getNamespaceURI() == null) {
                                return;
                            }
                    Severity: Minor
                    Found in ext/java/nokogiri/internals/c14n/Canonicalizer20010315.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 adoptAs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected IRubyObject adoptAs(ThreadContext context, AdoptScheme scheme, IRubyObject other_) {
                            final XmlNode other = asXmlNode(context, other_);
                            // this.doc might be null since this node can be empty node.
                            if (doc != null) other.setDocument(context, doc);
                    
                    
                    Severity: Minor
                    Found in ext/java/nokogiri/XmlNode.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

                    Severity
                    Category
                    Status
                    Source
                    Language