rubocop-hq/rubocop

View on GitHub

Showing 649 of 649 total issues

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

        def autocorrect(corrector, node)
          unless args_on_beginning_line?(node)
            autocorrect_arguments(corrector, node)
            expr_before_body = node.arguments.source_range.end
          end
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 notice_found? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def notice_found?(processed_source)
          notice_found = false
          notice_regexp = Regexp.new(notice)
          processed_source.tokens.each do |token|
            break unless token.comment?
Severity: Minor
Found in lib/rubocop/cop/style/copyright.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 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        def on_class(node)
          return unless data_define?(node.parent_class)

          add_offense(node.parent_class.source_range) do |corrector|
            corrector.remove(range_with_surrounding_space(node.loc.keyword, newlines: false))
Severity: Minor
Found in lib/rubocop/cop/style/data_inheritance.rb and 1 other location - About 30 mins to fix
lib/rubocop/cop/style/struct_inheritance.rb on lines 33..40

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        def investigate_trailing_style(first_line, second_line, end_of_first_line)
          matches = second_line.match(TRAILING_STYLE_OFFENSE)
          return if matches.nil?

          offense_range = trailing_offense_range(end_of_first_line, matches)
Severity: Minor
Found in lib/rubocop/cop/layout/line_continuation_leading_space.rb and 1 other location - About 30 mins to fix
lib/rubocop/cop/layout/line_continuation_leading_space.rb on lines 84..91

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        def investigate_leading_style(first_line, second_line, end_of_first_line)
          matches = first_line.match(LEADING_STYLE_OFFENSE)
          return if matches.nil?

          offense_range = leading_offense_range(end_of_first_line, matches)
Severity: Minor
Found in lib/rubocop/cop/layout/line_continuation_leading_space.rb and 1 other location - About 30 mins to fix
lib/rubocop/cop/layout/line_continuation_leading_space.rb on lines 95..102

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        def on_class(node)
          return unless struct_constructor?(node.parent_class)

          add_offense(node.parent_class.source_range) do |corrector|
            corrector.remove(range_with_surrounding_space(node.loc.keyword, newlines: false))
Severity: Minor
Found in lib/rubocop/cop/style/struct_inheritance.rb and 1 other location - About 30 mins to fix
lib/rubocop/cop/style/data_inheritance.rb on lines 36..43

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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 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 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 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 false if /^-?0.0/.match?(mantissa)
          Severity: Major
          Found in lib/rubocop/cop/style/exponential_notation.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

              Avoid too many return statements within this method.
              Open

                        return if same_name_assignment?(node)
              Severity: Major
              Found in lib/rubocop/cop/style/method_call_without_args_parentheses.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                          return if parenthesized_it_method_in_block?(node)
                Severity: Major
                Found in lib/rubocop/cop/style/method_call_without_args_parentheses.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return if allowed_string_interpolation_method_call?(node)
                    Severity
                    Category
                    Status
                    Source
                    Language