File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 33## Master (Unreleased)
44
55- 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 ] )
67
78## 3.5.0 (2025-02-16)
89
@@ -1040,6 +1041,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
10401041[ @rrosenblum ] : https://github.com/rrosenblum
10411042[ @rspeicher ] : https://github.com/rspeicher
10421043[ @rst-j ] : https://github.com/RST-J
1044+ [ @sakuro ] : https://github.com/sakuro
10431045[ @samrjenkins ] : https://github.com/samrjenkins
10441046[ @schmijos ] : https://github.com/schmijos
10451047[ @seanpdoyle ] : https://github.com/seanpdoyle
Original file line number Diff line number Diff line change @@ -115,7 +115,12 @@ def expect_patterns
115115 end
116116
117117 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
119124 end
120125 end
121126 end
Original file line number Diff line number Diff line change 228228 RUBY
229229 end
230230 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
231265end
You can’t perform that action at this time.
0 commit comments