bbatsov/rubocop

View on GitHub

Showing 669 of 669 total issues

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

        def excess_leading_space?(type, operator, with_space)
          return false unless allow_for_alignment?
          return false unless with_space.source.start_with?(EXCESSIVE_SPACE)

          return !aligned_with_operator?(operator) unless type == :assignment
Severity: Minor
Found in lib/rubocop/cop/layout/space_around_operators.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

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

          def calculate
            length = code_length(@node)
            return length if @foldable_types.empty?

            each_top_level_descendant(@node, @foldable_types) do |descendant|
Severity: Minor
Found in lib/rubocop/cop/metrics/utils/code_length_calculator.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 target_satisfies_all_gem_version_requirements? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def target_satisfies_all_gem_version_requirements?
        self.class.gem_requirements.all? do |gem_name, version_req|
          all_gem_versions_in_target = @config.gem_versions_in_target
          next false unless all_gem_versions_in_target

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

        def preceded_by_operator?(node, _range)
          # regular dotted method calls bind more tightly than operators
          # so we need to climb up the AST past them
          node.each_ancestor do |ancestor|
            return true if ancestor.and_type? || ancestor.or_type? || ancestor.range_type?
Severity: Minor
Found in lib/rubocop/cop/layout/space_around_keyword.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

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

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 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 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 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 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 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 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 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 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
                    Severity
                    Category
                    Status
                    Source
                    Language