sparklemotion/nokogiri

View on GitHub

Showing 511 of 511 total issues

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

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

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

        public void leave(Node node) {
            if (node instanceof Document) {
                leave((Document)node);
                return;
            }
    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 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/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 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 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 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 canonicalize has a Cognitive Complexity of 19 (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 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

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

                              } else if (!XML.equals(NName) || !XML_LANG_URI.equals(NValue)) {
                                  /* except omit namespace node with local name xml, which defines
                                   * the xml prefix, if its string value is
                                   * http://www.w3.org/XML/1998/namespace.
                                   */
              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/Canonicalizer20010315.java on lines 278..304

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

              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

                              } else if (!XML.equals(NName) || !XML_LANG_URI.equals(NValue)) {
                                  /* except omit namespace node with local name xml, which defines
                                   * the xml prefix, if its string value is http://www.w3.org/XML/1998/namespace.
                                   */
                                  //add the prefix binding to the ns symb table.
              Severity: Major
              Found in ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java and 1 other location - About 2 hrs to fix
              ext/java/nokogiri/internals/c14n/Canonicalizer11.java on lines 313..340

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

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