bbatsov/rubocop

View on GitHub

Showing 687 of 687 total issues

Avoid too many return statements within this method.
Open

            return if begin_node.parent&.if_type? && begin_node.parent.ternary?
Severity: Major
Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                return if node.semantic_operator? && begin_node.parent
    Severity: Major
    Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                return true if delimiter?(node, escaped[0])
      Severity: Major
      Found in lib/rubocop/cop/style/redundant_string_escape.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                  return 'an interpolated expression' if interpolation?(begin_node)
        Severity: Major
        Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                    return if begin_node.chained?
          Severity: Major
          Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return unless begin_node.parent.nil?
            Severity: Major
            Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return if ALLOWED_NODE_TYPES.include?(begin_node.parent&.type)
              Severity: Major
              Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                          return if exist_argument_between_heredoc_end_and_closing_parentheses?(node)
                Severity: Major
                Found in lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb - About 30 mins to fix

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

                          def check_case(node)
                            else_branch = node.else_branch
                            return false unless else_branch
                            return false unless break_statement?(else_branch)
                  
                  
                  Severity: Minor
                  Found in lib/rubocop/cop/lint/unreachable_loop.rb and 1 other location - About 30 mins to fix
                  lib/rubocop/cop/lint/unreachable_code.rb on lines 82..89

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

                  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) 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 32.

                  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 data_define?(node.parent_class)
                  
                            add_offense(node.parent_class) 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 32.

                  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 report_offense(file, offense)
                          output.printf(
                            "%<path>s:%<line>d:%<column>d: %<severity>s: %<message>s\n",
                            path: cyan(smart_path(file)),
                            line: offense.line,
                  Severity: Minor
                  Found in lib/rubocop/formatter/clang_style_formatter.rb and 1 other location - About 30 mins to fix
                  lib/rubocop/formatter/tap_formatter.rb on lines 46..59

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

                  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

                    module Cop
                      module Layout
                        # Checks for a line break before the first element in a
                        # multi-line hash.
                        #
                  Severity: Minor
                  Found in lib/rubocop/cop/layout/first_hash_element_line_break.rb and 1 other location - About 30 mins to fix
                  lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb on lines 4..72

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

                  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 report_offense(file, offense)
                          output.printf(
                            "# %<path>s:%<line>d:%<column>d: %<severity>s: %<message>s\n",
                            path: cyan(smart_path(file)),
                            line: offense.line,
                  Severity: Minor
                  Found in lib/rubocop/formatter/tap_formatter.rb and 1 other location - About 30 mins to fix
                  lib/rubocop/formatter/clang_style_formatter.rb on lines 17..30

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

                  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

                    module Cop
                      module Layout
                        # Ensures that each parameter in a multi-line method definition
                        # starts on a separate line.
                        #
                  lib/rubocop/cop/layout/first_hash_element_line_break.rb on lines 4..63

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

                  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 check_case(node)
                            else_branch = node.else_branch
                            return false unless else_branch
                            return false unless flow_expression?(else_branch)
                  
                  
                  Severity: Minor
                  Found in lib/rubocop/cop/lint/unreachable_code.rb and 1 other location - About 30 mins to fix
                  lib/rubocop/cop/lint/unreachable_loop.rb on lines 176..187

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

                  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 move_assignment_inside_condition(corrector, node)
                              column = node.source_range.column
                              *_var, condition = *node
                              assignment = assignment(node)
                  
                  
                  Severity: Minor
                  Found in lib/rubocop/cop/style/conditional_assignment.rb and 1 other location - About 25 mins to fix
                  lib/rubocop/cop/style/conditional_assignment.rb on lines 568..576

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

                  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 move_assignment_inside_condition(corrector, node)
                              column = node.source_range.column
                              *_var, condition = *node
                              assignment = assignment(node)
                  
                  
                  Severity: Minor
                  Found in lib/rubocop/cop/style/conditional_assignment.rb and 1 other location - About 25 mins to fix
                  lib/rubocop/cop/style/conditional_assignment.rb on lines 619..627

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

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

                      def self.cleanup(config_store, verbose, cache_root = nil)
                        return if inhibit_cleanup # OPTIMIZE: For faster testing
                  
                        cache_root ||= cache_root(config_store)
                        return unless File.exist?(cache_root)
                  Severity: Minor
                  Found in lib/rubocop/result_cache.rb - About 25 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 references has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def references(cop, see_objects) # rubocop:disable Metrics/AbcSize
                      cop_config = config.for_cop(cop)
                      urls = RuboCop::Cop::MessageAnnotator.new(config, cop.name, cop_config, {}).urls
                      return '' if urls.empty? && see_objects.empty?
                  
                  
                  Severity: Minor
                  Found in lib/rubocop/cops_documentation_generator.rb - About 25 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