Showing 76 of 94 total issues
Class Configuration
has 132 methods (exceeds 20 allowed). Consider refactoring.
class Configuration
include RSpec::Core::Hooks
# Module that holds `attr_reader` declarations. It's in a separate
# module to allow us to override those methods and use `super`.
File configuration.rb
has 957 lines of code (exceeds 250 allowed). Consider refactoring.
RSpec::Support.require_rspec_core "backtrace_formatter"
RSpec::Support.require_rspec_core "ruby_project"
RSpec::Support.require_rspec_core "formatters/deprecation_formatter"
RSpec::Support.require_rspec_core "output_wrapper"
Method parser
has 200 lines of code (exceeds 25 allowed). Consider refactoring.
def parser(options)
OptionParser.new do |parser|
parser.summary_width = 34
parser.banner = "Usage: rspec [options] [files or directories]\n\n"
Method parser
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
def parser(options)
OptionParser.new do |parser|
parser.summary_width = 34
parser.banner = "Usage: rspec [options] [files or directories]\n\n"
- Read upRead up
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
File example_group.rb
has 460 lines of code (exceeds 250 allowed). Consider refactoring.
RSpec::Support.require_rspec_support 'recursive_const_methods'
module RSpec
module Core
# rubocop:disable Metrics/ClassLength
Class ExampleGroup
has 50 methods (exceeds 20 allowed). Consider refactoring.
class ExampleGroup
extend Hooks
include MemoizedHelpers
extend MemoizedHelpers::ClassMethods
File exception_presenter.rb
has 378 lines of code (exceeds 250 allowed). Consider refactoring.
RSpec::Support.require_rspec_core "formatters/console_codes"
RSpec::Support.require_rspec_core "formatters/snippet_extractor"
RSpec::Support.require_rspec_core 'formatters/syntax_highlighter'
RSpec::Support.require_rspec_support "encoded_string"
File example.rb
has 343 lines of code (exceeds 250 allowed). Consider refactoring.
module RSpec
module Core
# Wrapper for an instance of a subclass of {ExampleGroup}. An instance of
# `RSpec::Core::Example` is returned by example definition methods
# such as {ExampleGroup.it it} and is yielded to the {ExampleGroup.it it},
Class Example
has 33 methods (exceeds 20 allowed). Consider refactoring.
class Example
# @private
#
# Used to define methods that delegate to this example's metadata.
def self.delegate_to_metadata(key)
Class World
has 32 methods (exceeds 20 allowed). Consider refactoring.
class World
# @private
attr_reader :example_groups, :filtered_examples, :example_group_counts_by_spec_file
# Used internally to determine what to do when a SIGINT is received.
File html_printer.rb
has 331 lines of code (exceeds 250 allowed). Consider refactoring.
require 'erb'
module RSpec
module Core
module Formatters
File metadata.rb
has 326 lines of code (exceeds 250 allowed). Consider refactoring.
module RSpec
module Core
# Each ExampleGroup class and Example instance owns an instance of
# Metadata, which is Hash extended to support lazy evaluation of values
# associated with keys that may or may not be used by any example or group.
Class Reporter
has 28 methods (exceeds 20 allowed). Consider refactoring.
class Reporter
# @private
RSPEC_NOTIFICATIONS = Set.new(
[
:close, :deprecation, :deprecation_summary, :dump_failures, :dump_pending,
Class ExceptionPresenter
has 27 methods (exceeds 20 allowed). Consider refactoring.
class ExceptionPresenter
attr_reader :exception, :example, :description, :message_color,
:detail_formatter, :extra_detail_formatter, :backtrace_formatter
private :message_color, :detail_formatter, :extra_detail_formatter, :backtrace_formatter
Class ConfigurationOptions
has 27 methods (exceeds 20 allowed). Consider refactoring.
class ConfigurationOptions
# @param args [Array<String>] command line arguments
def initialize(args)
@args = args.dup
organize_options
File notifications.rb
has 264 lines of code (exceeds 250 allowed). Consider refactoring.
RSpec::Support.require_rspec_core "formatters/console_codes"
RSpec::Support.require_rspec_core "formatters/exception_presenter"
RSpec::Support.require_rspec_core "formatters/helpers"
RSpec::Support.require_rspec_core "shell_escape"
Method initialize
has 45 lines of code (exceeds 25 allowed). Consider refactoring.
def initialize
# rubocop:disable Style/GlobalVars
@start_time = $_rspec_core_load_started_at || ::RSpec::Core::Time.now
# rubocop:enable Style/GlobalVars
@expectation_frameworks = []
Method filter_applies?
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
def filter_applies?(key, filter_value, metadata)
silence_metadata_example_group_deprecations do
return location_filter_applies?(filter_value, metadata) if key == :locations
return id_filter_applies?(filter_value, metadata) if key == :ids
return filters_apply?(key, filter_value, metadata) if Hash === filter_value
- Read upRead up
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 ensure_hooks_initialized_for
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
def ensure_hooks_initialized_for(position, scope)
if position == :before
if scope == :example
@before_example_hooks ||= @filterable_item_repo_class.new(:all?)
else
- Read upRead up
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_filter
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
def add_filter(argv, name, hash)
hash.each_pair do |k, v|
next if CONDITIONAL_FILTERS.include?(k)
tag = name == :inclusion ? k.to_s : "~#{k}".dup
tag << ":#{v}" if v.is_a?(String)
- Read upRead up
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 37 lines of code (exceeds 25 allowed). Consider refactoring.
def run(example_group_instance, reporter)
@example_group_instance = example_group_instance
@reporter = reporter
RSpec.configuration.configure_example(self, hooks)
RSpec.current_example = self
Method expect_with
has 32 lines of code (exceeds 25 allowed). Consider refactoring.
def expect_with(*frameworks)
modules = frameworks.map do |framework|
case framework
when Module
framework
Method mock_with
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
def mock_with(framework)
framework_module =
if framework.is_a?(Module)
framework
else
- Read upRead up
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 31 lines of code (exceeds 25 allowed). Consider refactoring.
def bisect_over(candidate_ids)
return if candidate_ids.one?
notify(
:bisect_round_started,
Method run_benchmarks
has 30 lines of code (exceeds 25 allowed). Consider refactoring.
def self.run_benchmarks
Benchmark.ips do |x|
implementations = { :old => "without", :new => "with" }
# Historically, many of our benchmarks have initially been order-sensitive,
# where whichever implementation went first got favored because defining
Method example_failed
has 29 lines of code (exceeds 25 allowed). Consider refactoring.
def example_failed(failure)
@failed_examples << failure.example
unless @header_red
@header_red = true
@printer.make_header_red
Method run
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def run(example_group_instance, reporter)
@example_group_instance = example_group_instance
@reporter = reporter
RSpec.configuration.configure_example(self, hooks)
RSpec.current_example = self
- Read upRead up
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 announce_filters
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def announce_filters
fail_if_config_and_cli_options_invalid
filter_announcements = []
announce_inclusion_filter filter_announcements
- Read upRead up
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 formatted_cause
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def formatted_cause(exception)
last_cause = final_exception(exception, [exception])
cause = []
if exception.cause
- Read upRead up
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_task
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def run_task(verbose)
command = spec_command
puts command if verbose
if with_clean_environment
- Read upRead up
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 hooks_for
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def hooks_for(position, scope)
if position == :before
scope == :example ? @before_example_hooks : @before_context_hooks
elsif position == :after
scope == :example ? @after_example_hooks : @after_context_hooks
- Read upRead up
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 define_example_group_method
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def self.define_example_group_method(name, metadata={})
idempotently_define_singleton_method(name) do |*args, &example_group_block|
thread_data = RSpec::Support.thread_local_data
top_level = self == ExampleGroup
- Read upRead up
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 define_example_group_method
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
def self.define_example_group_method(name, metadata={})
idempotently_define_singleton_method(name) do |*args, &example_group_block|
thread_data = RSpec::Support.thread_local_data
top_level = self == ExampleGroup
Method add
has 26 lines of code (exceeds 25 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)
Method custom_formatter
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def custom_formatter(formatter_ref)
if Class === formatter_ref
formatter_ref
elsif string_const?(formatter_ref)
begin
- Read upRead up
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 backwards_compatibility_default_proc
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def self.backwards_compatibility_default_proc(&example_group_selector)
Proc.new do |hash, key|
case key
when :example_group
# We commonly get here when rspec-core is applying a previously
- Read upRead up
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 options
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def options
argv = []
argv << "--color" if @submitted_options[:color]
argv << "--force-color" if @submitted_options[:color_mode] == :on
argv << "--no-color" if @submitted_options[:color_mode] == :off
- Read upRead up
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 expect_with
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def expect_with(*frameworks)
modules = frameworks.map do |framework|
case framework
when Module
framework
- Read upRead up
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 get_files_to_run
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def get_files_to_run(paths)
files = FlatMap.flat_map(paths_to_check(paths)) do |path|
path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
File.directory?(path) ? gather_directories(path) : extract_location(path)
end.uniq
- Read upRead up
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 setup_default
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def setup_default(output_stream, deprecation_stream)
add default_formatter, output_stream if @formatters.empty?
unless @formatters.any? { |formatter| DeprecationFormatter === formatter }
add DeprecationFormatter, deprecation_stream, output_stream
- Read upRead up
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 apply_derived_metadata_to
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def apply_derived_metadata_to(metadata)
already_run_blocks = Set.new
# We loop and attempt to re-apply metadata blocks to support cascades
# (e.g. where a derived bit of metadata triggers the application of
- Read upRead up
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 unclosed_tokens_in_line_range
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def unclosed_tokens_in_line_range(line_range)
tokens = FlatMap.flat_map(line_range) do |line_number|
source.tokens_by_line_number[line_number]
end
- Read upRead up
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 print_example_failed
has 6 arguments (exceeds 4 allowed). Consider refactoring.
def print_example_failed(pending_fixed, description, run_time, failure_id,
exception, extra_content)
Method run
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def run(position, scope, example_or_group)
return if RSpec.configuration.dry_run?
if scope == :context
unless example_or_group.class.metadata[:skip]
- Read upRead up
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 organize_options
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def organize_options
@filter_manager_options = []
@options = (file_options << command_line_options << env_options).each do |opts|
@filter_manager_options << [:include, opts.delete(:inclusion_filter)] if opts.key?(:inclusion_filter)
- Read upRead up
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 subclass
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def self.subclass(parent, description, args, registration_collection, &example_group_block)
Method create
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def self.create(group_metadata, user_metadata, index_provider, description, block)
Method process
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def process(host, parent_groups, globals, position, scope)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def initialize(metadata, user_metadata, index_provider, description_args, block)
Method define_mixed_in_module
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def define_mixed_in_module(mod, filters, mod_list, config_method, &block)