bbatsov/rubocop

View on GitHub

Showing 644 of 684 total issues

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

      def roundup_relevant_cops(processed_source)
        cops.select do |cop|
          next true if processed_source.comment_config.cop_opted_in?(cop)
          next false if cop.excluded_file?(processed_source.file_path)
          next false unless @registry.enabled?(cop, @config)
Severity: Minor
Found in lib/rubocop/cop/team.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
          last_line = last_line(processed_source)

          processed_source.raw_source.each_line.with_index do |line, index|
            break if index >= last_line
Severity: Minor
Found in lib/rubocop/cop/layout/end_of_line.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 node.arguments.empty?
          return unless node.arguments.all?(&:array_type?)

          offense = offense_range(node)
Severity: Minor
Found in lib/rubocop/cop/style/concat_array_literals.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 ignored_literal_ranges has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def ignored_literal_ranges(ast)
          # which lines start inside a string literal?
          return [] if ast.nil?

          ast.each_node(:str, :dstr, :array).with_object(Set.new) do |literal, ranges|
Severity: Minor
Found in lib/rubocop/cop/layout/line_continuation_spacing.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 exclusive_with? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

          def exclusive_with?(other)
            return false unless other
            return false if may_jump_to_other_branch?

            other.each_ancestor(include_self: true) do |other_ancestor|
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 validate_cop_list has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def validate_cop_list(names)
        return unless names

        cop_names = Cop::Registry.global.names
        departments = Cop::Registry.global.departments.map(&:to_s)
Severity: Minor
Found in lib/rubocop/options.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 complexity_score_for has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def complexity_score_for(node)
          case node.type
          when :case
            # If cond is nil, that means each when has an expression that
            # evaluates to true or false. It's just an alternative to
Severity: Minor
Found in lib/rubocop/cop/metrics/perceived_complexity.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_check_options has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def add_check_options(opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
      section(opts, 'Basic Options') do # rubocop:disable Metrics/BlockLength
        option(opts, '-l', '--lint') do
          @options[:only] ||= []
          @options[:only] << 'Lint'
Severity: Minor
Found in lib/rubocop/options.rb - About 1 hr to fix

    Method cache_root_dir_from_config has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def cache_root_dir_from_config
              CacheConfig.root_dir do
                # `RuboCop::ConfigStore` has heavy dependencies, this is a lightweight implementation
                # so that only the necessary `CacheRootDirectory` can be obtained.
                config_path = ConfigFinder.find_config_path(Dir.pwd)
    Severity: Minor
    Found in lib/rubocop/server/cache.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 properties has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def properties(cop)
        header = [
          'Enabled by default', 'Safe', 'Supports autocorrection', 'Version Added',
          'Version Changed'
        ]
    Severity: Minor
    Found in lib/rubocop/cops_documentation_generator.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_excludes_from_higher_level has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_excludes_from_higher_level(highest_config)
          return unless highest_config.for_all_cops['Exclude']
    
          excludes = for_all_cops['Exclude'] ||= []
          highest_config.for_all_cops['Exclude'].each do |path|
    Severity: Minor
    Found in lib/rubocop/config.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 gem_config_path has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def gem_config_path(gem_name, relative_config_path)
          if defined?(Bundler)
            begin
              gem = Bundler.load.specs[gem_name].first
              gem_path = gem.full_gem_path if gem
    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 extension_versions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.extension_versions(env)
          features = config_for_pwd(env).loaded_features.sort
          features.filter_map do |loaded_feature|
            next unless (match = loaded_feature.match(/rubocop-(?<feature>.*)/))
    
    
    Severity: Minor
    Found in lib/rubocop/version.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_class has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def on_class(node)
              return unless (module_node = node.parent) && node.parent_class
    
              description_beginning = first_comment_line(module_node)
              return unless description_beginning
    Severity: Minor
    Found in lib/rubocop/cop/internal_affairs/cop_description.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_multiline_collection_that_could_be_broken_up? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def contained_by_multiline_collection_that_could_be_broken_up?(node)
            node.each_ancestor.find do |ancestor|
              if (ancestor.hash_type? || ancestor.array_type?) &&
                 breakable_collection?(ancestor, ancestor.children)
                return children_could_be_broken_up?(ancestor.children)
    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 range_size has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def range_size(range_node)
              vals = range_node.to_a
              return :unknown unless vals.all? { |val| val.nil? || val.int_type? }
    
              low, high = vals.map { |val| val.nil? ? 0 : val.children[0] }
    Severity: Minor
    Found in lib/rubocop/cop/style/sample.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 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def on_new_investigation
              processed_source.diagnostics.each do |diagnostic|
                if target_ruby_version >= 3.0
                  next unless diagnostic.reason == :ambiguous_regexp
                else
    Severity: Minor
    Found in lib/rubocop/cop/lint/ambiguous_regexp_literal.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 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def on_if(node)
              return unless if_else?(node)
              return unless (condition = unwrap_begin_nodes(node.condition))
              return if double_negation?(condition) || !negated_condition?(condition)
    
    
    Severity: Minor
    Found in lib/rubocop/cop/style/negated_if_else_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 single_argument has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def single_argument(node)
              first_argument = node.first_argument
              if first_argument.hash_type?
                register_offense_for_hash(node, first_argument)
              elsif first_argument.splat_type?
    Severity: Minor
    Found in lib/rubocop/cop/style/hash_conversion.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 omit_parentheses has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

              def omit_parentheses(node) # rubocop:disable Metrics/PerceivedComplexity
                return unless node.parenthesized?
                return if inside_endless_method_def?(node)
                return if require_parentheses_for_hash_value_omission?(node)
                return if syntax_like_method_call?(node)

    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