rspec/rspec-core

View on GitHub

Showing 76 of 94 total issues

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

        def process(host, parent_groups, globals, position, scope)
Severity: Minor
Found in lib/rspec/core/hooks.rb - About 35 mins to fix

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

            def initialize(metadata, user_metadata, index_provider, description_args, block)
    Severity: Minor
    Found in lib/rspec/core/metadata.rb - About 35 mins to fix

      Method for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

            def self.for(example)
              execution_result = example.execution_result
      
              return SkippedExampleNotification.new(example) if execution_result.example_skipped?
              return new(example) unless execution_result.status == :pending || execution_result.status == :failed
      Severity: Minor
      Found in lib/rspec/core/notifications.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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

            def self.run(reporter=RSpec::Core::NullReporter)
              return if RSpec.world.wants_to_quit
              reporter.example_group_started(self)
      
              should_run_context_hooks = descendant_filtered_examples.any?
      Severity: Minor
      Found in lib/rspec/core/example_group.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 read_failed_lines has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

              def read_failed_lines
                matching_line = find_failed_line
                unless matching_line
                  return ["Unable to find matching line from backtrace"]
                end
      Severity: Minor
      Found in lib/rspec/core/formatters/exception_presenter.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 add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

          def add(formatter_to_use, *paths)
            # If a formatter instance was passed, we can register it directly,
            # with no need for any of the further processing that happens below.
            if Loader.formatters.key?(formatter_to_use.class)
              register formatter_to_use, notifications_for(formatter_to_use.class)
      Severity: Minor
      Found in lib/rspec/core/formatters.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 running_in_drb? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

            def self.running_in_drb?
              return false unless defined?(DRb)
      
              server = begin
                         DRb.current_server
      Severity: Minor
      Found in lib/rspec/core/runner.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 example_failed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

              def example_failed(failure)
                @failed_examples << failure.example
                unless @header_red
                  @header_red = true
                  @printer.make_header_red
      Severity: Minor
      Found in lib/rspec/core/formatters/html_formatter.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 multiple_exception_summarizer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

                def multiple_exception_summarizer(exception, prior_detail_formatter, color)
                  lambda do |example, colorizer|
                    summary = if exception.aggregation_metadata[:hide_backtrace]
                                # Since the backtrace is hidden, the subfailures will come
                                # immediately after this, and using `:` will read well.
      Severity: Minor
      Found in lib/rspec/core/formatters/exception_presenter.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.

                  return filter_applies_to_any_value?(key, filter_value, metadata) if Array === meta_value
      Severity: Major
      Found in lib/rspec/core/metadata_filter.rb - About 30 mins to fix

        Avoid too many return statements within this method.

                    return proc_filter_applies?(key, filter_value, metadata) if Proc === filter_value
        Severity: Major
        Found in lib/rspec/core/metadata_filter.rb - About 30 mins to fix

          Avoid too many return statements within this method.

                      return true if TrueClass === filter_value && meta_value
          Severity: Major
          Found in lib/rspec/core/metadata_filter.rb - About 30 mins to fix

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

                  def run_specs(example_groups)
                    examples_count = @world.example_count(example_groups)
                    success = @configuration.reporter.report(examples_count) do |reporter|
                      @configuration.with_suite_hooks do
                        if examples_count == 0 && @configuration.fail_if_no_examples
            Severity: Minor
            Found in lib/rspec/core/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 let has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                    def let(name, &block)
                      # We have to pass the block directly to `define_method` to
                      # allow it to use method constructs like `super` and `return`.
                      raise "#let or #subject called without a block" if block.nil?
                      raise(
            Severity: Minor
            Found in lib/rspec/core/memoized_helpers.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 run_examples has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                  def self.run_examples(reporter)
                    ordering_strategy.order(filtered_examples).map do |example|
                      next if RSpec.world.wants_to_quit
                      instance = new(example.inspect_output)
                      set_ivars(instance, before_context_ivars)
            Severity: Minor
            Found in lib/rspec/core/example_group.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 expression_lines has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                      def expression_lines
                        line_range = line_range_of_expression
            
                        if max_line_count && line_range.count > max_line_count
                          line_range = (line_range.begin)..(line_range.begin + max_line_count - 1)
            Severity: Minor
            Found in lib/rspec/core/formatters/snippet_extractor.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 expression_outmost_node? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                      def expression_outmost_node?(node)
                        return true unless node.parent
                        return false if node.type.to_s.start_with?('@')
                        ![node, node.parent].all? do |n|
                          # See `Ripper::PARSER_EVENTS` for the complete list of sexp types.
            Severity: Minor
            Found in lib/rspec/core/formatters/snippet_extractor.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 ascending has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                  def self.ascending(metadata)
                    yield metadata
                    return unless (group_metadata = metadata.fetch(:example_group) { metadata[:parent_example_group] })
            
                    loop do
            Severity: Minor
            Found in lib/rspec/core/metadata.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 warn_with has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                  def warn_with(message, options={})
                    if options[:use_spec_location_as_call_site]
                      message += "." unless message.end_with?(".")
            
                      if RSpec.current_example
            Severity: Minor
            Found in lib/rspec/core/warnings.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_inclusion_specification has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                  def file_inclusion_specification
                    if ENV['SPEC']
                      FileList[ENV['SPEC']].sort
                    elsif String === pattern && !File.exist?(pattern)
                      return if [*rspec_opts].any? { |opt| opt =~ /--pattern/ }
            Severity: Minor
            Found in lib/rspec/core/rake_task.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 format_backtrace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                  def format_backtrace(backtrace, options={})
                    return [] unless backtrace
                    return backtrace if options[:full_backtrace] || backtrace.empty?
            
                    backtrace.map { |l| backtrace_line(l) }.compact.
            Severity: Minor
            Found in lib/rspec/core/backtrace_formatter.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 persist_example_statuses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                  def persist_example_statuses
                    return if @configuration.dry_run
                    return unless (path = @configuration.example_status_persistence_file_path)
            
                    ExampleStatusPersister.persist(@world.all_examples, path)
            Severity: Minor
            Found in lib/rspec/core/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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                def parse(source=nil)
                  return { :files_or_directories_to_run => [] } if original_args.empty?
                  args = original_args.dup
            
                  options = args.delete('--tty') ? { :tty => true } : {}
            Severity: Minor
            Found in lib/rspec/core/option_parser.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 statuses_from_this_run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                  def statuses_from_this_run
                    @examples.map do |ex|
                      result = ex.execution_result
            
                      {
            Severity: Minor
            Found in lib/rspec/core/example_status_persister.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 bisect_over has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                    def bisect_over(candidate_ids)
                      return if candidate_ids.one?
            
                      notify(
                        :bisect_round_started,
            Severity: Minor
            Found in lib/rspec/core/bisect/example_minimizer.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 run_suite_hooks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

                  def run_suite_hooks(hook_description, hooks)
                    context = SuiteHookContext.new(hook_description, reporter)
            
                    hooks.each do |hook|
                      begin
            Severity: Minor
            Found in lib/rspec/core/configuration.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