Class: RuboCop::Cop::Style::RbsInline::VariableCommentSpacing

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
CommentParser, SourceCodeHelper
Defined in:
lib/rubocop/cop/style/rbs_inline/variable_comment_spacing.rb

Overview

Checks that ‘@rbs` variable comments are followed by a blank line.

RBS::Inline requires ‘@rbs` comments for instance variables, class variables, and class instance variables to be standalone comments, meaning they should not have any code immediately following them. A blank line after the variable comment ensures proper separation.

Examples:

# bad
# @rbs @ivar: Integer
# @rbs @@cvar: Float
# @rbs self.@civar: String
def method
end

# good
# @rbs @ivar: Integer
# @rbs @@cvar: Float
# @rbs self.@civar: String

def method
end

Constant Summary collapse

MSG =
'`@rbs` variable comment must be followed by a blank line.'
VARIABLE_COMMENT_PATTERN =
/\A#\s+@rbs\s+(?:self\.)?@@?[a-zA-Z_]/

Instance Attribute Summary

Attributes included from CommentParser

#parsed_comments

Instance Method Summary collapse

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 Method Details

#on_new_investigationObject

: void



41
42
43
# File 'lib/rubocop/cop/style/rbs_inline/variable_comment_spacing.rb', line 41

def on_new_investigation #: void
  check_variable_comment_spacing
end