sparklemotion/nokogiri

View on GitHub
lib/nokogiri/html5/node.rb

Summary

Maintainability
A
2 hrs
Test Coverage
A
94%

Method write_to has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def write_to(io, *options)
        return super(io, *options) unless document.is_a?(HTML5::Document)

        options = options.first.is_a?(Hash) ? options.shift : {}
        encoding = options[:encoding] || options[0]
Severity: Minor
Found in lib/nokogiri/html5/node.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

Consider simplifying this complex logical expression.
Open

        if Nokogiri.jruby?
          save_options = options[:save_with] || options[1]
          indent_times = options[:indent] || 0
        else
          save_options = options[:save_with] || options[1] || XML::Node::SaveOptions::FORMAT
Severity: Major
Found in lib/nokogiri/html5/node.rb - About 40 mins to fix

    There are no issues that match your filters.

    Category
    Status