rubocop-hq/rubocop

View on GitHub
lib/rubocop/cop/lint/useless_rescue.rb

Summary

Maintainability
A
50 mins
Test Coverage
A
100%

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

        def use_exception_variable_in_ensure?(resbody_node)
          return false unless (exception_variable = resbody_node.exception_variable)
          return false unless (ensure_node = resbody_node.each_ancestor(:ensure).first)
          return false unless (ensure_body = ensure_node.body)

Severity: Minor
Found in lib/rubocop/cop/lint/useless_rescue.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

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

        def only_reraising?(resbody_node)
          return false if use_exception_variable_in_ensure?(resbody_node)

          body = resbody_node.body

Severity: Minor
Found in lib/rubocop/cop/lint/useless_rescue.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

There are no issues that match your filters.

Category
Status