rubocop-hq/rubocop

View on GitHub

Showing 615 of 655 total issues

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

        def register_semicolon(line, column, after_expression, token_before_semicolon = nil)
          range = source_range(processed_source.buffer, line, column)

          add_offense(range) do |corrector|
            if after_expression
Severity: Minor
Found in lib/rubocop/cop/style/semicolon.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_module has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def on_module(node)
          return unless node.body&.begin_type?

          each_wrong_style(node.body.children) do |child_node|
            add_offense(child_node) do |corrector|
Severity: Minor
Found in lib/rubocop/cop/style/module_function.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 10 (exceeds 5 allowed). Consider refactoring.
Open

        def check(node, locations, begin_keyword = DO)
          locations.each do |loc|
            next unless node.loc.respond_to?(loc)

            range = node.loc.public_send(loc)
Severity: Minor
Found in lib/rubocop/cop/layout/space_around_keyword.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 setup_subtasks has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def setup_subtasks(name, *args, &task_block) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
      namespace(name) do
        # rubocop:todo Naming/InclusiveLanguage
        task(:auto_correct, *args) do
          require 'rainbow'
Severity: Minor
Found in lib/rubocop/rake_task.rb - About 1 hr to fix

    Method on_send has 26 lines of code (exceeds 25 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

      Method command has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def command
              command = 'rubocop --auto-gen-config'
      
              command += ' --auto-gen-only-exclude' if @options[:auto_gen_only_exclude]
      
      
      Severity: Minor
      Found in lib/rubocop/formatter/disabled_config_formatter.rb - About 55 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 profile_if_needed has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def profile_if_needed
            return yield unless @options[:profile]
      
            return STATUS_ERROR unless require_gem('stackprof')
      
      
      Severity: Minor
      Found in lib/rubocop/cli.rb - About 55 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 handle_disabled_by_default has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle_disabled_by_default(config, new_default_configuration)
            department_config = config.to_hash.reject { |cop| cop.include?('/') }
            department_config.each do |dept, dept_params|
              next unless dept_params['Enabled']
      
      
      Severity: Minor
      Found in lib/rubocop/config_loader_resolver.rb - About 55 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 partial_matcher! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def partial_matcher!(expected)
                lambda do |namespace|
                  while namespace
                    return match?(expected) if namespace.cbase_type?
      
      
      Severity: Minor
      Found in lib/rubocop/cop/naming/file_name.rb - About 55 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_str has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def on_str(node)
              # Constants like __FILE__ are handled as strings,
              # but don't respond to begin.
              return unless node.loc.respond_to?(:begin) && node.loc.begin
              return if part_of_ignored_node?(node)
      Severity: Minor
      Found in lib/rubocop/cop/mixin/string_help.rb - About 55 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 reject_conflicting_safe_settings has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def reject_conflicting_safe_settings
            @config.each do |name, cop_config|
              next unless cop_config.is_a?(Hash)
              next unless cop_config['Safe'] == false && cop_config['SafeAutoCorrect'] == true
      
      
      Severity: Minor
      Found in lib/rubocop/config_validator.rb - About 55 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 traverse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.traverse(tree, &on_duplicated)
            case tree
            when Psych::Nodes::Mapping
              tree.children.each_slice(2).with_object([]) do |(key, value), keys|
                exist = keys.find { |key2| key2.value == key.value }
      Severity: Minor
      Found in lib/rubocop/yaml_duplication_checker.rb - About 55 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 make_excludes_absolute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def make_excludes_absolute
            each_key do |key|
              @validator.validate_section_presence(key)
              next unless self[key]['Exclude']
      
      
      Severity: Minor
      Found in lib/rubocop/config.rb - About 55 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 shift_elements_for_heredoc_arg has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def shift_elements_for_heredoc_arg(node, elements, index)
              return index unless node.send_type? || node.array_type?
      
              heredoc_index = elements.index { |arg| arg.respond_to?(:heredoc?) && arg.heredoc? }
              return index unless heredoc_index
      Severity: Minor
      Found in lib/rubocop/cop/mixin/check_line_breakable.rb - About 55 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 find_version has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def find_version
              lock_file_path = bundler_lock_file_path
              return nil unless lock_file_path
      
              in_ruby_section = false
      Severity: Minor
      Found in lib/rubocop/target_ruby.rb - About 55 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 style_detected has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def style_detected(detected)
              return if no_acceptable_style?
      
              # This logic is more complex than it needs to be
              # to avoid allocating Arrays in the hot code path.
      Severity: Minor
      Found in lib/rubocop/cop/mixin/configurable_enforced_style.rb - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def on_new_investigation
                return if processed_source.blank?
      
                gem_declarations(processed_source.ast)
                  .each_cons(2) do |previous, current|
      Severity: Minor
      Found in lib/rubocop/cop/bundler/ordered_gems.rb - About 55 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_pair has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def on_pair(node)
              return if ignore_hash_shorthand_syntax?(node)
      
              hash_key_source = node.key.source
      
      
      Severity: Minor
      Found in lib/rubocop/cop/mixin/hash_shorthand_syntax.rb - About 55 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 receiver_name has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def receiver_name(receiver)
              if receiver.receiver && !receiver.receiver.const_type?
                return receiver_name(receiver.receiver)
              end
      
      
      Severity: Minor
      Found in lib/rubocop/cop/mixin/allowed_receivers.rb - About 55 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