rubocop-hq/rubocop

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

Summary

Maintainability
B
4 hrs
Test Coverage
A
96%

Class CaseLikeIf has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

      class CaseLikeIf < Base
        include RangeHelp
        include MinBranchesCount
        extend AutoCorrector

Severity: Minor
Found in lib/rubocop/cop/style/case_like_if.rb - About 2 hrs to fix

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

            def on_if(node)
              return unless should_check?(node)
    
              target = find_target(node.condition)
              return unless target
    Severity: Minor
    Found in lib/rubocop/cop/style/case_like_if.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 find_target_in_equality_node has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def find_target_in_equality_node(node)
              argument = node.first_argument
              receiver = node.receiver
              return unless argument && receiver
    
    
    Severity: Minor
    Found in lib/rubocop/cop/style/case_like_if.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 collect_conditions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def collect_conditions(node, target, conditions)
              condition =
                case node.type
                when :begin
                  return collect_conditions(node.children.first, target, conditions)
    Severity: Minor
    Found in lib/rubocop/cop/style/case_like_if.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 find_target has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def find_target(node)
              case node.type
              when :begin
                find_target(node.children.first)
              when :or
    Severity: Minor
    Found in lib/rubocop/cop/style/case_like_if.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