autotelik/datashift_journey

View on GitHub
app/controllers/datashift_journey/state_jumper_controller.rb

Summary

Maintainability
A
1 hr
Test Coverage

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

      def build_and_display
        state =   params['state']
        factory = params['factory']

        plan = if factory
Severity: Minor
Found in app/controllers/datashift_journey/state_jumper_controller.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

Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Open

        if plan.state != state

Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

There are no issues that match your filters.

Category
Status