Class: Rubocop::Cop::Style::BlockNesting
- Defined in:
- lib/rubocop/cop/style/block_nesting.rb
Overview
This cop checks for excessive nesting of conditional and looping constructs. Despite the cop's name, blocks are not considered as a extra level of nesting.
The maximum level of nesting allowed is configurable.
Constant Summary collapse
- NESTING_BLOCKS =
[:case, :if, :while, :while_post, :until, :until_post, :for, :resbody]
Constants inherited from Cop
Instance Attribute Summary
Attributes inherited from Cop
#config, #corrections, #offences, #processed_source
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, all, #autocorrect?, #convention, #cop_config, cop_name, #cop_name, cop_type, #debug?, #ignore_node, inherited, #initialize, lint?, non_rails, rails?, style?, #support_autocorrect?, #warning
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#investigate(processed_source) ⇒ Object
15 16 17 18 19 |
# File 'lib/rubocop/cop/style/block_nesting.rb', line 15 def investigate(processed_source) return unless processed_source.ast max = cop_config['Max'] check_nesting_level(processed_source.ast, max, 0) end |