rubocop-hq/rubocop

View on GitHub

Showing 614 of 652 total issues

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

        def on_block(node)
          return if node.single_line?

          unless args_on_beginning_line?(node) || line_break_necessary_in_args?(node)
            add_offense_for_expression(node, node.arguments, ARG_MSG)
Severity: Minor
Found in lib/rubocop/cop/layout/multiline_block_layout.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_send has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def on_send(node)
          heredoc_arg = extract_heredoc_argument(node)
          return unless heredoc_arg

          outermost_send = outermost_send_on_same_line(heredoc_arg)
Severity: Minor
Found in lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.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
          buffer = processed_source.buffer
          return if buffer.source.empty?

          # The extra text that comes after the last token could be __END__
Severity: Minor
Found in lib/rubocop/cop/layout/trailing_empty_lines.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 belong_to_outer_scope? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def belong_to_outer_scope?(target_node)
          return true if !naked_top_level? && target_node.equal?(node)
          return true if ancestor_node?(target_node)
          return false unless target_node.parent.equal?(node)

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

        def check_assignment(node, rhs)
          return if node.send_type? && node.loc.operator&.source != '='
          return unless rhs
          return unless supported_types.include?(rhs.type)
          return if rhs.single_line?
Severity: Minor
Found in lib/rubocop/cop/layout/multiline_assignment_layout.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 begin_pos_with_comment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def begin_pos_with_comment(node)
          first_comment = nil
          (node.first_line - 1).downto(1) do |annotation_line|
            break unless (comment = processed_source.comment_at_line(annotation_line))

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

        def extract_heredoc(node)
          return node if heredoc_node?(node)
          return node.receiver if single_line_send_with_heredoc_receiver?(node)

          return unless node.hash_type?
Severity: Minor
Found in lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.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 offending_range has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def offending_range(node)
          receiver = node.receiver
          return unless receiver&.block_type?

          receiver_location = receiver.loc
Severity: Minor
Found in lib/rubocop/cop/layout/single_line_block_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 check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def check(hash_node, left_parenthesis)
          return if ignored_node?(hash_node)

          left_brace = hash_node.loc.begin
          first_pair = hash_node.pairs.first
Severity: Minor
Found in lib/rubocop/cop/layout/first_hash_element_indentation.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 alignment_node has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def alignment_node(node)
          ancestor_node = ancestor_node(node)

          return ancestor_node if ancestor_node.nil? || ancestor_node.kwbegin_type?
          return if ancestor_node.respond_to?(:send_node) &&
Severity: Minor
Found in lib/rubocop/cop/layout/rescue_ensure_alignment.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 indentation_to_check? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def indentation_to_check?(base_loc, body_node)
          return false if skip_check?(base_loc, body_node)

          if body_node.rescue_type?
            check_rescue?(body_node)
Severity: Minor
Found in lib/rubocop/cop/layout/indentation_width.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 private_constant? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def private_constant?(node)
          return false unless node.casgn_type? && node.namespace.nil?
          return false unless (parent = node.parent)

          parent.each_child_node(:send) do |child_node|
Severity: Minor
Found in lib/rubocop/cop/layout/class_structure.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_heredoc has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def on_heredoc(node)
          body = heredoc_body(node)
          return if body.strip.empty?

          body_indent_level = indent_level(body)
Severity: Minor
Found in lib/rubocop/cop/layout/heredoc_indentation.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 ruby_executable? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def ruby_executable?(file)
      return false unless File.extname(file).empty? && File.exist?(file)

      first_line = File.open(file, &:readline)
      /#!.*(#{ruby_interpreters(file).join('|')})/.match?(first_line)
Severity: Minor
Found in lib/rubocop/target_finder.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 wanted_dir_patterns has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def wanted_dir_patterns(base_dir, exclude_pattern, flags)
      # Escape glob characters in base_dir to avoid unwanted behavior.
      base_dir = base_dir.gsub(/[\\\{\}\[\]\*\?]/) do |reserved_glob_character|
        "\\#{reserved_glob_character}"
      end
Severity: Minor
Found in lib/rubocop/target_finder.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

Avoid too many return statements within this method.
Open

        return if dispatch_node.parent && parentheses?(dispatch_node.parent)
Severity: Major
Found in lib/rubocop/cop/mixin/hash_shorthand_syntax.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return true if should_merge?(base_mode, key)
    Severity: Major
    Found in lib/rubocop/config_loader_resolver.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return if last_expression?(dispatch_node) && !method_dispatch_as_argument?(dispatch_node)
      Severity: Major
      Found in lib/rubocop/cop/mixin/hash_shorthand_syntax.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                  return unless (kwsplat = node.each_ancestor(:kwsplat).first)
        Severity: Major
        Found in lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                    return if !node.braces? || allowed_double_splat_receiver?(kwsplat)
          Severity: Major
          Found in lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language