Class: RuboCop::Cop::RSpec::ExampleLength
- Includes:
- CodeLength
- Defined in:
- lib/rubocop/cop/rspec/example_length.rb
Overview
Checks for long examples.
A long example is usually more difficult to understand. Consider extracting out some behaviour, e.g. with a ‘let` block, or a helper method.
Constant Summary collapse
- MSG =
'Example has too many lines [%<total>d/%<max>d].'
Constants inherited from Cop
Cop::DEFAULT_CONFIGURATION, Cop::DEFAULT_PATTERN_RE
Constants included from RSpec::Language
RSpec::Language::ALL, RSpec::Language::RSPEC
Instance Method Summary collapse
Methods inherited from Cop
Instance Method Details
#on_block(node) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/rubocop/cop/rspec/example_length.rb', line 33 def on_block(node) return unless example?(node) length = code_length(node) return unless length > max_length add_offense(node, location: :expression, message: (length)) end |