File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,8 @@ class MultilineMemoization < Base
34
34
include ConfigurableEnforcedStyle
35
35
extend AutoCorrector
36
36
37
- MSG = 'Wrap multiline memoization blocks in `begin` and `end`.'
37
+ KEYWORD_MSG = 'Wrap multiline memoization blocks in `begin` and `end`.'
38
+ BRACES_MSG = 'Wrap multiline memoization blocks in `(` and `)`.'
38
39
39
40
def on_or_asgn ( node )
40
41
_lhs , rhs = *node
@@ -51,6 +52,10 @@ def on_or_asgn(node)
51
52
end
52
53
end
53
54
55
+ def message ( _node )
56
+ style == :braces ? BRACES_MSG : KEYWORD_MSG
57
+ end
58
+
54
59
private
55
60
56
61
def bad_rhs? ( rhs )
Original file line number Diff line number Diff line change 134
134
it 'registers an offense for begin...end block on first line' do
135
135
expect_offense ( <<~RUBY )
136
136
foo ||= begin
137
- ^^^^^^^^^^^^^ Wrap multiline memoization blocks in `begin ` and `end `.
137
+ ^^^^^^^^^^^^^ Wrap multiline memoization blocks in `( ` and `) `.
138
138
bar
139
139
baz
140
140
end
150
150
it 'registers an offense for begin...end block on following line' do
151
151
expect_offense ( <<~RUBY )
152
152
foo ||=
153
- ^^^^^^^ Wrap multiline memoization blocks in `begin ` and `end `.
153
+ ^^^^^^^ Wrap multiline memoization blocks in `( ` and `) `.
154
154
begin
155
155
bar
156
156
baz
You can’t perform that action at this time.
0 commit comments