File tree 3 files changed +42
-1
lines changed
3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 3
3
## Master (Unreleased)
4
4
5
5
- Fix false positive in ` RSpec/Pending ` , where it would mark the default block ` it ` as an offense. ([ @bquorning ] )
6
+ - Fix issue when ` Style/ContextWording ` is configured with a Prefix being interpreted as a boolean, like ` on ` . ([ @sakuro ] )
6
7
7
8
## 3.5.0 (2025-02-16)
8
9
@@ -1040,6 +1041,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
1040
1041
[ @rrosenblum ] : https://github.com/rrosenblum
1041
1042
[ @rspeicher ] : https://github.com/rspeicher
1042
1043
[ @rst-j ] : https://github.com/RST-J
1044
+ [ @sakuro ] : https://github.com/sakuro
1043
1045
[ @samrjenkins ] : https://github.com/samrjenkins
1044
1046
[ @schmijos ] : https://github.com/schmijos
1045
1047
[ @seanpdoyle ] : https://github.com/seanpdoyle
Original file line number Diff line number Diff line change @@ -115,7 +115,12 @@ def expect_patterns
115
115
end
116
116
117
117
def prefixes
118
- Array ( cop_config . fetch ( 'Prefixes' , [ ] ) )
118
+ Array ( cop_config . fetch ( 'Prefixes' , [ ] ) ) . tap do |prefixes |
119
+ non_strings = prefixes . reject { |pre | pre . is_a? ( String ) }
120
+ unless non_strings . empty?
121
+ raise "Non-string prefixes #{ non_strings . inspect } detected."
122
+ end
123
+ end
119
124
end
120
125
end
121
126
end
Original file line number Diff line number Diff line change 228
228
RUBY
229
229
end
230
230
end
231
+
232
+ context 'when `Prefixes: [on]' do
233
+ let ( :cop_config ) do
234
+ YAML . safe_load ( <<-CONFIG )
235
+ Prefixes:
236
+ - on # evaluates to true
237
+ CONFIG
238
+ end
239
+
240
+ it 'fails' do
241
+ expect do
242
+ expect_no_offenses ( <<~RUBY )
243
+ context 'on Linux' do
244
+ end
245
+ RUBY
246
+ end . to raise_error ( /Non-string prefixes .+ detected/ )
247
+ end
248
+ end
249
+
250
+ context 'when `Prefixes: ["on"]' do
251
+ let ( :cop_config ) do
252
+ YAML . safe_load ( <<-CONFIG )
253
+ Prefixes:
254
+ - "on"
255
+ CONFIG
256
+ end
257
+
258
+ it 'does not fail' do
259
+ expect { expect_no_offenses ( <<~RUBY ) } . not_to raise_error
260
+ context 'on Linux' do
261
+ end
262
+ RUBY
263
+ end
264
+ end
231
265
end
You can’t perform that action at this time.
0 commit comments