Class: RuboCop::Cop::WaitFor::ConditionMet
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::WaitFor::ConditionMet
- Defined in:
- lib/rubocop/cop/wait_for/condition_met.rb
Overview
Evaluates annotated comments that specify a runtime condition and registers an offense once the condition evaluates to true.
It is designed to support use cases such as removing temporary code once a feature flag is enabled, a deprecation deadline is reached, or some environment-dependent behavior becomes active.
Constant Summary collapse
- DIRECTIVE_PATTERN =
/#\s*(?:rubocop[:\-])?wait-for\s+(.+)/.freeze
- MSG =
'Condition has been met.'
Instance Method Summary collapse
Instance Method Details
#external_dependency_checksum ⇒ Object
29 30 31 |
# File 'lib/rubocop/cop/wait_for/condition_met.rb', line 29 def external_dependency_checksum Time.now.to_i.to_s if ENV['RUBOCOP_WAIT_FOR_CHECK_ALL'] == '1' end |
#on_new_investigation ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rubocop/cop/wait_for/condition_met.rb', line 33 def on_new_investigation return if processed_source.buffer.source.empty? processed_source.comments.each do |comment| next unless (condition = DIRECTIVE_PATTERN.match(comment.text)) result = evaluate_condition(condition.captures[0]) add_offense(comment) if result == true end end |