bbatsov/rubocop

View on GitHub

Showing 669 of 669 total issues

Method reposition has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def reposition(src, pos, step, include_newlines: false)
        offset = step == -1 ? -1 : 0
        pos += step while SINGLE_SPACE_REGEXP.match?(src[pos + offset]) ||
                          (include_newlines && src[pos + offset] == "\n")
        pos.negative? ? 0 : pos
Severity: Minor
Found in lib/rubocop/cop/mixin/surrounding_space.rb - About 35 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 allow_receiver? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def allow_receiver?(receiver)
          if receiver.numeric_type? || (receiver.send_type? &&
            (conversion_method?(receiver.method_name) ||
            allowed_method_name?(receiver.method_name)))
            true
Severity: Minor
Found in lib/rubocop/cop/lint/number_conversion.rb - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
Open

        def on_new_investigation
          return if @options.key?(:stdin)
          return if Platform.windows?
          return unless processed_source.start_with?(SHEBANG)
          return if executable?(processed_source)
Severity: Minor
Found in lib/rubocop/cop/lint/script_permission.rb - About 35 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 empty_if_branch? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def empty_if_branch?(node)
          return false unless (parent = node.parent)
          return true unless parent.if_type?
          return true unless (if_branch = parent.if_branch)

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

        def offense_range(duplicate_branch)
          parent = duplicate_branch.parent

          if parent.respond_to?(:else_branch) && parent.else_branch.equal?(duplicate_branch)
            if parent.if_type? && parent.ternary?
Severity: Minor
Found in lib/rubocop/cop/lint/duplicate_branch.rb - About 35 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_offense_node_by has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def find_offense_node_by(diagnostic)
          ast = processed_source.ast
          ast.each_node(:splat, :block_pass, :kwsplat) do |node|
            next unless offense_position?(node, diagnostic)

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

        def on_block(node)
          return unless node.lambda?

          selector = node.send_node.source

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

        def replacement(regexp_node)
          regexp_content = regexp_node.content
          stack = []
          chars = regexp_content.chars.each_with_object([]) do |char, strings|
            if stack.empty? && char == '\\'
Severity: Minor
Found in lib/rubocop/cop/style/redundant_regexp_argument.rb - About 35 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_const has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def on_const(node)
          # FIXME: Workaround for "`undefined method `expression' for nil:NilClass`" when processing
          #        `__ENCODING__`. It is better to be able to work without this condition.
          #        Maybe further investigation of RuboCop AST will lead to an essential solution.
          return unless node.loc
Severity: Minor
Found in lib/rubocop/cop/lint/deprecated_constants.rb - About 35 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 returned_accumulator_index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def returned_accumulator_index(return_values, accumulator_name, element_name)
          return_values.detect do |val|
            next unless accumulator_index?(val, accumulator_name)
            next true if val.method?(:[]=)

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

        def lookup_constant(node, const_name)
          # this method is quite imperfect and can be fooled
          # to do much better, we would need to do global analysis of the whole
          # codebase
          node.each_ancestor(:class, :module, :casgn) do |ancestor|
Severity: Minor
Found in lib/rubocop/cop/lint/duplicate_methods.rb - About 35 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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def check(node)
          lambda do |exception_class, cbase|
            return if cbase.nil? && implicit_namespace?(node)

            add_offense(exception_class) do |corrector|
Severity: Minor
Found in lib/rubocop/cop/lint/raise_exception.rb - About 35 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 require_parentheses? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def require_parentheses?(send_node)
          return false unless send_node.comparison_method?
          return false unless (node = send_node.parent)

          (node.respond_to?(:logical_operator?) && node.logical_operator?) ||
Severity: Minor
Found in lib/rubocop/cop/lint/safe_navigation_chain.rb - About 35 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 preceded_by_continue_statement? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def preceded_by_continue_statement?(break_statement)
          break_statement.left_siblings.any? do |sibling|
            # Numblocks have the arguments count as a number in the AST.
            next if sibling.is_a?(Integer)
            next if sibling.loop_keyword? || loop_method?(sibling)
Severity: Minor
Found in lib/rubocop/cop/lint/unreachable_loop.rb - About 35 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 entirely_literal? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def entirely_literal?(node)
          case node.type
          when :array
            node.each_value.all? { |value| entirely_literal?(value) }
          when :hash
Severity: Minor
Found in lib/rubocop/cop/lint/void.rb - About 35 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 nil_node_at_the_end_of_method_body has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def nil_node_at_the_end_of_method_body(body)
          return body if body.nil_type?
          return unless body.begin_type?
          return unless (last_child = body.children.last)

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

        def check_send(node)
          if node.arithmetic_operation?
            lhs, _operation, rhs = *node
            float?(lhs) || float?(rhs)
          elsif FLOAT_RETURNING_METHODS.include?(node.method_name)
Severity: Minor
Found in lib/rubocop/cop/lint/float_comparison.rb - About 35 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_case_match has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def on_case_match(node)
          node.in_pattern_branches.each do |branch|
            next if branch.body
            next if cop_config['AllowComments'] && contains_comments?(branch)

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

        def on_if(node)
          return if node.body || same_line?(node.loc.begin, node.loc.end)
          return if cop_config['AllowComments'] && contains_comments?(node)

          add_offense(node, message: format(MSG, keyword: node.keyword)) do |corrector|
Severity: Minor
Found in lib/rubocop/cop/lint/empty_conditional_body.rb - About 35 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 engineering? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def engineering?(node)
          mantissa, exponent = node.source.split('e')
          return false unless /^-?\d+$/.match?(exponent)
          return false unless (exponent.to_i % 3).zero?
          return false if /^-?\d{4}/.match?(mantissa)
Severity: Minor
Found in lib/rubocop/cop/style/exponential_notation.rb - About 35 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