rubocop-hq/rubocop

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

Summary

Maintainability
C
1 day
Test Coverage
A
100%

Method find_offense_message has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

        def find_offense_message(begin_node, node)
          return 'a keyword' if keyword_with_redundant_parentheses?(node)
          return 'a literal' if disallowed_literal?(begin_node, node)
          return 'a variable' if node.variable?
          return 'a constant' if node.const_type?
Severity: Minor
Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 3 hrs 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

Class RedundantParentheses has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

      class RedundantParentheses < Base
        include Parentheses
        extend AutoCorrector

        ALLOWED_NODE_TYPES = %i[and or send splat kwsplat].freeze
Severity: Minor
Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 3 hrs to fix

    Avoid too many return statements within this method.
    Open

                return 'an expression'
    Severity: Major
    Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return if ALLOWED_NODE_TYPES.include?(begin_node.parent&.type)
      Severity: Major
      Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return if node.semantic_operator? && begin_node.parent
        Severity: Major
        Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return if node.multiline? && allow_in_multiline_conditions?
          Severity: Major
          Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return unless begin_node.parent.nil?
            Severity: Major
            Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                        return 'an interpolated expression' if interpolation?(begin_node)
              Severity: Major
              Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return if begin_node.parent&.if_type? && begin_node.parent&.ternary?
                Severity: Major
                Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                            return if begin_node.chained?
                  Severity: Major
                  Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

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

                            def keyword_with_redundant_parentheses?(node)
                              return false unless node.keyword?
                              return true if node.special_keyword?
                    
                              args = *node
                    Severity: Minor
                    Found in lib/rubocop/cop/style/redundant_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