rubocop-hq/rubocop

View on GitHub
lib/rubocop/cop/style/ternary_parentheses.rb

Summary

Maintainability
A
2 hrs
Test Coverage
A
100%

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

        def offense?(node)
          condition = node.condition

          if safe_assignment?(condition)
            !safe_assignment_allowed?
Severity: Minor
Found in lib/rubocop/cop/style/ternary_parentheses.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

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

        def message(node)
          if require_parentheses_when_complex?
            command = parenthesized?(node.condition) ? 'Only use' : 'Use'
            format(MSG_COMPLEX, command: command)
          else
Severity: Minor
Found in lib/rubocop/cop/style/ternary_parentheses.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

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

        def condition_as_parenthesized_one_line_pattern_matching?(condition)
          return false unless condition.parenthesized_call?
          return false unless (first_child = condition.children.first)

          if target_ruby_version >= 3.0
Severity: Minor
Found in lib/rubocop/cop/style/ternary_parentheses.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