bbatsov/rubocop

View on GitHub

Showing 687 of 687 total issues

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

        def groupable_accessor?(node)
          return true unless (previous_expression = node.left_siblings.last)

          # Accessors with Sorbet `sig { ... }` blocks shouldn't be groupable.
          if previous_expression.block_type?
Severity: Minor
Found in lib/rubocop/cop/style/accessor_grouping.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 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 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 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 run has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run(args = ARGV)
      @options, paths = Options.new.parse(args)
      @env = Environment.new(@options, @config_store, paths)

      profile_if_needed do
Severity: Minor
Found in lib/rubocop/cli.rb - About 1 hr to fix

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

          def aligned_with_line?(line_nos, range, indent = nil)
            line_nos.each do |lineno|
              next if aligned_comment_lines.include?(lineno + 1)
    
              line = processed_source.lines[lineno]
    Severity: Minor
    Found in lib/rubocop/cop/mixin/preceding_following_alignment.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 relevant_assignment_lines has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def relevant_assignment_lines(line_range)
            result                        = []
            original_line_indent          = processed_source.line_indentation(line_range.first)
            relevant_line_indent_at_level = true
    
    
    Severity: Minor
    Found in lib/rubocop/cop/mixin/preceding_following_alignment.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 11 (exceeds 5 allowed). Consider refactoring.
    Open

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

        def resolve_inheritance(path, hash, file, debug) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
          inherited_files = Array(hash['inherit_from'])
          base_configs(path, inherited_files, file)
            .each_with_index.reverse_each do |base_config, index|
            override_department_setting_for_cops(base_config, hash)
    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

    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

    Method on_new_investigation has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

            def on_new_investigation
              processed_source.comments.each do |comment|
                next if comment.text !~ DISABLE_COMMENT_FORMAT
    
                offset = Regexp.last_match(1).length
    Severity: Minor
    Found in lib/rubocop/cop/migration/department_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 def_node_that_require_parentheses has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def def_node_that_require_parentheses(node)
            last_pair = node.parent.pairs.last
            return unless last_pair.key.source == last_pair.value.source
            return unless (dispatch_node = find_ancestor_method_dispatch_node(node))
            return if dispatch_node.assignment_method?
    Severity: Minor
    Found in lib/rubocop/cop/mixin/hash_shorthand_syntax.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 11 (exceeds 5 allowed). Consider refactoring.
    Open

            def on_send(node)
              return if target_ruby_version < 2.6 && node.method?(:filter)
              return unless (block_node = node.block_node)
              return if block_node.body&.begin_type?
              return if receiver_allowed?(block_node.receiver)
    Severity: Minor
    Found in lib/rubocop/cop/style/select_by_regexp.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 keyword_arg_same? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

            def keyword_arg_same?(def_arg, super_arg)
              return false unless def_arg.kwarg_type? || def_arg.kwoptarg_type?
              return false unless (pair_node = super_arg).pair_type?
              return false unless (sym_node = pair_node.key).sym_type?
              return false unless (lvar_node = pair_node.value).lvar_type?
    Severity: Minor
    Found in lib/rubocop/cop/style/super_arguments.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