bbatsov/rubocop

View on GitHub

Showing 687 of 687 total issues

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

        def constant_result?(variable, operation, number)
          if number.to_s == '0'
            return 0 if operation == :*
            return 1 if operation == :**
          elsif number.to_s == '1'
Severity: Minor
Found in lib/rubocop/cop/lint/numeric_operation_with_constant_result.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 check has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def check(node, args)
        args.each do |arg|
          # Argument names might be "_" or prefixed with "_" to indicate they
          # are unused. Trim away this prefix and only analyse the basename.
          name_child = arg.children.first
Severity: Minor
Found in lib/rubocop/cop/mixin/uncommunicative_name.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 most_left_indices has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def most_left_indices(grouped_operands)
          indices = { csend_in_and: nil, csend_in_or: nil, send_in_and: nil, send_in_or: nil }

          grouped_operands.each_with_index do |operand, index|
            indices[:csend_in_and] ||= index if operand_in_and?(operand) && operand.csend_type?
Severity: Minor
Found in lib/rubocop/cop/lint/safe_navigation_consistency.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 each_single_element_character_class has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def each_single_element_character_class(node)
          node.parsed_tree&.each_expression do |expr|
            next if expr.type != :set || expr.expressions.size != 1
            next if expr.negative?
            next if %i[set posixclass nonposixclass].include?(expr.expressions.first.type)
Severity: Minor
Found in lib/rubocop/cop/style/redundant_regexp_character_class.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 redundant_each_method has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def redundant_each_method(node)
          return if node.last_argument&.block_pass_type?

          if node.method?(:each) && !node.parent&.block_type?
            ancestor_node = node.each_ancestor(:send, :csend).detect do |ancestor|
Severity: Minor
Found in lib/rubocop/cop/style/redundant_each.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 on_block has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def on_block(node)
          return unless node.parent&.begin_type?
          return unless collection_looping_method?(node)
          return unless same_collection_looping_block?(node, node.left_sibling)
          return unless node.body && node.left_sibling.body
Severity: Minor
Found in lib/rubocop/cop/style/combinable_loops.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 on_block has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def on_block(node)
          return unless each_block_with_push?(node)

          dest_var = find_dest_var(node)

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

        def on_send(node)
          def_node = node.each_ancestor(:def, :defs).first
          return if def_node &&
                    (allowed_method?(def_node.method_name) ||
                    matches_allowed_pattern?(def_node.method_name))
Severity: Minor
Found in lib/rubocop/cop/style/class_equality_comparison.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 on_if has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def on_if(node)
          return if node.condition.block_type?

          traverse_node(node.condition) do |asgn_node|
            next :skip_children if skip_children?(asgn_node)
Severity: Minor
Found in lib/rubocop/cop/lint/assignment_in_condition.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 setup_subtasks has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def setup_subtasks(name, *args, &task_block) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
      namespace(name) do
        # rubocop:todo Naming/InclusiveLanguage
        task(:auto_correct, *args) do
          require 'rainbow'
Severity: Minor
Found in lib/rubocop/rake_task.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 each_missing_space has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def each_missing_space(tokens)
        tokens.each_cons(2) do |token1, token2|
          next unless kind(token1)
          next unless space_missing?(token1, token2)
          next unless space_required_before?(token2)
Severity: Minor
Found in lib/rubocop/cop/mixin/space_after_punctuation.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 argument_in_method_call has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def argument_in_method_call(node, kind) # rubocop:todo Metrics/CyclomaticComplexity
        node.each_ancestor(:send, :block).find do |a|
          # If the node is inside a block, it makes no difference if that block
          # is an argument in a method call. It doesn't count.
          break false if a.block_type?
Severity: Minor
Found in lib/rubocop/cop/mixin/multiline_expression_indentation.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 each_bad_cons has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def each_bad_cons(node)
          node.children.each_cons(2) do |child_node1, child_node2|
            # `'abc' 'def'` -> (dstr (str "abc") (str "def"))
            next unless string_literals?(child_node1, child_node2)
            next unless child_node1.last_line == child_node2.first_line
Severity: Minor
Found in lib/rubocop/cop/lint/implicit_string_concatenation.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 each_unsafe_regexp_range has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def each_unsafe_regexp_range(node)
          node.parsed_tree&.each_expression do |expr|
            next if skip_expression?(expr)

            range_pairs(expr).reject do |range_start, range_end|
Severity: Minor
Found in lib/rubocop/cop/lint/mixed_case_range.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 check_for_unused_assignments has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def check_for_unused_assignments(variable)
          return if variable.should_be_unused?

          variable.assignments.reverse_each do |assignment|
            assignment_node = assignment.node
Severity: Minor
Found in lib/rubocop/cop/lint/useless_assignment.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_consistent_parts has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def find_consistent_parts(grouped_operands)
          csend_in_and, csend_in_or, send_in_and, send_in_or = most_left_indices(grouped_operands)

          return if csend_in_and && csend_in_or && csend_in_and < csend_in_or

Severity: Minor
Found in lib/rubocop/cop/lint/safe_navigation_consistency.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 each_line_range has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def each_line_range(cop, line_ranges)
          line_ranges.each_with_index do |line_range, line_range_index|
            next if ignore_offense?(line_range)
            next if expected_final_disable?(cop, line_range)

Severity: Minor
Found in lib/rubocop/cop/lint/redundant_cop_disable_directive.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 redundant_feature? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def redundant_feature?(feature_name)
          feature_name == 'enumerator' ||
            (target_ruby_version >= 2.1 && feature_name == 'thread') ||
            (target_ruby_version >= 2.2 && RUBY_22_LOADED_FEATURES.include?(feature_name)) ||
            (target_ruby_version >= 2.5 && feature_name == 'pp' && !need_to_require_pp?) ||
Severity: Minor
Found in lib/rubocop/cop/lint/redundant_require_statement.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 each_redundantly_quantified_pair has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def each_redundantly_quantified_pair(node)
          seen = Set.new
          node.parsed_tree&.each_expression do |(expr)|
            next if seen.include?(expr) || !redundant_group?(expr) || !mergeable_quantifier(expr)

Severity: Minor
Found in lib/rubocop/cop/lint/redundant_regexp_quantifiers.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 on_hash has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def on_hash(node)
          return if node.pairs.empty? || node.pairs.any?(&:hash_rocket?)
          return unless (parent = node.parent)
          return unless parent.call_type? || parent.kwsplat_type?
          return unless mergeable?(parent)
Severity: Minor
Found in lib/rubocop/cop/style/redundant_double_splat_hash_braces.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

Severity
Category
Status
Source
Language