Class: Laser::InlineCommentSpaceWarning
- Inherits:
-
LineWarning
show all
- Defined in:
- lib/laser/warnings/comment_spacing.rb
Overview
Warning for insufficient space between inline comments and code
Constant Summary
- OPTION_KEY =
:inline_comment_space
- DEFAULT_SPACE =
2
Instance Attribute Summary
Attributes inherited from Warning
#body, #file, #line_number, #name, #severity
Instance Method Summary
(collapse)
Methods inherited from LineWarning
options
Instance Method Details
- (Object) fix
21
22
23
24
25
26
|
# File 'lib/laser/warnings/comment_spacing.rb', line 21
def fix
= find_token(:on_comment)
= .col - 1
= line[0..].rstrip
+ (' ' * spacing) + .body
end
|
- (Boolean) match?(line = self.body)
11
12
13
14
15
16
17
18
19
|
# File 'lib/laser/warnings/comment_spacing.rb', line 11
def match?(line = self.body)
return false unless = find_token(:on_comment)
= line[0,.col].lstrip
return false if [0,1] == '#'
stripped = .rstrip
return false if stripped.empty?
padding_size = .size - stripped.size
return spacing != padding_size
end
|
- (Object) spacing
28
29
30
|
# File 'lib/laser/warnings/comment_spacing.rb', line 28
def spacing
@settings[OPTION_KEY] || DEFAULT_SPACE
end
|