rubocop-hq/rubocop

View on GitHub
lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb

Summary

Maintainability
C
1 day
Test Coverage
A
100%

Class MethodCallWithArgsParentheses has 35 methods (exceeds 20 allowed). Consider refactoring.
Open

      class MethodCallWithArgsParentheses
        # Style omit_parentheses
        # rubocop:disable Metrics/ModuleLength, Metrics/CyclomaticComplexity
        module OmitParentheses
          TRAILING_WHITESPACE_REGEX = /\s+\Z/.freeze

    Method omit_parentheses has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

              def omit_parentheses(node) # rubocop:disable Metrics/PerceivedComplexity
                return unless node.parenthesized?
                return if inside_endless_method_def?(node)
                return if require_parentheses_for_hash_value_omission?(node)
                return if syntax_like_method_call?(node)

    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

    Avoid too many return statements within this method.
    Open

                return if legitimate_call_with_parentheses?(node)

      Avoid too many return statements within this method.
      Open

                  return if super_call_without_arguments?(node)

        Avoid too many return statements within this method.
        Open

                    return if allowed_camel_case_method_call?(node)

          Avoid too many return statements within this method.
          Open

                      return if allowed_string_interpolation_method_call?(node)

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

                      def assignment_in_condition?(node)
                        parent = node.parent
                        return false unless parent
            
                        grandparent = parent.parent

            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 call_in_logical_operators? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                      def call_in_logical_operators?(node)
                        parent = node.parent&.block_type? ? node.parent.parent : node.parent
                        return false unless parent
            
                        logical_operator?(parent) ||

            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 allowed_chained_call_with_parentheses? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                      def allowed_chained_call_with_parentheses?(node)
                        return false unless cop_config['AllowParenthesesInChaining']
            
                        previous = node.descendants.first
                        return false unless previous&.send_type?

            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