rubocop-hq/rubocop

View on GitHub

Showing 614 of 652 total issues

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

        def self.extension_versions(env)
          features = Util.silence_warnings do
            # Suppress any config issues when loading the config (ie. deprecations,
            # pending cops, etc.).
            env.config_store.unvalidated.for_pwd.loaded_features.sort
    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_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 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_def has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def on_def(node)
              return unless node.predicate_method?
              return if allowed_method?(node.method_name) || matches_allowed_pattern?(node.method_name)
              return unless (body = node.body)
    
    
    Severity: Minor
    Found in lib/rubocop/cop/style/return_nil_in_predicate_method_definition.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 on_new_investigation has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def on_new_investigation
              processed_source.comments.each_with_index do |comment, index|
                next unless first_comment_line?(processed_source.comments, index) ||
                            inline_comment?(comment)
    
    
    Severity: Minor
    Found in lib/rubocop/cop/style/comment_annotation.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 10 (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 on_send has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def on_send(node)
              inverse_candidate?(node) do |method_call, lhs, method, rhs|
                return unless inverse_methods.key?(method)
                return if negated?(node) || relational_comparison_with_safe_navigation?(method_call)
                return if part_of_ignored_node?(node)
    Severity: Minor
    Found in lib/rubocop/cop/style/inverse_methods.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 argument_newline? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def argument_newline?(node)
              node = node.to_a.last if node.assignment?
              return false if node.parenthesized_call?
    
              node = node.children.first if node.root? && node.begin_type?
    Severity: Minor
    Found in lib/rubocop/cop/style/redundant_line_continuation.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 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def on_block(node)
              each_with_object_block_candidate?(node) do |method, args, body|
                _, method_name, method_arg = *method
                return if simple_method_arg?(method_arg)
    
    
    Severity: Minor
    Found in lib/rubocop/cop/style/each_with_object.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 class_name has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def class_name(class_node, node)
              if class_name_method?(node.children.first.method_name)
                if (receiver = class_node.receiver) && class_name_method?(class_node.method_name)
                  return receiver.source
                end
    Severity: Minor
    Found in lib/rubocop/cop/style/class_equality_comparison.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 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def bad_method?(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 on_send has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def on_send(node)
              return unless node.receiver
    
              style_check?(node) do
                add_offense(node.loc.selector) do |corrector|
    Severity: Minor
    Found in lib/rubocop/cop/style/nil_comparison.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 preferred_method has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def preferred_method(operator, lhs, rhs, if_branch, else_branch)
              if lhs == if_branch && rhs == else_branch
                GRATER_OPERATORS.include?(operator) ? 'max' : 'min'
              elsif lhs == else_branch && rhs == if_branch
                LESS_OPERATORS.include?(operator) ? 'max' : 'min'
    Severity: Minor
    Found in lib/rubocop/cop/style/min_max_comparison.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