rubocop-hq/rubocop

View on GitHub

Showing 624 of 666 total issues

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

      def run_hook(method_name, *args)
        cops.each do |cop|
          next unless cop.respond_to?(method_name)

          cop.public_send(method_name, *args)
Severity: Minor
Found in lib/rubocop/cop/force.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

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

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 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 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 !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 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 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 match_predicate_without_receiver?(regexp_method_send_node)
                  Severity: Major
                  Found in lib/rubocop/cop/style/select_by_regexp.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                              return if method_chain.method?(:empty?)
                    Severity: Major
                    Found in lib/rubocop/cop/style/safe_navigation.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                return if include_statement_only?(body)
                      Severity: Major
                      Found in lib/rubocop/cop/style/documentation.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return if allowed_string_interpolation_method_call?(node)

                          Avoid too many return statements within this method.
                          Open

                                    return false unless sym_node.source == lvar_node.source
                          Severity: Major
                          Found in lib/rubocop/cop/style/super_arguments.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return if allowed_camel_case_method_call?(node)

                              Avoid too many return statements within this method.
                              Open

                                          return if legitimate_call_with_parentheses?(node)

                                Avoid too many return statements within this method.
                                Open

                                          return if target_ruby_version <= 2.2 && replacement == 'grep_v'
                                Severity: Major
                                Found in lib/rubocop/cop/style/select_by_regexp.rb - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language