sparklemotion/nokogiri

View on GitHub

Showing 515 of 515 total issues

Method handleAttributes has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Override
    protected Iterator<Attr> handleAttributes(Element element, NameSpaceSymbTable ns)
        throws CanonicalizationException {
        // result will contain the attrs which have to be output
        xmlattrStack.push(ns.getLevel());
Severity: Major
Found in ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java - About 2 hrs to fix

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

        protected void outputPItoWriter(
            ProcessingInstruction currentPI, OutputStream writer, int position
        ) throws IOException {
            if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
                writer.write('\n');
    Severity: Minor
    Found in ext/java/nokogiri/internals/c14n/CanonicalizerBase.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 resolveEntity has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        protected InputSource resolveEntity(Ruby runtime, String name, String publicId, String baseURI, String systemId)
            throws IOException, SAXException {
            InputSource s = new InputSource();
            if (name.equals("[dtd]") && !shouldLoadDtd()) {
              return emptyInputSource(s);
    Severity: Minor
    Found in ext/java/nokogiri/internals/NokogiriEntityResolver.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 getElementById has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public int getElementById(String elementId)
        {
    
            Document doc = (m_root.getNodeType() == Node.DOCUMENT_NODE)
                ? (Document) m_root : m_root.getOwnerDocument();
    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 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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                    if (output.length() == 0) {
                        output.append("/");
                    } else if (output.toString().endsWith("../")) {
                        output.append("..");
                    } else if (output.toString().endsWith("..")) {
    Severity: Major
    Found in ext/java/nokogiri/internals/c14n/Canonicalizer11.java and 1 other location - About 2 hrs to fix
    ext/java/nokogiri/internals/c14n/Canonicalizer11.java on lines 537..553

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 138.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                    if (output.length() == 0) {
                        output.append("/");
                    } else if (output.toString().endsWith("../")) {
                        output.append("..");
                    } else if (output.toString().endsWith("..")) {
    Severity: Major
    Found in ext/java/nokogiri/internals/c14n/Canonicalizer11.java and 1 other location - About 2 hrs to fix
    ext/java/nokogiri/internals/c14n/Canonicalizer11.java on lines 558..574

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 138.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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
                Severity
                Category
                Status
                Source
                Language