Class: RuboCop::Cop::Style::RbsInline::InvalidComment
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Style::RbsInline::InvalidComment
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/style/rbs_inline/invalid_comment.rb
Overview
IRB::Inline expects annotations comments to start with ‘#:` or `# @rbs`. This cop checks for comments that do not match the expected pattern.
Constant Summary collapse
- MSG =
'Invalid RBS annotation comment found.'- RBS_INLINE_KEYWORDS =
%w[inherits override use module-self generic skip module class].freeze
- RBS_INLINE_KEYWORD_PATTERN =
: Array
RBS_INLINE_KEYWORDS.join('|')
- SIGNATURE_PATTERN =
'\(.*\)\s*(\??\s*{.*?}\s*)?->\s*.*'- MISSING_HASH_COLON =
/\A#\s+#{SIGNATURE_PATTERN}/- SPACE_BEFORE_COLON =
/\A#\s+:\s*#{SIGNATURE_PATTERN}/- MIXED_ANNOTATION =
/\A#:\s+@rbs\s+/- MISSING_AT_SIGN =
/\A#\s*rbs\s+(#{RBS_INLINE_KEYWORD_PATTERN}|\S+:|%a\{.*\}|#{SIGNATURE_PATTERN})/
Instance Method Summary collapse
-
#on_new_investigation ⇒ Object
: void.
Instance Method Details
#on_new_investigation ⇒ Object
: void
38 39 40 41 42 |
# File 'lib/rubocop/cop/style/rbs_inline/invalid_comment.rb', line 38 def on_new_investigation #: void (processed_source.comments).each do |comment| check_comment(comment) end end |