lib/rspec/mocks/syntax.rb
Method enable_should
has 49 lines of code (exceeds 25 allowed). Consider refactoring.
def self.enable_should(syntax_host=default_should_syntax_host)
@warn_about_should = false if syntax_host == default_should_syntax_host
return if should_enabled?(syntax_host)
syntax_host.class_exec do
Method enable_expect
has 28 lines of code (exceeds 25 allowed). Consider refactoring.
def self.enable_expect(syntax_host=::RSpec::Mocks::ExampleMethods)
return if expect_enabled?(syntax_host)
syntax_host.class_exec do
def receive(method_name, &block)
Method default_should_syntax_host
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def self.default_should_syntax_host
# JRuby 1.7.4 introduces a regression whereby `defined?(::BasicObject) => nil`
# yet `BasicObject` still exists and patching onto ::Object breaks things
# e.g. SimpleDelegator expectations won't work
#
- 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"