ManageIQ/manageiq-ui-classic

View on GitHub
app/controllers/application_controller/report_data_additional_options.rb

Summary

Maintainability
A
45 mins
Test Coverage
A
97%

Method from_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.from_options(options)
      additional_options = new
      additional_options.named_scope = options[:named_scope]
      additional_options.gtl_dbname = options[:gtl_dbname]
      additional_options.with_model(options[:model]) if options[:model]
Severity: Minor
Found in app/controllers/application_controller/report_data_additional_options.rb - About 45 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

:filter member overrides Struct#filter and it may be unexpected.
Open

    :filter,

Checks unexpected overrides of the Struct built-in methods via Struct.new.

Example:

# bad
Bad = Struct.new(:members, :clone, :count)
b = Bad.new([], true, 1)
b.members #=> [] (overriding `Struct#members`)
b.clone #=> true (overriding `Object#clone`)
b.count #=> 1 (overriding `Enumerable#count`)

# good
Good = Struct.new(:id, :name)
g = Good.new(1, "foo")
g.members #=> [:id, :name]
g.clone #=> #<struct good id="1," name="foo">
g.count #=&gt; 2</struct>

:display member overrides Struct#display and it may be unexpected.
Open

    :display,

Checks unexpected overrides of the Struct built-in methods via Struct.new.

Example:

# bad
Bad = Struct.new(:members, :clone, :count)
b = Bad.new([], true, 1)
b.members #=> [] (overriding `Struct#members`)
b.clone #=> true (overriding `Object#clone`)
b.count #=> 1 (overriding `Enumerable#count`)

# good
Good = Struct.new(:id, :name)
g = Good.new(1, "foo")
g.members #=> [:id, :name]
g.clone #=> #<struct good id="1," name="foo">
g.count #=&gt; 2</struct>

There are no issues that match your filters.

Category
Status