Class: RuboCop::Cop::Style::RbsInline::MethodCommentSpacing
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Style::RbsInline::MethodCommentSpacing
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp, CommentParser, SourceCodeHelper
- Defined in:
- lib/rubocop/cop/style/rbs_inline/method_comment_spacing.rb
Overview
Checks that method-related ‘@rbs` annotations are placed immediately before method definitions.
Method-related annotations (‘@rbs param`, `@rbs return`, `@rbs &block`, `@rbs override`, `@rbs skip`, `@rbs %a…`, `# @rbs (…) -> Type`, `#: (…) -> Type`) must be placed directly before the method definition they describe, without any blank lines in between. These annotations should not appear in standalone locations without an immediately following method definition.
Constant Summary collapse
- MSG =
'Method-related `@rbs` annotation must be immediately before a method definition.'- MSG_WITH_BLANK_LINE =
'Remove blank line between method annotation and method definition.'- METHOD_DEFINITION_PATTERN =
/\A(?:(?:private|protected|public|private_class_method|module_function)\s+)?def\s/
Instance Attribute Summary collapse
-
#processed_comments ⇒ Object
readonly
: Array.
Attributes included from CommentParser
Instance Method Summary collapse
-
#on_new_investigation ⇒ Object
: void.
Methods included from CommentParser
#find_doc_style_param_annotations, #find_doc_style_return_annotation, #find_last_consecutive_comment, #find_leading_annotation, #find_method_type_signature_comments, #find_trailing_comment, #overload_type_signatures?, #parse_comments
Methods included from SourceCodeHelper
#annotation_range, #blank_line?, #char_at, #character_offset, #comment_at, #comment_range, #line_range, #location_to_range, #source_code_at
Instance Attribute Details
#processed_comments ⇒ Object (readonly)
: Array
69 70 71 |
# File 'lib/rubocop/cop/style/rbs_inline/method_comment_spacing.rb', line 69 def processed_comments @processed_comments end |
Instance Method Details
#on_new_investigation ⇒ Object
: void
71 72 73 74 75 |
# File 'lib/rubocop/cop/style/rbs_inline/method_comment_spacing.rb', line 71 def on_new_investigation #: void @processed_comments = [] parse_comments check_method_comment_spacing end |