bbatsov/rubocop

View on GitHub

Showing 644 of 684 total issues

Method on_def has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def on_def(node)
          return if node.arguments.empty?

          last_argument = node.last_argument
          return if expected_block_forwarding_style?(node, last_argument)
Severity: Minor
Found in lib/rubocop/cop/naming/block_forwarding.rb - About 45 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 override_enabled_for_disabled_departments has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def override_enabled_for_disabled_departments(base_hash, derived_hash)
      cops_to_disable = derived_hash.each_key.with_object([]) do |key, cops|
        next unless disabled?(derived_hash, key)

        cops.concat(base_hash.keys.grep(Regexp.new("^#{key}/")))
Severity: Minor
Found in lib/rubocop/config_loader_resolver.rb - About 45 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 pending_cops has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def pending_cops
      keys.each_with_object([]) do |qualified_cop_name, pending_cops|
        department = department_of(qualified_cop_name)
        next if department && department['Enabled'] == false

Severity: Minor
Found in lib/rubocop/config.rb - About 45 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 inherited_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def inherited_file(path, inherit_from, file)
      if remote_file?(inherit_from)
        # A remote configuration, e.g. `inherit_from: http://example.com/rubocop.yml`.
        RemoteConfig.new(inherit_from, File.dirname(path))
      elsif Pathname.new(inherit_from).absolute?
Severity: Minor
Found in lib/rubocop/config_loader_resolver.rb - About 45 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 format_table_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def format_table_value(val)
    value =
      case val
      when Array
        if val.empty?
Severity: Minor
Found in lib/rubocop/cops_documentation_generator.rb - About 45 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 register_offense has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def register_offense(block_argument, node)
          add_offense(block_argument, message: format(MSG, style: style)) do |corrector|
            if style == :anonymous
              corrector.replace(block_argument, '&')

Severity: Minor
Found in lib/rubocop/cop/naming/block_forwarding.rb - About 45 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 load has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def load
      # Don't use `::Kernel.require(target)` to prevent the following error:
      # https://github.com/rubocop/rubocop/issues/10893
      require(target)
    rescue ::LoadError => e
Severity: Minor
Found in lib/rubocop/feature_loader.rb - About 45 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_and has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def on_and(node)
          all_operands = collect_operands(node, [])
          operand_groups = all_operands.group_by { |operand| receiver_name_as_key(operand, +'') }

          operand_groups.each_value do |grouped_operands|
Severity: Minor
Found in lib/rubocop/cop/lint/safe_navigation_consistency.rb - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
Open

        def on_if(node)
          previous = []
          while node.if? || node.elsif?
            condition = node.condition
            add_offense(condition) if previous.include?(condition)
Severity: Minor
Found in lib/rubocop/cop/lint/duplicate_elsif_condition.rb - About 45 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_csend has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def on_csend(node)
          unless assume_receiver_instance_exists?(node.receiver)
            return unless check?(node) && allowed_method?(node.method_name)
            return if respond_to_nil_specific_method?(node)
          end
Severity: Minor
Found in lib/rubocop/cop/lint/redundant_safe_navigation.rb - About 45 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 process_multiple_assignment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def process_multiple_assignment(masgn_node)
            mlhs_node, mrhs_node = *masgn_node

            mlhs_node.children.each_with_index do |lhs_node, index|
              next unless ASSIGNMENT_TYPES.include?(lhs_node.type)
Severity: Minor
Found in lib/rubocop/cop/lint/useless_setter_call.rb - About 45 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 autocorrect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def autocorrect(corrector, node, condition, replacement, guard)
          corrector.replace(node.loc.keyword.join(condition.source_range), replacement)

          if_branch = node.if_branch
          else_branch = node.else_branch
Severity: Minor
Found in lib/rubocop/cop/style/guard_clause.rb - About 45 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 same_conditions_node_different_branch? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def same_conditions_node_different_branch?(variable, outer_local_variable)
          variable_node = variable_node(variable)
          return false unless node_or_its_ascendant_conditional?(variable_node)

          outer_local_variable_node =
Severity: Minor
Found in lib/rubocop/cop/lint/shadowing_outer_local_variable.rb - About 45 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_percent_literal has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def on_percent_literal(node)
          return unless contains_quotes_or_commas?(node)

          add_offense(node) do |corrector|
            node.each_value do |value|
Severity: Minor
Found in lib/rubocop/cop/lint/percent_string_array.rb - About 45 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_block has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def on_block(node)
          return if target_ruby_version >= 3.0
          return unless node.body
          return unless unsorted_dir_loop?(node.send_node)

Severity: Minor
Found in lib/rubocop/cop/lint/non_deterministic_require_order.rb - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          return unless (receiver = node.receiver)
          return unless receiver.receiver&.const_type? && receiver.receiver.short_name == :Dir
          return unless GLOB_METHODS.include?(receiver.method_name)
          return if multiple_argument?(receiver)
Severity: Minor
Found in lib/rubocop/cop/lint/redundant_dir_glob_sort.rb - About 45 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 message has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def message(node)
          if require_parentheses_when_complex?
            command = parenthesized?(node.condition) ? 'Only use' : 'Use'
            format(MSG_COMPLEX, command: command)
          else
Severity: Minor
Found in lib/rubocop/cop/style/ternary_parentheses.rb - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          read, write, excepts, timeout = *io_select(node)
          return if excepts && !excepts.children.empty?
          return unless scheduler_compatible?(read, write) || scheduler_compatible?(write, read)

Severity: Minor
Found in lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb - About 45 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_new_investigation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def on_new_investigation
          processed_source.diagnostics.each do |diagnostic|
            next unless diagnostic.reason == :ambiguous_prefix

            offense_node = find_offense_node_by(diagnostic)
Severity: Minor
Found in lib/rubocop/cop/lint/ambiguous_operator.rb - About 45 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_block_pass has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def on_block_pass(node)
          return if target_ruby_version >= 3.0
          return unless method_require?(node)
          return unless unsorted_dir_pass?(node.parent)

Severity: Minor
Found in lib/rubocop/cop/lint/non_deterministic_require_order.rb - About 45 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