sparklemotion/nokogiri

View on GitHub

Showing 533 of 533 total issues

Method op_or has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  @JRubyMethod(name = {"|", "+"})
  public IRubyObject
  op_or(ThreadContext context, IRubyObject nodeSet)
  {
    IRubyObject[] otherNodes = getNodes(context, nodeSet);
Severity: Minor
Found in ext/java/nokogiri/XmlNodeSet.java - About 1 hr 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 12 (exceeds 5 allowed). Consider refactoring.
Open

  @Override
  public void
  accept(ThreadContext context, SaveContextVisitor visitor)
  {
    Document document = getDocument();
Severity: Minor
Found in ext/java/nokogiri/XmlDocument.java - About 1 hr 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 visit_element_name has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def visit_element_name(node)
        if @doctype == DoctypeConfig::HTML5 && html5_element_name_needs_namespace_handling(node)
          # HTML5 has namespaces that should be ignored in CSS queries
          # https://github.com/sparklemotion/nokogiri/issues/2376
          if @builtins == BuiltinsConfig::ALWAYS || (@builtins == BuiltinsConfig::OPTIMAL && Nokogiri.uses_libxml?)
Severity: Minor
Found in lib/nokogiri/css/xpath_visitor.rb - About 1 hr 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 12 (exceeds 5 allowed). Consider refactoring.
Open

        def parse(string_or_io, url = nil, encoding = nil, **options, &block)
          yield options if block
          string_or_io = "" unless string_or_io

          if string_or_io.respond_to?(:encoding) && string_or_io.encoding != Encoding::ASCII_8BIT
Severity: Minor
Found in lib/nokogiri/html5/document.rb - About 1 hr 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 initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(document, tags = nil, ctx = nil, options = XML::ParseOptions::DEFAULT_HTML) # 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/html4/document_fragment.rb - About 1 hr 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 compare has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public int
  compare(Attr attr0, Attr attr1)
  {
    String namespaceURI0 = attr0.getNamespaceURI();
    String namespaceURI1 = attr1.getNamespaceURI();
Severity: Minor
Found in ext/java/nokogiri/internals/c14n/AttrCompare.java - About 1 hr to fix

    Method handleAttributesSubtree has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      @Override
      protected Iterator<Attr>
      handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
      throws CanonicalizationException
      {
    Severity: Minor
    Found in ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java - About 1 hr to fix

      Method handleAttributesSubtree has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        @Override
        protected Iterator<Attr>
        handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
        throws CanonicalizationException
        {
      Severity: Minor
      Found in ext/java/nokogiri/internals/c14n/Canonicalizer11.java - About 1 hr to fix

        Method outputPItoWriter has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          protected void
          outputPItoWriter(
            ProcessingInstruction currentPI, OutputStream writer, int position
          ) throws IOException
          {
        Severity: Minor
        Found in ext/java/nokogiri/internals/c14n/CanonicalizerBase.java - About 1 hr to fix

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

                if ((prefix == null) || (prefix.length() == 0)) {
                  result = doc.createElementNS(namespace, localName);
                  result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns", namespace);
                } else {
                  result = doc.createElementNS(namespace, prefix + ":" + localName);
          Severity: Major
          Found in ext/java/nokogiri/internals/c14n/ElementProxy.java and 1 other location - About 1 hr to fix
          ext/java/nokogiri/internals/c14n/ElementProxy.java on lines 160..166

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

          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 ((prefix == null) || (prefix.length() == 0)) {
                  result = doc.createElementNS(namespace, localName);
                  result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns", namespace);
                } else {
                  result = doc.createElementNS(namespace, prefix + ":" + localName);
          Severity: Major
          Found in ext/java/nokogiri/internals/c14n/ElementProxy.java and 1 other location - About 1 hr to fix
          ext/java/nokogiri/internals/c14n/ElementProxy.java on lines 127..133

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

          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 enter has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public boolean
            enter(Node node)
            {
              if (node instanceof Document) {
                return enter((Document)node);
          Severity: Minor
          Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 1 hr to fix

            Method populateNokogiriClassCache has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private static Map<String, RubyClass>
              populateNokogiriClassCache(Ruby ruby)
              {
                Map<String, RubyClass> nokogiriClassCache = new HashMap<String, RubyClass>();
                nokogiriClassCache.put("Nokogiri::HTML4::Document", (RubyClass)ruby.getClassFromPath("Nokogiri::HTML4::Document"));
            Severity: Minor
            Found in ext/java/nokogiri/NokogiriService.java - About 1 hr to fix

              Method resolveEntity has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                protected InputSource
                resolveEntity(Ruby runtime, String name, String publicId, String baseURI, String systemId)
                throws IOException, SAXException
                {
                  InputSource s = new InputSource();
              Severity: Minor
              Found in ext/java/nokogiri/internals/NokogiriEntityResolver.java - About 1 hr to fix

                Method getAttrsAndNamespaces has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private Attr[]
                  getAttrsAndNamespaces(Element element)
                  {
                    NamedNodeMap attrs = element.getAttributes();
                    if (!canonical) {
                Severity: Minor
                Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 1 hr to fix

                  Method getXmlnsAttr has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      void
                      getXmlnsAttr(Collection<Attr> col)
                      {
                        int size = levels.size() - 1;
                        if (cur == null) {
                  Severity: Minor
                  Found in ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java - About 1 hr to fix

                    Method protectAgainstWrappingAttack has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      public static boolean
                      protectAgainstWrappingAttack(
                        Node startNode, Element knownElement, String value
                      )
                      {
                    Severity: Minor
                    Found in ext/java/nokogiri/internals/c14n/XMLUtils.java - About 1 hr to fix

                      Method parse_with has 33 lines of code (exceeds 25 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 1 hr to fix

                        Method pretty_print has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                def pretty_print(pp)
                                  nice_name = self.class.name.split("::").last
                                  pp.group(2, "#(#{nice_name}:#{format("0x%x", object_id)} {", "})") do
                                    pp.breakable
                        
                        
                        Severity: Minor
                        Found in lib/nokogiri/xml/pp/node.rb - About 1 hr to fix

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

                              outer:
                              for (int i = 0; i < curr.length; i++) {
                                IRubyObject n = curr[i];
                          
                                for (int j = 0; j < other.length; j++) {
                          Severity: Major
                          Found in ext/java/nokogiri/XmlNodeSet.java and 1 other location - About 1 hr to fix
                          ext/java/nokogiri/XmlNodeSet.java on lines 298..309

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

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language