Module: RuboCop::CommentConfig::DisableNext Private
- Included in:
- RuboCop::CommentConfig
- Defined in:
- lib/rubocop/comment_config/disable_next.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Handling of disable-next directives: computing the statement scope
they apply to and tracking directives that attached to nothing.
The scope is the whole statement starting on the next line bearing
code. Comment-only lines between the directive and the code chain (so
several directives can stack), while a blank line breaks the attachment.
Instance Method Summary collapse
-
#detached_next_directives ⇒ Object
private
disable-nextdirectives that suppress nothing: nothing follows them, or they sit at the end of a code line. -
#statement_scope_after(line) ⇒ Object
private
The line range of the statement a
disable-nextdirective on the given line scopes to (or would scope to), ornilwhen no statement is attached.
Instance Method Details
#detached_next_directives ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
disable-next directives that suppress nothing: nothing follows
them, or they sit at the end of a code line.
14 15 16 17 |
# File 'lib/rubocop/comment_config/disable_next.rb', line 14 def detached_next_directives cop_disabled_line_ranges # ensure the analysis that collects them ran @detached_next_directives end |
#statement_scope_after(line) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The line range of the statement a disable-next directive on the
given line scopes to (or would scope to), or nil when no statement
is attached. A directive is only honored on a comment-only line.
Stacked directives share the target, so the computation is memoized.
24 25 26 27 28 29 30 31 |
# File 'lib/rubocop/comment_config/disable_next.rb', line 24 def statement_scope_after(line) return nil unless comment_only_line?(line) code_line = attached_code_line(line) return nil unless code_line (@statement_bounds ||= {})[code_line] ||= statement_bounds_at(code_line) end |