rubocop-hq/rubocop

View on GitHub

Showing 666 of 666 total issues

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

        def last_heredoc_argument(node)
          n = last_heredoc_argument_node(node)

          return n if heredoc?(n)
          return unless n.respond_to?(:arguments)
Severity: Minor
Found in lib/rubocop/cop/layout/empty_line_after_guard_clause.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 invertible? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def invertible?(node)
          case node.type
          when :begin
            invertible?(node.children.first)
          when :send
Severity: Minor
Found in lib/rubocop/cop/style/invertible_unless_condition.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 process_errors has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def process_errors(file, errors)
        errors.each do |error|
          line = ":#{error.line}" if error.line
          column = ":#{error.column}" if error.column
          location = "#{file}#{line}#{column}"
Severity: Minor
Found in lib/rubocop/cop/team.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_new_investigation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def on_new_investigation
          str_ranges = nil

          processed_source.lines.each.with_index(1) do |line, lineno|
            next unless (range = find_offense(line, lineno))
Severity: Minor
Found in lib/rubocop/cop/layout/indentation_style.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 each_extra_empty_line has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def each_extra_empty_line(lines)
          prev_line = 1

          lines.each do |cur_line|
            if exceeds_line_offset?(cur_line - prev_line)
Severity: Minor
Found in lib/rubocop/cop/layout/empty_lines.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

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

          def each_escape(node)
            node.parsed_tree&.traverse&.reduce(0) do |char_class_depth, (event, expr)|
              yield(expr.text[1], expr.ts, !char_class_depth.zero?) if expr.type == :escape

              if expr.type == :set
Severity: Minor
Found in lib/rubocop/cop/style/redundant_regexp_escape.rb and 1 other location - About 45 mins to fix
lib/rubocop/cop/style/redundant_regexp_escape.rb on lines 113..120

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 40.

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

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

    def add_additional_modes(opts)
      section(opts, 'Additional Modes') do
        option(opts, '-L', '--list-target-files')
        option(opts, '--show-cops [COP1,COP2,...]') do |list|
          @options[:show_cops] = list.nil? ? [] : list.split(',')
Severity: Minor
Found in lib/rubocop/options.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

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

          def each_escape(node)
            node.parsed_tree&.traverse&.reduce(0) do |char_class_depth, (event, expr)|
              yield(expr.text[1], expr.start_index, !char_class_depth.zero?) if expr.type == :escape

              if expr.type == :set
Severity: Minor
Found in lib/rubocop/cop/style/redundant_regexp_escape.rb and 1 other location - About 45 mins to fix
lib/rubocop/cop/style/redundant_regexp_escape.rb on lines 99..106

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 40.

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

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

    def file
      return cache_path unless cache_path_expired?

      request do |response|
        next if response.is_a?(Net::HTTPNotModified)
Severity: Minor
Found in lib/rubocop/remote_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 autocorrect has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def autocorrect(corrector, node, range, offending_name, preferred_name)
Severity: Minor
Found in lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb - About 35 mins to fix

    Method move_pos has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def move_pos(src, pos, step, condition, regexp)
    Severity: Minor
    Found in lib/rubocop/cop/mixin/range_help.rb - About 35 mins to fix

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(file, team, options, config_store, cache_root = nil)
      Severity: Minor
      Found in lib/rubocop/result_cache.rb - About 35 mins to fix

        Method space_offense has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def space_offense(node, token, side, message, command)
        Severity: Minor
        Found in lib/rubocop/cop/mixin/surrounding_space.rb - About 35 mins to fix

          Method check has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def check(node, items, kind, begin_pos, end_pos)
          Severity: Minor
          Found in lib/rubocop/cop/mixin/trailing_comma.rb - About 35 mins to fix

            Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                      file_count, offense_count, correction_count, correctable_count, rainbow,
                      safe_autocorrect: false
            Severity: Minor
            Found in lib/rubocop/formatter/simple_text_formatter.rb - About 35 mins to fix

              Method move_pos_str has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def move_pos_str(src, pos, step, condition, needle)
              Severity: Minor
              Found in lib/rubocop/cop/mixin/range_help.rb - About 35 mins to fix

                Method fix_include_paths has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def fix_include_paths(base_config_path, hash, path, key, value)
                Severity: Minor
                Found in lib/rubocop/config_loader_resolver.rb - About 35 mins to fix

                  Method autocorrect has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          def autocorrect(corrector, node, condition, replacement, guard)
                  Severity: Minor
                  Found in lib/rubocop/cop/style/guard_clause.rb - About 35 mins to fix

                    Method autocorrect_heredoc_argument has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            def autocorrect_heredoc_argument(corrector, node, heredoc_branch, leave_branch, guard)
                    Severity: Minor
                    Found in lib/rubocop/cop/style/guard_clause.rb - About 35 mins to fix

                      Method apply_autocorrect has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              def apply_autocorrect(corrector, node, rhs, operator, new_rhs)
                      Severity: Minor
                      Found in lib/rubocop/cop/style/self_assignment.rb - About 35 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language