bbatsov/rubocop

View on GitHub

Showing 647 of 687 total issues

Method find_class_or_module has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        def find_class_or_module(node, namespace)
          return nil unless node

          name = namespace.pop

Severity: Minor
Found in lib/rubocop/cop/naming/file_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 on_return has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        def on_return(node)
          # Check Lint/NonLocalExitFromIterator first before this cop
          node.each_ancestor(:block, :def, :defs) do |n|
            break if scoped_node?(n)

Severity: Minor
Found in lib/rubocop/cop/style/return_nil.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 14 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          return unless struct_new(node)

          node.arguments.each_with_index do |arg, index|
            # Ignore if the first argument is a class name
Severity: Minor
Found in lib/rubocop/cop/lint/struct_new_override.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 shadowing_assignment has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        def shadowing_assignment(argument)
          return unless argument.referenced?

          assignment_without_argument_usage(argument) do |node, location_known|
            assignment_without_usage_pos = node.source_range.begin_pos
Severity: Minor
Found in lib/rubocop/cop/lint/shadowed_argument.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_return has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        def on_return(return_node)
          return if return_value?(return_node)

          return_node.each_ancestor(:block, :def, :defs) do |node|
            break if scoped_node?(node)
Severity: Minor
Found in lib/rubocop/cop/lint/non_local_exit_from_iterator.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 bad_method? has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        def bad_method?(method_name, block)
          if active_support_extensions_enabled?
            bad_method_with_active_support?(block) do |key_arg, send_node|
              if send_node.method?(:in?) && send_node.receiver&.source != key_arg.source
                return false
Severity: Minor
Found in lib/rubocop/cop/style/hash_except.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 add_safe_nav_to_all_methods_in_chain has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        def add_safe_nav_to_all_methods_in_chain(corrector,
                                                 start_method,
                                                 method_chain)
          start_method.each_ancestor do |ancestor|
            break unless %i[send block].include?(ancestor.type)
Severity: Minor
Found in lib/rubocop/cop/style/safe_navigation.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 unsafe_method_used? has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        def unsafe_method_used?(method_chain, method)
          return true if unsafe_method?(method)

          method.each_ancestor(:send).any? do |ancestor|
            break true unless config.for_cop('Lint/SafeNavigationChain')['Enabled']
Severity: Minor
Found in lib/rubocop/cop/style/safe_navigation.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_and has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        def on_and(node) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
          collect_and_clauses(node).each do |(lhs, lhs_operator_range), (rhs, _rhs_operator_range)|
            lhs_not_nil_check = not_nil_check?(lhs)
            lhs_receiver = lhs_not_nil_check || lhs
            rhs_receiver = find_matching_receiver_invocation(strip_begin(rhs), lhs_receiver)
Severity: Minor
Found in lib/rubocop/cop/style/safe_navigation.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_expressions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        def check_expressions(node, expressions, insert_position)
          return if expressions.any?(&:nil?)

          inserted_expression = false

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

      def expect_correction(correction, loop: true, source: nil)
        if source
          expected_annotations = parse_annotations(source, raise_error: false)
          @processed_source = parse_processed_source(expected_annotations.plain_source)
          _investigate(cop, @processed_source)
Severity: Minor
Found in lib/rubocop/rspec/expect_offense.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_end_line has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def find_end_line(node)
        if node.if_type?
          if node.else?
            node.loc.else.line
          elsif node.ternary?
Severity: Minor
Found in lib/rubocop/cop/mixin/comments_help.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 match_path? has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def match_path?(pattern, path)
      case pattern
      when String
        matches =
          if pattern == path
Severity: Minor
Found in lib/rubocop/path_util.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_cop_config_value has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def check_cop_config_value(hash, parent = nil)
      hash.each do |key, value|
        check_cop_config_value(value, key) if value.is_a?(Hash)

        next unless CONFIG_CHECK_KEYS.include?(key) && value.is_a?(String)
Severity: Minor
Found in lib/rubocop/config_validator.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 validate_enforced_styles has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_enforced_styles(valid_cop_names) # rubocop:todo Metrics/AbcSize
      valid_cop_names.each do |name|
        styles = @config[name].select { |key, _| key.start_with?('Enforced') }

        styles.each do |style_name, style|
Severity: Minor
Found in lib/rubocop/config_validator.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 configuration_from_file has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def configuration_from_file(config_file, check: true)
        return default_configuration if config_file == DEFAULT_FILE

        config = load_file(config_file, check: check)
        config.validate_after_resolution if check
Severity: Minor
Found in lib/rubocop/config_loader.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 register_offense has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def register_offense(node, message, replacement) # rubocop:disable Metrics/AbcSize
        add_offense(node.value, message: message) do |corrector|
          corrector.replace(node, replacement)

          next unless (def_node = def_node_that_require_parentheses(node))
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_new_investigation has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def on_new_investigation
          return if processed_source.blank?

          dependency_declarations(processed_source.ast)
            .each_cons(2) do |previous, current|
Severity: Minor
Found in lib/rubocop/cop/gemspec/ordered_dependencies.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 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

Severity
Category
Status
Source
Language