rubocop-hq/rubocop

View on GitHub

Showing 615 of 655 total issues

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 if allow_if_method_has_argument?(node.send_node)
    Severity: Major
    Found in lib/rubocop/cop/style/symbol_proc.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return 'an expression'
      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 '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 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 unless begin_node.parent.nil?
            Severity: Major
            Found in lib/rubocop/cop/style/redundant_parentheses.rb - About 30 mins to fix

              Method iterate_until_no_changes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def iterate_until_no_changes(source, offenses_by_iteration)
                    # Keep track of the state of the source. If a cop modifies the source
                    # and another cop undoes it producing identical source we have an
                    # infinite loop.
                    @processed_sources = []
              Severity: Minor
              Found in lib/rubocop/runner.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 on_def has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                      def on_def(node)
                        return unless block_handler?(node)
                        return unless node.parent
              
                        add_offense(node) unless numblock_handler?(node.parent)
              Severity: Minor
              Found in lib/rubocop/cop/internal_affairs/numblock_handler.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 list_unknown_cops has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def list_unknown_cops(invalid_cop_names)
                    unknown_cops = []
                    invalid_cop_names.each do |name|
                      # There could be a custom cop with this name. If so, don't warn
                      next if Cop::Registry.global.contains_cop_matching?([name])
              Severity: Minor
              Found in lib/rubocop/config_validator.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 move_pos has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def move_pos(src, pos, step, condition, regexp)
                      offset = step == -1 ? -1 : 0
                      pos += step while condition && regexp.match?(src[pos + offset])
                      pos.negative? ? 0 : pos
                    end
              Severity: Minor
              Found in lib/rubocop/cop/mixin/range_help.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 last_line_heredoc? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def last_line_heredoc?(node, parent = nil)
                      parent ||= node
              
                      if node.respond_to?(:loc) &&
                         node.loc.respond_to?(:heredoc_end) &&
              Severity: Minor
              Found in lib/rubocop/cop/mixin/multiline_literal_brace_layout.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 safety_object has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def safety_object(safety_object_objects)
                  safety_object_objects.each_with_object(h3('Safety').dup) do |safety_object, content|
                    next if safety_object.text.blank?
              
                    content << "\n" unless content.end_with?("\n\n")
              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

              Method location has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def location(node)
                      return node.loc.name if node.casgn_type?
              
                      if LSP.enabled?
                        end_range = node.loc.respond_to?(:name) ? node.loc.name : node.loc.begin
              Severity: Minor
              Found in lib/rubocop/cop/mixin/code_length.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 each_bad_alignment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def each_bad_alignment(items, base_column)
                      prev_line = -1
                      items.each do |current|
                        if current.loc.line > prev_line && begins_its_line?(current.source_range)
                          @column_delta = base_column - display_column(current.source_range)
              Severity: Minor
              Found in lib/rubocop/cop/mixin/alignment.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 file_to_include? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def file_to_include?(file)
                    relative_file_path = path_relative_to_config(file)
              
                    # Optimization to quickly decide if the given file is hidden (on the top
                    # level) and cannot be matched by any pattern.
              Severity: Minor
              Found in lib/rubocop/config.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 offenses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def offenses(path, text)
                      diagnostic_options = {
                        stdin: text, force_exclusion: true, formatters: ['json'], format: 'json'
                      }
                      diagnostic_options[:only] = config_only_options if @lint_mode || @layout_mode
              Severity: Minor
              Found in lib/rubocop/lsp/runtime.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 add_newline? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                      def add_newline?(node)
                        # Determine if a blank line should be inserted before the new directive
                        # in order to spread out pattern matchers
                        return false if node.sibling_index&.zero?
                        return false unless node.parent
              Severity: Minor
              Found in lib/rubocop/cop/internal_affairs/node_matcher_directive.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 on_send has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                      def on_send(node)
                        return unless (attrs = node.attribute_accessor?)
              
                        attrs.last.each do |name_item|
                          name = attr_name(name_item)
              Severity: Minor
              Found in lib/rubocop/cop/naming/method_name.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 check_alignment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def check_alignment(items, base_column = nil)
                      base_column ||= display_column(items.first.source_range) unless items.empty?
              
                      each_bad_alignment(items, base_column) do |current|
                        expr = current.source_range
              Severity: Minor
              Found in lib/rubocop/cop/mixin/alignment.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 elements has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def elements(node)
                      return node.children unless node.call_type?
              
                      node.arguments.flat_map do |argument|
                        # For each argument, if it is a multi-line hash without braces,
              Severity: Minor
              Found in lib/rubocop/cop/mixin/trailing_comma.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