Class: RuboCop::Cop::RSpec::ExampleLength
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::RSpec::ExampleLength
- Includes:
- CodeLength
- Defined in:
- lib/rubocop/cop/rspec/example_length.rb
Overview
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
- EXAMPLE_BLOCKS =
[:it, :specify].freeze
Instance Method Summary collapse
Instance Method Details
#on_block(node) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rubocop/cop/rspec/example_length.rb', line 31 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 add_offense(node, :expression, (length, max)) end |