HHRy/prawn-graph

View on GitHub
lib/prawn/graph/chart_components/canvas.rb

Summary

Maintainability
A
25 mins
Test Coverage

Method verify_series_are_ok! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def verify_series_are_ok!
          if @series.respond_to?(:each) && @series.respond_to?(:collect)
            classes = @series.collect{ |c| c.is_a?(Prawn::Graph::Series) }.uniq
            if classes.size > 1 || classes[0] != true
              raise RuntimeError.new("All of the items provided must be instances of Prawn::Graph::Series")
Severity: Minor
Found in lib/prawn/graph/chart_components/canvas.rb - About 25 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

Unused method argument - block. If it's necessary, use _ or _block as an argument name to indicate that it won't be used.
Open

        def initialize(series, prawn, options = {}, &block)

This cop checks for unused method arguments.

Example:

# bad

def some_method(used, unused, _unused_but_allowed)
  puts used
end

Example:

# good

def some_method(used, _unused, _unused_but_allowed)
  puts used
end

There are no issues that match your filters.

Category
Status