sparklemotion/nokogiri

View on GitHub

Showing 400 of 533 total issues

Method initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(document, tags = nil, ctx = nil, options = ParseOptions::DEFAULT_XML) # rubocop:disable Lint/MissingSuper
        return self unless tags

        options = Nokogiri::XML::ParseOptions.new(options) if Integer === options
        yield options if block_given?
Severity: Minor
Found in lib/nokogiri/xml/document_fragment.rb - About 55 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 createClosingNode has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  createClosingNode(Ruby ruby, String uri, String localName, String qName, int depth, Stack<String> langStack,
                    Stack<String> xmlBaseStack)
Severity: Major
Found in ext/java/nokogiri/internals/ReaderNode.java - About 50 mins to fix

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

      private void
      setAttribute(ThreadContext context, String key, String val)
      {
        Element element = (Element) node;
    
    
    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 (rewriteTable == null) { rewriteTable = new HashMap<CharSequence, CharSequence>(8, 1); }
    Severity: Major
    Found in ext/java/nokogiri/XmlDocumentFragment.java - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if (attr.isId() && id.equals(attr.getValue()) && se != knownElement) {
                    //log.debug("Multiple elements with the same 'Id' attribute value!");
                    return false;
                  }
      Severity: Major
      Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 45 mins to fix

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

          protected static void
          coalesceTextNodes(ThreadContext context,
                            IRubyObject anchorNode,
                            AdoptScheme scheme)
          {
        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 getContentImpl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            public CharSequence
            getContentImpl()
            {
              if (!node.hasChildNodes() && node.getNodeValue() == null &&
                  (node.getNodeType() == Node.TEXT_NODE || node.getNodeType() == Node.CDATA_SECTION_NODE)) {
          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 (childElement.hasAttributeNS(namespaceNs,
                                                          currentAttr.getLocalName())) {
                            continue;
                          }
          Severity: Major
          Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            if (!namespaceNs.equals(currentAttr.getNamespaceURI())) {
                              continue;
                            }
            Severity: Major
            Found in ext/java/nokogiri/internals/c14n/XMLUtils.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 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

              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

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

                @JRubyMethod
                public IRubyObject
                parse_with(ThreadContext context, IRubyObject handlerRuby)
                {
                  final Ruby runtime = context.getRuntime();
              Severity: Minor
              Found in ext/java/nokogiri/XmlSaxParserContext.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 native_write has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                @JRubyMethod
                public IRubyObject
                native_write(ThreadContext context, IRubyObject chunk,
                             IRubyObject isLast)
                {
              Severity: Minor
              Found in ext/java/nokogiri/XmlSaxPushParser.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 (attr.isId() && id.equals(attr.getValue())) {
                            if (foundElement == null) {
                              // Continue searching to find duplicates
                              foundElement = attr.getOwnerElement();
                            } else {
              Severity: Major
              Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                              if (specifiedPrefix == null &&
                                  attr.getNodeName().equals("xmlns")) {
                                // default namespace
                                return value;
                              } else if (attrPrefix != null &&

                  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 (node == elem) {
                                elemHandle = getHandleFromNode(elem);
                                break;
                              }
                  Severity: Major
                  Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                if (NName.equals("id")) {
                                  if (isRealVisible) {
                                    // treat xml:id like any other attribute
                                    // (emit it, but don't inherit it)
                                    result.add(attribute);
                    Severity: Major
                    Found in ext/java/nokogiri/internals/c14n/Canonicalizer11.java - About 45 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language