Skip to content

Commit 3cb7fd9

Browse files
committed
Modernize RuboCop usage, add/enable performance, minitest, and rake cops
1 parent 3ae58e3 commit 3cb7fd9

File tree

3 files changed

+162
-31
lines changed

3 files changed

+162
-31
lines changed

.rubocop.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
inherit_from: .rubocop_todo.yml
22

3+
plugins:
4+
- rubocop-performance
5+
- rubocop-minitest
6+
- rubocop-rake
7+
38
AllCops:
49
TargetRubyVersion: 3.0
510
DisplayCopNames: true
611
Exclude:
712
- "tasks/**/*"
813
- "vendor/**/*"
14+
- "lib/rouge/lexers/**/keywords.rb"
15+
- "lib/rouge/lexers/**/builtins.rb"
16+
NewCops: enable
917

1018
Style:
1119
Enabled: false
@@ -39,3 +47,15 @@ Lint/RedundantSplatExpansion:
3947

4048
Lint/IneffectiveAccessModifier:
4149
Enabled: false
50+
51+
Lint/AmbiguousOperatorPrecedence:
52+
Enabled: false
53+
54+
Naming/BlockForwarding:
55+
Enabled: false
56+
57+
Performance/RegexpMatch:
58+
Enabled: false
59+
60+
Performance/ConstantRegexp:
61+
Enabled: false

.rubocop_todo.yml

Lines changed: 139 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2022-01-26 19:45:20 UTC using RuboCop version 1.11.0.
3+
# on 2026-02-05 01:54:50 UTC using RuboCop version 1.84.1.
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
77
# versions of RuboCop, may require this file to be generated again.
88

99
# Offense count: 1
10-
# Configuration parameters: Include.
11-
# Include: **/*.gemspec
12-
Gemspec/RequiredRubyVersion:
10+
# This cop supports safe autocorrection (--autocorrect).
11+
Gemspec/RequireMFA:
1312
Exclude:
1413
- 'rouge.gemspec'
1514

@@ -22,15 +21,27 @@ Lint/ConstantDefinitionInBlock:
2221
- 'spec/lexer_spec.rb'
2322
- 'spec/theme_spec.rb'
2423

25-
# Offense count: 27
26-
Lint/MissingSuper:
24+
# Offense count: 37
25+
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
26+
Lint/DuplicateBranch:
2727
Enabled: false
2828

29-
# Offense count: 2
30-
Lint/MixedRegexpCaptureTypes:
29+
# Offense count: 108
30+
# This cop supports safe autocorrection (--autocorrect).
31+
Lint/DuplicateSetElement:
32+
Enabled: false
33+
34+
# Offense count: 3
35+
# Configuration parameters: AllowComments, AllowEmptyLambdas.
36+
Lint/EmptyBlock:
3137
Exclude:
32-
- 'lib/rouge/lexers/elixir.rb'
33-
- 'lib/rouge/lexers/lasso.rb'
38+
- 'lib/rouge/lexers/nix.rb'
39+
- 'spec/lexers/terraform_spec.rb'
40+
41+
# Offense count: 27
42+
# Configuration parameters: AllowedParentClasses.
43+
Lint/MissingSuper:
44+
Enabled: false
3445

3546
# Offense count: 4
3647
Lint/NestedPercentLiteral:
@@ -40,28 +51,40 @@ Lint/NestedPercentLiteral:
4051
- 'lib/rouge/lexers/powershell.rb'
4152
- 'spec/lexers/j_spec.rb'
4253

43-
# Offense count: 1
44-
# Cop supports --auto-correct.
45-
Lint/NonDeterministicRequireOrder:
46-
Exclude:
47-
- 'spec/spec_helper.rb'
48-
4954
# Offense count: 1
5055
Lint/OutOfRangeRegexpRef:
5156
Exclude:
5257
- 'lib/rouge/tex_theme_renderer.rb'
5358

5459
# Offense count: 2
55-
# Cop supports --auto-correct.
56-
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
57-
Lint/UselessAccessModifier:
60+
# This cop supports safe autocorrection (--autocorrect).
61+
Lint/RedundantRequireStatement:
5862
Exclude:
59-
- 'lib/rouge/cli.rb'
63+
- 'lib/rouge/lexer.rb'
64+
- 'lib/rouge/lexers/digdag.rb'
6065

6166
# Offense count: 1
62-
Naming/AccessorMethodName:
67+
Lint/SharedMutableDefault:
6368
Exclude:
64-
- 'lib/rouge/theme.rb'
69+
- 'lib/rouge/lexers/j.rb'
70+
71+
# Offense count: 1
72+
# This cop supports safe autocorrection (--autocorrect).
73+
# Configuration parameters: EnforcedStyle.
74+
# SupportedStyles: strict, consistent
75+
Lint/SymbolConversion:
76+
Exclude:
77+
- 'lib/rouge/lexers/postscript.rb'
78+
79+
# Offense count: 1
80+
Lint/ToEnumArguments:
81+
Exclude:
82+
- 'lib/rouge/lexer.rb'
83+
84+
# Offense count: 1
85+
Lint/UselessConstantScoping:
86+
Exclude:
87+
- 'lib/rouge/formatters/terminal256.rb'
6588

6689
# Offense count: 43
6790
Naming/ConstantName:
@@ -70,7 +93,7 @@ Naming/ConstantName:
7093
- 'lib/rouge/themes/gruvbox.rb'
7194

7295
# Offense count: 21
73-
# Cop supports --auto-correct.
96+
# This cop supports safe autocorrection (--autocorrect).
7497
# Configuration parameters: EnforcedStyle.
7598
# SupportedStyles: lowercase, uppercase
7699
Naming/HeredocDelimiterCase:
@@ -86,15 +109,18 @@ Naming/HeredocDelimiterCase:
86109
- 'spec/theme_spec.rb'
87110
- 'spec/visual_spec.rb'
88111

89-
# Offense count: 4
112+
# Offense count: 8
90113
# Configuration parameters: ForbiddenDelimiters.
91-
# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
114+
# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))
92115
Naming/HeredocDelimiterNaming:
93116
Exclude:
94117
- 'lib/rouge/tex_theme_renderer.rb'
118+
- 'spec/lexers/mason_spec.rb'
119+
- 'spec/lexers/matlab_spec.rb'
95120
- 'spec/lexers/swift_spec.rb'
96121

97122
# Offense count: 8
123+
# This cop supports unsafe autocorrection (--autocorrect-all).
98124
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
99125
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
100126
Naming/MemoizedInstanceVariableName:
@@ -107,21 +133,33 @@ Naming/MemoizedInstanceVariableName:
107133
- 'lib/rouge/lexers/yang.rb'
108134

109135
# Offense count: 16
110-
# Configuration parameters: EnforcedStyle, IgnoredPatterns.
136+
# Configuration parameters: EnforcedStyle, AllowedPatterns, ForbiddenIdentifiers, ForbiddenPatterns.
111137
# SupportedStyles: snake_case, camelCase
138+
# ForbiddenIdentifiers: __id__, __send__
112139
Naming/MethodName:
113140
Exclude:
114141
- 'lib/rouge/lexers/igorpro.rb'
115142
- 'lib/rouge/lexers/xpath.rb'
116143

117144
# Offense count: 68
118145
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
119-
# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
146+
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
120147
Naming/MethodParameterName:
121148
Enabled: false
122149

150+
# Offense count: 4
151+
# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
152+
# AllowedMethods: call
153+
# WaywardPredicates: infinite?, nonzero?
154+
Naming/PredicateMethod:
155+
Exclude:
156+
- 'lib/rouge/guessers/util.rb'
157+
- 'lib/rouge/lexers/javascript.rb'
158+
- 'lib/rouge/regex_lexer.rb'
159+
- 'spec/visual/app.rb'
160+
123161
# Offense count: 40
124-
# Configuration parameters: EnforcedStyle, AllowedIdentifiers.
162+
# Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns, ForbiddenIdentifiers, ForbiddenPatterns.
125163
# SupportedStyles: snake_case, camelCase
126164
Naming/VariableName:
127165
Exclude:
@@ -133,10 +171,81 @@ Naming/VariableName:
133171
- 'lib/rouge/lexers/xpath.rb'
134172

135173
# Offense count: 5
136-
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers.
174+
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
137175
# SupportedStyles: snake_case, normalcase, non_integer
138-
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
176+
# AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
139177
Naming/VariableNumber:
140178
Exclude:
141179
- 'lib/rouge/lexers/c.rb'
142180
- 'lib/rouge/themes/gruvbox.rb'
181+
182+
# Offense count: 1
183+
# This cop supports unsafe autocorrection (--autocorrect-all).
184+
Performance/InefficientHashSearch:
185+
Exclude:
186+
- 'lib/rouge/lexers/apache.rb'
187+
188+
# Offense count: 2
189+
# This cop supports unsafe autocorrection (--autocorrect-all).
190+
Performance/MapCompact:
191+
Exclude:
192+
- 'lib/rouge/guessers/glob_mapping.rb'
193+
- 'lib/rouge/guessers/modeline.rb'
194+
195+
# Offense count: 1
196+
Performance/MapMethodChain:
197+
Exclude:
198+
- 'lib/rouge/regex_lexer.rb'
199+
200+
# Offense count: 7
201+
Performance/MethodObjectAsBlock:
202+
Exclude:
203+
- 'lib/rouge/cli.rb'
204+
- 'lib/rouge/formatters/tex.rb'
205+
- 'lib/rouge/lexers/console.rb'
206+
- 'spec/visual/app.rb'
207+
208+
# Offense count: 10
209+
# This cop supports safe autocorrection (--autocorrect).
210+
Performance/RedundantBlockCall:
211+
Exclude:
212+
- 'lib/rouge/guesser.rb'
213+
- 'lib/rouge/lexer.rb'
214+
- 'lib/rouge/regex_lexer.rb'
215+
- 'lib/rouge/token.rb'
216+
- 'lib/rouge/util.rb'
217+
218+
# Offense count: 1
219+
# This cop supports safe autocorrection (--autocorrect).
220+
Performance/RedundantSplitRegexpArgument:
221+
Exclude:
222+
- 'lib/rouge/guessers/modeline.rb'
223+
224+
# Offense count: 12
225+
# This cop supports unsafe autocorrection (--autocorrect-all).
226+
Performance/StringInclude:
227+
Exclude:
228+
- 'lib/rouge/cli.rb'
229+
- 'lib/rouge/lexers/hack.rb'
230+
- 'lib/rouge/lexers/igorpro.rb'
231+
- 'lib/rouge/lexers/lua.rb'
232+
- 'lib/rouge/lexers/moonscript.rb'
233+
- 'spec/formatters/html_pygments_spec.rb'
234+
- 'spec/lexers/escape_spec.rb'
235+
- 'spec/theme_spec.rb'
236+
237+
# Offense count: 5
238+
# This cop supports unsafe autocorrection (--autocorrect-all).
239+
Performance/UnfreezeString:
240+
Exclude:
241+
- 'lib/rouge/cli.rb'
242+
- 'lib/rouge/formatter.rb'
243+
- 'lib/rouge/formatters/terminal_truecolor.rb'
244+
- 'lib/rouge/tex_theme_renderer.rb'
245+
- 'spec/lexers_spec.rb'
246+
247+
# Offense count: 2
248+
# This cop supports safe autocorrection (--autocorrect).
249+
Rake/Desc:
250+
Exclude:
251+
- 'Rakefile'

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ group :development do
2323
gem 'git'
2424
gem 'yard'
2525

26-
gem 'rubocop', '~> 1.0', '<= 1.11'
26+
gem 'rubocop'
2727
gem 'rubocop-performance'
28+
gem 'rubocop-minitest'
29+
gem 'rubocop-rake'
2830

2931
# docs
3032
gem 'github-markup'

0 commit comments

Comments
 (0)