sparklemotion/nokogiri

View on GitHub

Showing 537 of 537 total issues

Avoid too many return statements within this method.
Open

    /*if (o instanceof XmlNode)*/ return ((XmlNode) obj).getNode();
Severity: Major
Found in ext/java/nokogiri/internals/NokogiriXPathFunction.java - About 30 mins to fix

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

          def inspect
            options = []
            self.class.constants.each do |k|
              options << k.downcase if send(:"#{k.downcase}?")
            end
    Severity: Minor
    Found in lib/nokogiri/xml/parse_options.rb and 1 other location - About 25 mins to fix
    lib/nokogiri/xml/node/save_options.rb on lines 66..71

    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 31.

    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

            def inspect
              options = []
              self.class.constants.each do |k|
                options << k.downcase if send(:"#{k.downcase}?")
              end
    Severity: Minor
    Found in lib/nokogiri/xml/node/save_options.rb and 1 other location - About 25 mins to fix
    lib/nokogiri/xml/parse_options.rb on lines 204..209

    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 31.

    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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      @JRubyMethod(visibility = Visibility.PRIVATE)
      public IRubyObject
      get(ThreadContext context, IRubyObject rbkey)
      {
        if (node instanceof Element) {
    Severity: Minor
    Found in ext/java/nokogiri/XmlNode.java - About 25 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 accept has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      @Override
      public void
      accept(ThreadContext context, SaveContextVisitor visitor)
      {
        visitor.enter((Text) node);
    Severity: Minor
    Found in ext/java/nokogiri/XmlText.java - About 25 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 isVisibleInt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      protected int
      isVisibleInt(Node currentNode)
      {
        if (nodeFilter != null) {
          Iterator<NodeFilter> it = nodeFilter.iterator();
    Severity: Minor
    Found in ext/java/nokogiri/internals/c14n/CanonicalizerBase.java - About 25 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 rbNew has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      @JRubyMethod(name = "new", meta = true, required = 1, optional = 3)
      public static IRubyObject
      rbNew(ThreadContext context, IRubyObject cls, IRubyObject[] args, Block block)
      {
        if (args.length < 1) {
    Severity: Minor
    Found in ext/java/nokogiri/XmlDocumentFragment.java - About 25 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 resolveNamespaceIfNecessary has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private void
      resolveNamespaceIfNecessary(Node node, String default_href)
      {
        if (node == null) { return; }
        String nodePrefix = node.getPrefix();
    Severity: Minor
    Found in ext/java/nokogiri/XmlDocument.java - About 25 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 isVisible has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      protected boolean
      isVisible(Node currentNode)
      {
        if (nodeFilter != null) {
          Iterator<NodeFilter> it = nodeFilter.iterator();
    Severity: Minor
    Found in ext/java/nokogiri/internals/c14n/CanonicalizerBase.java - About 25 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 addMappingAndRender has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      public Node
      addMappingAndRender(String prefix, String uri, Attr n)
      {
        NameSpaceSymbEntry ob = symb.get(prefix);
    
    
    Severity: Minor
    Found in ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java - About 25 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 apply has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      protected void
      apply(Ruby runtime, RubyClass klass,
            XmlDocument doc,
            NodeIter iter)
      {
    Severity: Minor
    Found in ext/java/nokogiri/XmlElementContent.java - About 25 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 addMapping has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      public boolean
      addMapping(String prefix, String uri, Attr n)
      {
        NameSpaceSymbEntry ob = symb.get(prefix);
        if ((ob != null) && uri.equals(ob.uri)) {
    Severity: Minor
    Found in ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java - About 25 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 equals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        public boolean
        equals(final Object obj)
        {
          if (obj instanceof CacheKey) {
    Severity: Minor
    Found in ext/java/nokogiri/internals/NokogiriNamespaceCache.java - About 25 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 verifyXmlSpace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private void
      verifyXmlSpace(List<Attr> attributes, NamedNodeMap attrs)
      {
        Attr attr = (Attr) attrs.getNamedItem("xml:space");
        if (attr == null) {
    Severity: Minor
    Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 25 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 getNamespacesAndAttrs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private void
      getNamespacesAndAttrs(Node current, List<Attr> namespaces, List<Attr> attributes)
      {
        NamedNodeMap attrs = current.getAttributes();
        for (int i = 0; i < attrs.getLength(); i++) {
    Severity: Minor
    Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 25 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 createElementForFamily has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      public static Element
      createElementForFamily(Document doc, String namespace, String localName)
      {
        Element result;
        String prefix = ElementProxy.getDefaultPrefix(namespace);
    Severity: Minor
    Found in ext/java/nokogiri/internals/c14n/ElementProxy.java - About 25 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 getNodeName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      @Override
      protected IRubyObject
      getNodeName(ThreadContext context)
      {
        if (name != null) { return name; }
    Severity: Minor
    Found in ext/java/nokogiri/XmlAttr.java - About 25 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 findEmptyTexts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private static void
      findEmptyTexts(Node node, List<Node> emptyNodes)
      {
        if (node.getNodeType() == Node.TEXT_NODE && isBlank(node.getTextContent())) {
          emptyNodes.add(node);
    Severity: Minor
    Found in ext/java/nokogiri/internals/XmlDomParserContext.java - About 25 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 encoding has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      @JRubyMethod
      public IRubyObject
      encoding(ThreadContext context)
      {
        if (this.encoding == null || this.encoding.isNil()) {
    Severity: Minor
    Found in ext/java/nokogiri/XmlDocument.java - About 25 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 convert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private static StringBuffer
      convert(Pattern ptn, CharSequence input, String[] oldChars, String[] newChars)
      {
        Matcher matcher = ptn.matcher(input);
        boolean result = matcher.find();
    Severity: Minor
    Found in ext/java/nokogiri/internals/NokogiriHelpers.java - About 25 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

    Severity
    Category
    Status
    Source
    Language