lib/rspec/core/metadata.rb
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.
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 create
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def self.create(parent_group_metadata, user_metadata, example_group_index, *args, &block)
Method create
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def self.create(group_metadata, user_metadata, index_provider, description, block)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def initialize(metadata, user_metadata, index_provider, description_args, block)
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
- 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"