class RuboCop::Cop::RSpec::ExampleLength
end # 6 points
)
2
1,
foo( # +1
HEREDOC
content.
Heredoc
msg = <<~HEREDOC # +1
}
key: ‘value’
hash = { # +3
]
2
1,
array = [ # +1
it do
@example CountAsOne: [‘array’, ‘heredoc’, ‘method_call’]
its actual size.
Each construct will be counted as one line regardless of
Available are: ‘array’, ‘hash’, ‘heredoc’, and ‘method_call’.
You can set constructs you want to fold with ‘CountAsOne`.
end
expect(result).to be(true)
result = service.call
service = described_class.new
it do
# good
end
expect(result).to be(true)
result = service.call
more_setup
more_setup
service = described_class.new
it do
# bad
@example
method.
extracting out some behavior, e.g. with a `let` block, or a helper
A long example is usually more difficult to understand. Consider
Checks for long examples.
def cop_label
def cop_label LABEL end
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler return unless example?(node) check_code_length(node) end