Class: RuboCop::Cop::RSpec::ExampleLength
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::RSpec::ExampleLength
- Includes:
- CodeLength, RSpec::SpecOnly
- 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
Constants included from RSpec::SpecOnly
RSpec::SpecOnly::DEFAULT_CONFIGURATION
Instance Method Summary collapse
Methods included from RSpec::SpecOnly
Instance Method Details
#on_block(node) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubocop/cop/rspec/example_length.rb', line 33 def on_block(node) method, _args, _body = *node _receiver, method_name, _object = *method return unless EXAMPLE_BLOCKS.include?(method_name) length = code_length(node) return unless length > max_length add_offense(node, :expression, (length)) end |