rubocop-hq/rubocop

View on GitHub

Showing 614 of 652 total issues

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

        def offense?(node)
          condition = node.condition

          if safe_assignment?(condition)
            !safe_assignment_allowed?
Severity: Minor
Found in lib/rubocop/cop/style/ternary_parentheses.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 ineffective_modifier has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def ineffective_modifier(node, ignored_methods = nil, modifier = nil, &block)
          node.each_child_node do |child|
            case child.type
            when :send
              modifier = child if access_modifier?(child)
Severity: Minor
Found in lib/rubocop/cop/lint/ineffective_access_modifier.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 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 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

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

        def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
          return unless (body = node.body)
          return unless node.arguments.empty_and_without_delimiters?

          if body.send_type? && deprecated_it_method?(body)
Severity: Minor
Found in lib/rubocop/cop/lint/it_without_arguments_in_block.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_branches has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def check_branches(node, branches)
          # return if any branch is empty. An empty branch can be an `if`
          # without an `else` or a branch that contains only comments.
          return if branches.any?(&:nil?)

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

          def each_escape(node)
            node.parsed_tree&.traverse&.reduce(0) do |char_class_depth, (event, expr)|
              yield(expr.text[1], expr.ts, !char_class_depth.zero?) if expr.type == :escape

              if expr.type == :set
Severity: Minor
Found in lib/rubocop/cop/style/redundant_regexp_escape.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_escape has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

          def each_escape(node)
            node.parsed_tree&.traverse&.reduce(0) do |char_class_depth, (event, expr)|
              yield(expr.text[1], expr.start_index, !char_class_depth.zero?) if expr.type == :escape

              if expr.type == :set
Severity: Minor
Found in lib/rubocop/cop/style/redundant_regexp_escape.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_new_investigation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def on_new_investigation
          processed_source.sorted_tokens.each_cons(2) do |token1, token2|
            next unless token2.comment?
            next unless same_line?(token1, token2)
            next unless token1.pos.end == token2.pos.begin
Severity: Minor
Found in lib/rubocop/cop/layout/space_before_comment.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 correct_extraneous_space has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def correct_extraneous_space(tokens)
          tokens.each_cons(2) do |token1, token2|
            next unless parens?(token1, token2)

            # If the second token is a comment, that means that a line break
Severity: Minor
Found in lib/rubocop/cop/layout/space_inside_parens.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 of has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def self.of(target_node, scope: nil)
          ([target_node] + target_node.ancestors).each do |node|
            return nil unless node.parent
            return nil unless scope.include?(node)

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

        def offense_range(node)
          if reject_method_with_block_pass?(node) || grep_v_with_nil?(node)
            range(node, node)
          else
            block_node = node.parent
Severity: Minor
Found in lib/rubocop/cop/style/collection_compact.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_nesting_level has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def check_nesting_level(node, max, current_level)
          if consider_node?(node)
            current_level += 1 unless node.if_type? && node.elsif?
            if current_level > max
              self.max = current_level
Severity: Minor
Found in lib/rubocop/cop/metrics/block_nesting.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 contained_by_breakable_collection_on_same_line? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def contained_by_breakable_collection_on_same_line?(node)
        node.each_ancestor.find do |ancestor|
          # Ignore ancestors on different lines.
          break if ancestor.first_line != node.first_line

Severity: Minor
Found in lib/rubocop/cop/mixin/check_line_breakable.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 override_department_setting_for_cops has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def override_department_setting_for_cops(base_hash, derived_hash)
      derived_hash.each_key do |key|
        next unless key =~ %r{(.*)/.*}

        department = Regexp.last_match(1)
Severity: Minor
Found in lib/rubocop/config_loader_resolver.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