sparklemotion/nokogiri

View on GitHub

Showing 385 of 513 total issues

Method parse has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

        def parse string_or_io, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML

          options = Nokogiri::XML::ParseOptions.new(options) if Integer === options
          # Give the options to the user
          yield options if block_given?
Severity: Minor
Found in lib/nokogiri/html/document.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 getXmlnsAttr has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        void getXmlnsAttr(Collection<Attr> col) throws CanonicalizationException {
            int size = levels.size() - 1;
            if (cur == null) {
                cur = new XmlsStackElement();
                cur.level = currentLevel;
Severity: Major
Found in ext/java/nokogiri/internals/c14n/Canonicalizer11.java - About 2 hrs to fix

    Method handleAttributesSubtree has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        protected Iterator<Attr> handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
            throws CanonicalizationException {
            if (!element.hasAttributes() && !firstCall) {
                return null;
    Severity: Minor
    Found in ext/java/nokogiri/internals/c14n/Canonicalizer20010315.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 canonicalize has a Cognitive Complexity of 20 (exceeds 5 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 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 addNamespaceDeclIfNeeded has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        private static String addNamespaceDeclIfNeeded(XmlDocument doc, String tags) {
            if (doc.getDocument() == null) return tags;
            if (doc.getDocument().getDocumentElement() == null) return tags;
            Matcher matcher = START_TAG_RE.matcher(tags);
            Map<CharSequence, CharSequence> rewriteTable = null;
    Severity: Minor
    Found in ext/java/nokogiri/XmlDocumentFragment.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 handleAttributesSubtree has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        protected Iterator<Attr> handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
            throws CanonicalizationException {
            if (!element.hasAttributes() && !firstCall) {
                return null;
    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 enter has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        public boolean enter(Element element) {
            if (canonical) {
                c14nNodeList.add(element);
                if (element == element.getOwnerDocument().getDocumentElement()) {
                    c14nNodeList.add(element.getOwnerDocument());
    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 addNode has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected int addNode(Node node, int parentIndex,
                              int previousSibling, int forceNodeType)
        {
            int nodeIndex = m_nodes.size();
    
    
    Severity: Major
    Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 2 hrs to fix

      Method getStringInUtf8 has a Cognitive Complexity of 19 (exceeds 5 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: 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 joinURI has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static String joinURI(String baseURI, String relativeURI) throws URISyntaxException {
              String bscheme = null;
              String bauthority = null;
              String bpath = "";
              String bquery = null;
      Severity: Major
      Found in ext/java/nokogiri/internals/c14n/Canonicalizer11.java - About 2 hrs to fix

        Method handleAttributes has 63 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/Canonicalizer11.java - About 2 hrs to fix

          XmlSaxParserContext has 23 methods (exceeds 20 allowed). Consider refactoring.
          Open

          @JRubyClass(name="Nokogiri::XML::SAX::ParserContext")
          public class XmlSaxParserContext extends ParserContext {
          
              protected static final String FEATURE_NAMESPACES =
                  "http://xml.org/sax/features/namespaces";
          Severity: Minor
          Found in ext/java/nokogiri/XmlSaxParserContext.java - About 2 hrs to fix

            Method leave has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                public void leave(Element element) {
                    if (canonical) {
                        c14nNamespaceStack.poll();
                        c14nAttrStack.poll();
                    }
            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 getAttributeNode has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                public int getAttributeNode(int nodeHandle, String namespaceURI,
                                            String name)
                {
            
                    // %OPT% This is probably slower than it needs to be.
            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 getUnparsedEntityURI has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                public String getUnparsedEntityURI(String name)
                {
            
                    String url = "";
                    Document doc = (m_root.getNodeType() == Node.DOCUMENT_NODE)
            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 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

              Severity
              Category
              Status
              Source
              Language