rubocop-hq/rubocop

View on GitHub

Showing 628 of 670 total issues

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

        def find_parent_not_enumerable(node)
          return unless (parent = node.parent)

          if parent.pair_type? || parent.hash_type? || parent.array_type?
            find_parent_not_enumerable(parent)
Severity: Minor
Found in lib/rubocop/cop/style/double_negation.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 correct_to_endless? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def correct_to_endless?(body_node)
          return false if target_ruby_version < 3.0
          return false if disallow_endless_method_style?
          return false unless body_node
          return false if body_node.parent.assignment_method? ||
Severity: Minor
Found in lib/rubocop/cop/style/single_line_methods.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 on_send has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          return if node.method?(:safe_load) && target_ruby_version <= 2.7
          return unless (file_path, rest_arguments = yaml_file_read?(node))

          range = offense_range(node)
Severity: Minor
Found in lib/rubocop/cop/style/yaml_file_read.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 else_source has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def else_source(else_branch, arithmetic_operation) # rubocop:disable Metrics/AbcSize
          if arithmetic_operation
            "#{else_branch.first_argument.source})"
          elsif branches_have_method?(else_branch.parent)
            else_source_if_has_method(else_branch)
Severity: Minor
Found in lib/rubocop/cop/style/redundant_condition.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 on_send has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          return unless node.self_receiver? && regular_method_call?(node)
          return if node.parent&.mlhs_type?
          return if allowed_send_node?(node)
          return if it_method_in_block?(node)
Severity: Minor
Found in lib/rubocop/cop/style/redundant_self.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 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

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

        def token_after_last_string(successor, base_index)
          index = base_index + 3
          if successor.type == COMPLEX_STRING_BEGIN_TOKEN
            ends_to_find = 1
            while ends_to_find.positive?
Severity: Minor
Found in lib/rubocop/cop/style/line_end_concatenation.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 delimiter? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def delimiter?(node, char)
          return false if heredoc?(node)

          if literal_in_interpolated_or_multiline_string?(node) || percent_array_literal?(node)
            return delimiter?(node.parent, char)
Severity: Minor
Found in lib/rubocop/cop/style/redundant_string_escape.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 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 right_hand_operand has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def right_hand_operand(node, left_hand_keyword)
          condition = node.condition

          expr = if condition.send_type? && !condition.arguments.empty? &&
                    !condition.operator_method?
Severity: Minor
Found in lib/rubocop/cop/style/nested_modifier.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 multi_argument has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def multi_argument(node)
          if node.arguments.count.odd?
            add_offense(node, message: MSG_LITERAL_MULTI_ARG)
          else
            add_offense(node, message: MSG_LITERAL_MULTI_ARG) do |corrector|
Severity: Minor
Found in lib/rubocop/cop/style/hash_conversion.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 argument_with_operator? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def argument_with_operator?(argument)
          return true if ARGUMENT_WITH_OPERATOR_TYPES.include?(argument.type)
          return false unless argument.hash_type?
          return false unless (node = argument.children.first)

Severity: Minor
Found in lib/rubocop/cop/style/redundant_condition.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 on_if has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_if(node)
          return unless node.modifier_form? && node.body.if_type?

          add_offense(node.loc.keyword, message: format(MSG, keyword: node.keyword)) do |corrector|
            keyword = node.if? ? 'if' : 'unless'
Severity: Minor
Found in lib/rubocop/cop/style/if_unless_modifier_of_if_unless.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 main_node_offense has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def main_node_offense(node)
          node.masgn_type? ? (mlhs_node, right = *node) : mlhs_node = node

          variables = *mlhs_node
          first_offense = find_first_offense(variables)
Severity: Minor
Found in lib/rubocop/cop/style/trailing_underscore_variable.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 on_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_hash(node)
          pairs = node.pairs

          return if pairs.empty?

Severity: Minor
Found in lib/rubocop/cop/style/hash_syntax.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 expand_elsif has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def expand_elsif(node, elsif_branches = [])
          return [] if node.nil? || !node.if_type? || !node.elsif?

          elsif_branches << node.if_branch

Severity: Minor
Found in lib/rubocop/cop/style/conditional_assignment.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 on_send has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          # Classes should not redefine eval, but in case one does, it shouldn't
          # register an offense. Only `eval` without a receiver and `Kernel.eval`
          # are considered.
          return if node.method?(:eval) && !valid_eval_receiver?(node.receiver)
Severity: Minor
Found in lib/rubocop/cop/style/eval_with_location.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 offending_range has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def offending_range(node, lhs, rhs, given_style)
          return false unless begins_its_line?(rhs)
          return false if not_for_this_cop?(node)

          @base = alignment_base(node, rhs, given_style)
Severity: Minor
Found in lib/rubocop/cop/layout/multiline_method_call_indentation.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 check_modifier has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def check_modifier(send_node, end_range)
          offset = column_offset_between(send_node.source_range, end_range)

          @column_delta = expected_indent_offset - offset
          if @column_delta.zero?
Severity: Minor
Found in lib/rubocop/cop/layout/access_modifier_indentation.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 on_send has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          return unless node.attribute_accessor?
          return if next_line_empty?(node.last_line)
          return if next_line_empty_or_enable_directive_comment?(node.last_line)

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

Severity
Category
Status
Source
Language