rubocop-hq/rubocop

View on GitHub

Showing 628 of 670 total issues

Method add_newline? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def add_newline?(node)
          # Determine if a blank line should be inserted before the new directive
          # in order to spread out pattern matchers
          return false if node.sibling_index&.zero?
          return false unless node.parent
Severity: Minor
Found in lib/rubocop/cop/internal_affairs/node_matcher_directive.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          insecure_protocol_source?(node) do |source_node|
            source = source_node.value
            use_http_protocol = source == 'http://rubygems.org'

Severity: Minor
Found in lib/rubocop/cop/bundler/insecure_protocol_source.rb - About 25 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 issue_offenses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def issue_offenses(node, range, name)
        forbidden_offense(node, range, name) if forbidden_names.include?(name)
        case_offense(node, range) if uppercase?(name)
        length_offense(node, range) unless long_enough?(name)
        return if allow_nums
Severity: Minor
Found in lib/rubocop/cop/mixin/uncommunicative_name.rb - About 25 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 condition_as_parenthesized_one_line_pattern_matching? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def condition_as_parenthesized_one_line_pattern_matching?(condition)
          return false unless condition.parenthesized_call?
          return false unless (first_child = condition.children.first)

          if target_ruby_version >= 3.0
Severity: Minor
Found in lib/rubocop/cop/style/ternary_parentheses.rb - About 25 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_return has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_return(return_node)
          return unless return_node.descendants.any?

          context_node = non_void_context(return_node)

Severity: Minor
Found in lib/rubocop/cop/lint/return_in_void_context.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          if (name = alias_method?(node))
            return if node.ancestors.any?(&:if_type?)
            return if possible_dsl?(node)

Severity: Minor
Found in lib/rubocop/cop/lint/duplicate_methods.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          if node.method?(:[]=)
            handle_key_assignment(node) if node.arguments.size == 2
          elsif node.assignment_method?
            handle_attribute_assignment(node) if node.arguments.size == 1
Severity: Minor
Found in lib/rubocop/cop/lint/self_assignment.rb - About 25 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_def has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_def(node)
          return unless node.body

          last_expr = last_expression(node.body)
          return unless setter_call_to_local_variable?(last_expr)
Severity: Minor
Found in lib/rubocop/cop/lint/useless_setter_call.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          return unless (receiver = node.receiver)
          return unless (regexp = exact_regexp_match(node))

          parsed_regexp = Regexp::Parser.parse(regexp)
Severity: Minor
Found in lib/rubocop/cop/style/exact_regexp_match.rb - About 25 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 check_else has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def check_else(node)
          else_branch = node.else_branch
          first_else = else_branch.begin_type? ? else_branch.children.first : else_branch

          return unless first_else
Severity: Minor
Found in lib/rubocop/cop/lint/else_layout.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

        def register_offense(comment, cop_names)
          directive = DirectiveComment.new(comment)

          cop_names.each do |name|
            name = name.split('/').first if department?(directive, name)
Severity: Minor
Found in lib/rubocop/cop/lint/redundant_cop_enable_directive.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          return if node.receiver
          return unless (parent = node.parent)
          return unless parent.block_type? && parent.method?(:refine)

Severity: Minor
Found in lib/rubocop/cop/lint/refinement_import_methods.rb - About 25 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_def has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_def(node)
          subject, = *node
          return if node.defs_type? && subject.variable?

          def_ancestor = node.each_ancestor(:def, :defs).first
Severity: Minor
Found in lib/rubocop/cop/lint/nested_method_definition.rb - About 25 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 correct_hash_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def correct_hash_key(node)
          # Although some operators can be converted to symbols normally
          # (ie. `:==`), these are not accepted as hash keys and will
          # raise a syntax error (eg. `{ ==: ... }`). Therefore, if the
          # symbol does not start with an alphanumeric or underscore, it
Severity: Minor
Found in lib/rubocop/cop/lint/symbol_conversion.rb - About 25 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 message_for_normal_block has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def message_for_normal_block(variable, all_arguments)
          if all_arguments.none?(&:referenced?) && !define_method_call?(variable)
            if all_arguments.count > 1
              "You can omit all the arguments if you don't care about them."
            else
Severity: Minor
Found in lib/rubocop/cop/lint/unused_block_argument.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_new_investigation
          processed_source.comments.each do |comment|
            next if comment.text.ascii_only?
            next if only_allowed_non_ascii_chars?(comment.text)

Severity: Minor
Found in lib/rubocop/cop/style/ascii_comments.rb - About 25 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 check_nonmutating has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def check_nonmutating(node)
          return if !node.send_type? && !node.block_type? && !node.numblock_type?

          method_name = node.method_name
          return unless NONMUTATING_METHODS.include?(method_name)
Severity: Minor
Found in lib/rubocop/cop/lint/void.rb - About 25 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_nth_ref has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_nth_ref(node)
          backref, = *node
          return if @valid_ref.nil? || backref <= @valid_ref

          message = format(
Severity: Minor
Found in lib/rubocop/cop/lint/out_of_range_regexp_ref.rb - About 25 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 replacement_range_and_content has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def replacement_range_and_content(node)
          variable, = *node
          loc = node.loc
          expression = loc.expression

Severity: Minor
Found in lib/rubocop/cop/lint/redundant_splat_expansion.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          return unless (required_feature = node.first_argument)
          return unless required_feature.respond_to?(:value)
          return unless same_file?(processed_source.file_path, required_feature.value)

Severity: Minor
Found in lib/rubocop/cop/lint/require_relative_self_path.rb - About 25 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