rubocop-hq/rubocop

View on GitHub

Showing 628 of 670 total issues

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

        def on_send(node)
          return unless node.arguments.size == 1 && node.first_argument.int_type?

          value = node.first_argument.value
          return unless [0, -1].include?(value)
Severity: Minor
Found in lib/rubocop/cop/style/array_first_last.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_send has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          return unless (block_node = node.block_node)
          return if block_node.body&.begin_type?
          return if receiver_allowed?(block_node.receiver)
          return unless (regexp_method_send_node = extract_send_node(block_node))
Severity: Minor
Found in lib/rubocop/cop/style/select_by_regexp.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_if has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def on_if(node)
          return if node.ternary? || node.unless?

          else_branch = node.else_branch

Severity: Minor
Found in lib/rubocop/cop/style/if_inside_else.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 add_forward_all_offenses has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def add_forward_all_offenses(node, send_classifications, forwardable_args)
          _rest_arg, _kwrest_arg, block_arg = *forwardable_args
          registered_block_arg_offense = false

          send_classifications.each do |send_node, _c, forward_rest, forward_kwrest, forward_block_arg| # rubocop:disable Layout/LineLength
Severity: Minor
Found in lib/rubocop/cop/style/arguments_forwarding.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_first_possible_offense has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def find_first_possible_offense(variables)
          variables.reduce(nil) do |offense, variable|
            break offense unless DISALLOW.include?(variable.type)

            var, = *variable
Severity: Minor
Found in lib/rubocop/cop/style/trailing_underscore_variable.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 unless processed_source.ast

          each_match_range(processed_source.ast.source_range, /(\\\n)/) do |range|
            next if require_line_continuation?(range)
Severity: Minor
Found in lib/rubocop/cop/style/redundant_line_continuation.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 code_length has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

          def code_length(node) # rubocop:disable Metrics/MethodLength
            if classlike_node?(node)
              classlike_code_length(node)
            elsif heredoc_node?(node)
              heredoc_length(node)
Severity: Minor
Found in lib/rubocop/cop/metrics/utils/code_length_calculator.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_if has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def on_if(node)
          return if correct_style?(node)
          return if multiple_statements_on_line?(node)

          if node.modifier_form? && (heredoc_node = last_heredoc_argument(node))
Severity: Minor
Found in lib/rubocop/cop/layout/empty_line_after_guard_clause.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 add_cop_selection_csv_option has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def add_cop_selection_csv_option(option, opts)
      option(opts, "--#{option} [COP1,COP2,...]") do |list|
        unless list
          message = "--#{option} argument should be [COP1,COP2,...]."

Severity: Minor
Found in lib/rubocop/options.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 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 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 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 final_pos has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def final_pos(src, pos, increment, continuations, newlines, whitespace)
Severity: Minor
Found in lib/rubocop/cop/mixin/range_help.rb - About 45 mins to fix

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

          def process_arguments(argv)
            server_arguments = delete_server_argument_from(argv)
    
            detach = !server_arguments.delete('--no-detach')
    
    
    Severity: Minor
    Found in lib/rubocop/server/cli.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 mark_assignments_as_referenced_in_loop has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def mark_assignments_as_referenced_in_loop(node)
            referenced_variable_names_in_loop, assignment_nodes_in_loop = find_variables_in_loop(node)
    
            referenced_variable_names_in_loop.each do |name|
              variable = variable_table.find_variable(name)
    Severity: Minor
    Found in lib/rubocop/cop/variable_force.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 cops_body has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def cops_body(cop, description, examples_objects, safety_objects, see_objects, pars) # rubocop:disable Metrics/AbcSize, Metrics/ParameterLists
    Severity: Minor
    Found in lib/rubocop/cops_documentation_generator.rb - About 45 mins to fix

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

              def on_block(node)
                return unless (described_class_arguments = described_class_subject?(node))
                return if described_class_arguments.count >= 2
      
                describe = find_describe_method_node(node)
      Severity: Minor
      Found in lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.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 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 on_or_asgn has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def on_or_asgn(node)
                lhs, _value = *node
                return unless lhs.ivasgn_type?
      
                method_node, method_name = find_definition(node)
      Severity: Minor
      Found in lib/rubocop/cop/naming/memoized_instance_variable_name.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