Skip to content

Commit fac0bc6

Browse files
authored
Safe auto-correct and manually fix RuboCop infractions and regen todo (#2206)
1 parent 7d1bf7f commit fac0bc6

34 files changed

+134
-190
lines changed

.rubocop_todo.yml

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2026-02-13 03:42:44 UTC using RuboCop version 1.84.2.
3+
# on 2026-02-13 03:44:28 UTC using RuboCop version 1.84.2.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -20,10 +20,11 @@ Lint/ConstantDefinitionInBlock:
2020
Lint/DuplicateBranch:
2121
Enabled: false
2222

23-
# Offense count: 149
23+
# Offense count: 41
2424
# This cop supports safe autocorrection (--autocorrect).
2525
Lint/DuplicateSetElement:
26-
Enabled: false
26+
Exclude:
27+
- 'lib/rouge/lexers/glsl.rb'
2728

2829
# Offense count: 3
2930
# Configuration parameters: AllowComments, AllowEmptyLambdas.
@@ -55,14 +56,6 @@ Lint/SharedMutableDefault:
5556
Exclude:
5657
- 'lib/rouge/lexers/j.rb'
5758

58-
# Offense count: 1
59-
# This cop supports safe autocorrection (--autocorrect).
60-
# Configuration parameters: EnforcedStyle.
61-
# SupportedStyles: strict, consistent
62-
Lint/SymbolConversion:
63-
Exclude:
64-
- 'lib/rouge/lexers/postscript.rb'
65-
6659
# Offense count: 1
6760
Lint/ToEnumArguments:
6861
Exclude:
@@ -79,23 +72,6 @@ Naming/ConstantName:
7972
- 'lib/rouge/lexers/eiffel.rb'
8073
- 'lib/rouge/themes/gruvbox.rb'
8174

82-
# Offense count: 21
83-
# This cop supports safe autocorrection (--autocorrect).
84-
# Configuration parameters: EnforcedStyle.
85-
# SupportedStyles: lowercase, uppercase
86-
Naming/HeredocDelimiterCase:
87-
Exclude:
88-
- 'rouge.gemspec'
89-
- 'spec/lexers/diff_spec.rb'
90-
- 'spec/lexers/haml_spec.rb'
91-
- 'spec/lexers/html_spec.rb'
92-
- 'spec/lexers/mason_spec.rb'
93-
- 'spec/lexers/matlab_spec.rb'
94-
- 'spec/lexers/shell_spec.rb'
95-
- 'spec/plugins/redcarpet_spec.rb'
96-
- 'spec/theme_spec.rb'
97-
- 'spec/visual_spec.rb'
98-
9975
# Offense count: 8
10076
# Configuration parameters: ForbiddenDelimiters.
10177
# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))
@@ -186,22 +162,6 @@ Performance/MethodObjectAsBlock:
186162
- 'lib/rouge/lexers/console.rb'
187163
- 'spec/visual/app.rb'
188164

189-
# Offense count: 10
190-
# This cop supports safe autocorrection (--autocorrect).
191-
Performance/RedundantBlockCall:
192-
Exclude:
193-
- 'lib/rouge/guesser.rb'
194-
- 'lib/rouge/lexer.rb'
195-
- 'lib/rouge/regex_lexer.rb'
196-
- 'lib/rouge/token.rb'
197-
- 'lib/rouge/util.rb'
198-
199-
# Offense count: 1
200-
# This cop supports safe autocorrection (--autocorrect).
201-
Performance/RedundantSplitRegexpArgument:
202-
Exclude:
203-
- 'lib/rouge/guessers/modeline.rb'
204-
205165
# Offense count: 12
206166
# This cop supports unsafe autocorrection (--autocorrect-all).
207167
Performance/StringInclude:

lib/rouge/guesser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def collect_best(lexers, opts={}, &scorer)
3535
best_score = opts[:threshold]
3636

3737
lexers.each do |lexer|
38-
score = scorer.call(lexer)
38+
score = yield(lexer)
3939

4040
next if score.nil?
4141

lib/rouge/guessers/modeline.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def filter(lexers)
3131

3232
source_text = get_source(@source)
3333

34-
lines = source_text.split(/\n/)
34+
lines = source_text.split("\n")
3535

3636
search_space = (lines.first(@lines) + lines.last(@lines)).join("\n")
3737

lib/rouge/lexer.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def guess(info={}, &fallback)
183183
return lexers[0] if lexers.size == 1
184184

185185
if fallback
186-
fallback.call(lexers)
186+
yield(lexers)
187187
else
188188
raise Guesser::Ambiguous.new(lexers)
189189
end
@@ -420,7 +420,7 @@ def bool_option(name, &default)
420420
if @options.key?(name_str)
421421
as_bool(@options[name_str])
422422
else
423-
default ? default.call : false
423+
default ? yield : false
424424
end
425425
end
426426

@@ -446,13 +446,13 @@ def hash_option(name, defaults, &val_cast)
446446

447447
base = @options.delete(name.to_s)
448448
base = {} unless base.is_a?(Hash)
449-
base.each { |k, v| out[k.to_s] = val_cast ? val_cast.call(v) : v }
449+
base.each { |k, v| out[k.to_s] = val_cast ? yield(v) : v }
450450

451451
@options.keys.each do |key|
452452
next unless key =~ /(\w+)\[(\w+)\]/ and $1 == name
453453
value = @options.delete(key)
454454

455-
out[$2] = val_cast ? val_cast.call(value) : value
455+
out[$2] = val_cast ? yield(value) : value
456456
end
457457

458458
out
@@ -513,12 +513,12 @@ def continue_lex(string, &b)
513513
next
514514
end
515515

516-
b.call(last_token, last_val) if last_token
516+
yield(last_token, last_val) if last_token
517517
last_token = tok
518518
last_val = val
519519
end
520520

521-
b.call(last_token, last_val) if last_token
521+
yield(last_token, last_val) if last_token
522522
end
523523

524524
# delegated to {Lexer.tag}

lib/rouge/lexers/apex.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def self.declarations
3030
def self.soql
3131
@soql ||= Set.new %w(
3232
SELECT FROM WHERE UPDATE LIKE TYPEOF END USING SCOPE WITH DATA
33-
CATEGORY GROUP BY ROLLUP CUBE HAVING ORDER BY ASC DESC NULLS FIRST
34-
LAST LIMIT OFFSET FOR VIEW REFERENCE UPDATE TRACKING VIEWSTAT OR AND
33+
CATEGORY GROUP BY ROLLUP CUBE HAVING ORDER ASC DESC NULLS FIRST
34+
LAST LIMIT OFFSET FOR VIEW REFERENCE TRACKING VIEWSTAT OR AND
3535
)
3636
end
3737

lib/rouge/lexers/brightscript.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,18 @@ def self.builtins
6464
@builtins ||= Set.new %w(
6565
roAppendFile roAppInfo roAppManager roArray roAssociativeArray
6666
roAudioGuide roAudioMetadata roAudioPlayer roAudioPlayerEvent
67-
roAudioResourceroBitmap roBoolean roBoolean roBrightPackage roBrSub
67+
roAudioResourceroBitmap roBoolean roBrightPackage roBrSub
6868
roButton roByteArray roCaptionRenderer roCaptionRendererEvent
6969
roCecInterface roCECStatusEvent roChannelStore roChannelStoreEvent
7070
roClockWidget roCodeRegistrationScreen
71-
roCodeRegistrationScreenEventroCompositor roControlDown roControlPort
72-
roControlPort roControlUp roCreateFile roDatagramReceiver
71+
roCodeRegistrationScreenEventroCompositor roControlDown roControlPort roControlUp roCreateFile roDatagramReceiver
7372
roDatagramSender roDataGramSocket roDateTime roDeviceInfo
7473
roDeviceInfoEvent roDoubleroEVPCipher roEVPDigest roFileSystem
7574
roFileSystemEvent roFloat roFont roFontMetrics roFontRegistry
7675
roFunction roGlobal roGpio roGridScreen roGridScreenEvent
7776
roHdmiHotPlugEventroHdmiStatus roHdmiStatusEvent roHMAC roHttpAgent
7877
roImageCanvas roImageCanvasEvent roImageMetadata roImagePlayer
79-
roImageWidgetroInput roInputEvent roInt roInt roInvalid roInvalid
78+
roImageWidgetroInput roInputEvent roInt roInvalid
8079
roIRRemote roKeyboard roKeyboardPress roKeyboardScreen
8180
roKeyboardScreenEventroList roListScreen roListScreenEvent
8281
roLocalization roLongInteger roMessageDialog roMessageDialogEvent

lib/rouge/lexers/coq.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def self.ltac
3838
edestruct constructor econstructor eexists exists
3939
f_equal refine instantiate revert simpl
4040
specialize generalize dependent red induction
41-
beta iota zeta delta exfalso autorewrite setoid_rewrite
41+
beta iota zeta delta exfalso autorewrite
4242
compute vm_compute native_compute
4343
)
4444
end

lib/rouge/lexers/css.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def self.builtins
126126
above absolute accumulate add additive all alpha alphabetic
127127
alternate alternate-reverse always armenian aural auto auto-fill
128128
auto-fit avoid backwards balance baseline behind below bidi-override
129-
blink block bold bolder border-box both bottom bottom break-spaces
129+
blink block bold bolder border-box both bottom break-spaces
130130
capitalize center center-left center-right circle cjk-ideographic
131131
close-quote closest-corner closest-side collapse
132132
color color-burn color-dodge column column-reverse

lib/rouge/lexers/ecl.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ def self.functions
4242
row rowdiff sample set sin sinh sizeof soapcall sort sorted sqrt
4343
stepped stored sum table tan tanh thisnode topn tounicode toxml
4444
transfer transform trim truncate typeof ungroup unicodeorder variance
45-
which workunit xmldecode xmlencode xmltext xmlunicode apply assert
46-
build buildindex evaluate fail keydiff keypatch loadxml nothor notify
47-
output parallel sequential soapcall wait
45+
which workunit xmldecode xmlencode xmltext xmlunicode assert
46+
build buildindex fail keydiff keypatch loadxml nothor notify
47+
output parallel sequential wait
4848
)
4949
end
5050

lib/rouge/lexers/factor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def self.builtins
2525
do unless* if* loop bi-curry* drop when* assert= retainstack
2626
assert? -rot execute 2bi@ 2tri@ boa with either? 3drop bi
2727
curry? datastack until 3dip over 3curry tri-curry* tri-curry@
28-
swap and 2nip throw bi-curry (clone) hashcode* compose 2dip if
28+
swap and 2nip throw bi-curry (clone) hashcode* compose 2dip
2929
3tri unless compose? tuple keep 2curry equal? assert tri 2drop
3030
most <wrapper> boolean? identity-hashcode identity-tuple?
3131
null new dip bi-curry@ rot xor identity-tuple boolean

0 commit comments

Comments
 (0)