class RubyLint::Analysis::LoopKeywords
Analysis
class that checks if certain keywords are used inside a block/loop or not. For example, the following is not valid Ruby code:
next
But the following is valid:
[10, 20].each do |n| next end
The following isn't valid either:
def foo next end
See {KEYWORDS} for a list of the keywords that can only be used inside a loop.
Constants
- KEYWORDS
List of keywords that can only be used inside a loop.
@return [Array]
- STATEMENTS
List of statements that do allow the use of the various keywords.
@return [Array]
Public Instance Methods
after_initialize()
click to toggle source
Calls superclass method
RubyLint::Analysis::Base#after_initialize
# File lib/ruby-lint/analysis/loop_keywords.rb, line 27 def after_initialize @loop_nesting = 0 super end
verify_keyword(keyword, node)
click to toggle source
@param [Symbol] keyword @param [RubyLint::AST::Node] node
# File lib/ruby-lint/analysis/loop_keywords.rb, line 64 def verify_keyword(keyword, node) if current_scope.type != :block and @loop_nesting.zero? error("#{keyword} can only be used inside a loop/block", node) end end