Skip to content

Commit 8cd73ff

Browse files
committed
Upgrade to latest rubocop version
1 parent 21d0f46 commit 8cd73ff

File tree

4 files changed

+368
-30
lines changed

4 files changed

+368
-30
lines changed

Gemfile.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ GEM
1212
byebug (11.1.3)
1313
coderay (1.1.3)
1414
diffy (3.4.3)
15-
json (2.7.2)
16-
language_server-protocol (3.17.0.3)
15+
json (2.10.1)
16+
language_server-protocol (3.17.0.4)
1717
method_source (1.0.0)
1818
minitest (5.25.4)
19-
parallel (1.24.0)
20-
parser (3.3.1.0)
19+
parallel (1.26.3)
20+
parser (3.3.7.1)
2121
ast (~> 2.4.1)
2222
racc
2323
pry (0.14.2)
@@ -26,26 +26,26 @@ GEM
2626
pry-byebug (3.10.1)
2727
byebug (~> 11.0)
2828
pry (>= 0.13, < 0.15)
29-
racc (1.7.3)
29+
racc (1.8.1)
3030
rainbow (3.1.1)
3131
rake (13.2.1)
32-
regexp_parser (2.9.0)
33-
rexml (3.2.6)
34-
rubocop (1.63.4)
32+
regexp_parser (2.10.0)
33+
rubocop (1.71.2)
3534
json (~> 2.3)
3635
language_server-protocol (>= 3.17.0)
3736
parallel (~> 1.10)
3837
parser (>= 3.3.0.2)
3938
rainbow (>= 2.2.2, < 4.0)
40-
regexp_parser (>= 1.8, < 3.0)
41-
rexml (>= 3.2.5, < 4.0)
42-
rubocop-ast (>= 1.31.1, < 2.0)
39+
regexp_parser (>= 2.9.3, < 3.0)
40+
rubocop-ast (>= 1.38.0, < 2.0)
4341
ruby-progressbar (~> 1.7)
44-
unicode-display_width (>= 2.4.0, < 3.0)
45-
rubocop-ast (1.31.3)
42+
unicode-display_width (>= 2.4.0, < 4.0)
43+
rubocop-ast (1.38.0)
4644
parser (>= 3.3.1.0)
4745
ruby-progressbar (1.13.0)
48-
unicode-display_width (2.5.0)
46+
unicode-display_width (3.1.4)
47+
unicode-emoji (~> 4.0, >= 4.0.4)
48+
unicode-emoji (4.0.4)
4949

5050
PLATFORMS
5151
ruby

bin/sort-cops

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require 'yaml'
5+
6+
def extract_cop_entries(content)
7+
# Extract all cop configurations (entries that start with a department name)
8+
cop_pattern = /^[A-Z][A-Za-z]+\/[A-Za-z]+:/
9+
cops = {}
10+
11+
current_cop = nil
12+
current_config = []
13+
14+
content.each_line do |line|
15+
if line.match?(cop_pattern)
16+
# Save previous cop if exists
17+
if current_cop
18+
cops[current_cop] = current_config.join
19+
end
20+
21+
# Start new cop
22+
current_cop = line.split(':').first
23+
current_config = [line]
24+
elsif current_cop
25+
current_config << line
26+
end
27+
end
28+
29+
# Save last cop
30+
if current_cop
31+
cops[current_cop] = current_config.join
32+
end
33+
34+
cops
35+
end
36+
37+
def sort_cops(file_path)
38+
content = File.read(file_path)
39+
40+
# Extract header (content before first cop)
41+
first_cop_pattern = /^[A-Z][A-Za-z]+\/[A-Za-z]+:/
42+
header_end = content.index(content.lines.find { |line| line.match?(first_cop_pattern) })
43+
header = content[0...header_end]
44+
45+
# Extract and sort cops
46+
cops = extract_cop_entries(content)
47+
sorted_cops = cops.sort_by { |name, _| name }
48+
49+
# Generate new content
50+
new_content = header
51+
52+
sorted_cops.each do |_, config|
53+
new_content << config
54+
end
55+
56+
# Write sorted content back to file
57+
File.write(file_path, new_content)
58+
end
59+
60+
if ARGV.empty?
61+
puts "Usage: ruby sort_cops.rb path/to/rubocop.yml"
62+
exit 1
63+
end
64+
65+
sort_cops(ARGV[0])
66+
puts "Successfully sorted cops in #{ARGV[0]}"

rubocop.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ Bundler/OrderedGems:
1919

2020

2121
# Gemspec Department
22+
<% if rubocop_version >= "1.65" %>
23+
Gemspec/AddRuntimeDependency:
24+
Enabled: false
25+
<% end %>
26+
2227
Gemspec/DeprecatedAttributeAssignment:
2328
Enabled: true
2429

@@ -335,6 +340,11 @@ Lint/AmbiguousRange:
335340
Lint/AmbiguousRegexpLiteral:
336341
Enabled: false
337342

343+
<% if rubocop_version >= "1.71" %>
344+
Lint/ArrayLiteralInRegexp:
345+
Enabled: false
346+
<% end %>
347+
338348
Lint/AssignmentInCondition:
339349
Enabled: false
340350

@@ -356,6 +366,11 @@ Lint/ConstantDefinitionInBlock:
356366
Lint/ConstantOverwrittenInRescue:
357367
Enabled: false
358368

369+
<% if rubocop_version >= "1.70" %>
370+
Lint/ConstantReassignment:
371+
Enabled: false
372+
<% end %>
373+
359374
Lint/Debugger:
360375
Enabled: false
361376

@@ -401,6 +416,11 @@ Lint/DuplicateRequire:
401416
Lint/DuplicateRescueException:
402417
Enabled: false
403418

419+
<% if rubocop_version >= "1.67" %>
420+
Lint/DuplicateSetElement:
421+
Enabled: false
422+
<% end %>
423+
404424
Lint/EachWithObjectArgument:
405425
Enabled: false
406426

@@ -455,6 +475,11 @@ Lint/FormatParameterMismatch:
455475
Lint/HashCompareByIdentity:
456476
Enabled: false
457477

478+
<% if rubocop_version >= "1.69" %>
479+
Lint/HashNewWithKeywordArgumentsAsDefault:
480+
Enabled: false
481+
<% end %>
482+
458483
Lint/IdentityComparison:
459484
Enabled: false
460485

@@ -530,6 +555,11 @@ Lint/NonLocalExitFromIterator:
530555
Lint/NumberedParameterAssignment:
531556
Enabled: false
532557

558+
<% if rubocop_version >= "1.69" %>
559+
Lint/NumericOperationWithConstantResult:
560+
Enabled: false
561+
<% end %>
562+
533563
Lint/OrAssignmentToConstant:
534564
Enabled: false
535565

@@ -635,6 +665,11 @@ Lint/ShadowedException:
635665
Lint/ShadowingOuterLocalVariable:
636666
Enabled: false
637667

668+
<% if rubocop_version >= "1.70" %>
669+
Lint/SharedMutableDefault:
670+
Enabled: false
671+
<% end %>
672+
638673
Lint/StructNewOverride:
639674
Enabled: false
640675

@@ -662,6 +697,11 @@ Lint/TripleQuotes:
662697
Lint/UnderscorePrefixedVariableName:
663698
Enabled: false
664699

700+
<% if rubocop_version >= "1.68" %>
701+
Lint/UnescapedBracketInRegexp:
702+
Enabled: false
703+
<% end %>
704+
665705
Lint/UnexpectedBlockArity:
666706
Enabled: false
667707

@@ -695,12 +735,22 @@ Lint/UselessAccessModifier:
695735
Lint/UselessAssignment:
696736
Enabled: false
697737

738+
<% if rubocop_version >= "1.69" %>
739+
Lint/UselessDefined:
740+
Enabled: false
741+
<% end %>
742+
698743
Lint/UselessElseWithoutRescue:
699744
Enabled: false
700745

701746
Lint/UselessMethodDefinition:
702747
Enabled: false
703748

749+
<% if rubocop_version >= "1.66" %>
750+
Lint/UselessNumericOperation:
751+
Enabled: false
752+
<% end %>
753+
704754
Lint/UselessRescue:
705755
Enabled: false
706756

@@ -848,6 +898,11 @@ Style/Alias:
848898
Enabled: false
849899
EnforcedStyle: prefer_alias_method
850900

901+
<% if rubocop_version >= "1.68" %>
902+
Style/AmbiguousEndlessMethodDefinition:
903+
Enabled: false
904+
<% end %>
905+
851906
Style/AndOr:
852907
Enabled: false
853908

@@ -872,6 +927,11 @@ Style/BeginBlock:
872927
Style/BisectedAttrAccessor:
873928
Enabled: false
874929

930+
<% if rubocop_version >= "1.68" %>
931+
Style/BitwisePredicate:
932+
Enabled: false
933+
<% end %>
934+
875935
Style/BlockComments:
876936
Enabled: false
877937

@@ -916,6 +976,11 @@ Style/ColonMethodCall:
916976
Style/ColonMethodDefinition:
917977
Enabled: false
918978

979+
<% if rubocop_version >= "1.68" %>
980+
Style/CombinableDefined:
981+
Enabled: false
982+
<% end %>
983+
919984
Style/CombinableLoops:
920985
Enabled: false
921986

@@ -944,6 +1009,11 @@ Style/DataInheritance:
9441009
Style/DefWithParentheses:
9451010
Enabled: false
9461011

1012+
<% if rubocop_version >= "1.69" %>
1013+
Style/DigChain:
1014+
Enabled: false
1015+
<% end %>
1016+
9471017
Style/Dir:
9481018
Enabled: false
9491019

@@ -1026,9 +1096,19 @@ Style/FetchEnvVar:
10261096
Style/FileEmpty:
10271097
Enabled: false
10281098

1099+
<% if rubocop_version >= "1.69" %>
1100+
Style/FileNull:
1101+
Enabled: false
1102+
<% end %>
1103+
10291104
Style/FileRead:
10301105
Enabled: false
10311106

1107+
<% if rubocop_version >= "1.69" %>
1108+
Style/FileTouch:
1109+
Enabled: false
1110+
<% end %>
1111+
10321112
Style/FileWrite:
10331113
Enabled: false
10341114

@@ -1075,9 +1155,16 @@ Style/HashExcept:
10751155
Style/HashLikeCase:
10761156
Enabled: false
10771157

1158+
<% if rubocop_version >= "1.71" %>
1159+
Style/HashSlice:
1160+
Enabled: false
1161+
<% end %>
1162+
10781163
Style/HashSyntax:
10791164
Enabled: false
1165+
<% if rubocop_version < "1.67" %>
10801166
EnforcedShorthandSyntax: either
1167+
<% end %>
10811168

10821169
Style/HashTransformKeys:
10831170
Enabled: false
@@ -1112,6 +1199,16 @@ Style/InfiniteLoop:
11121199
Style/InverseMethods:
11131200
Enabled: false
11141201

1202+
<% if rubocop_version >= "1.70" %>
1203+
Style/ItAssignment:
1204+
Enabled: false
1205+
<% end %>
1206+
1207+
<% if rubocop_version >= "1.68" %>
1208+
Style/KeywordArgumentsMerging:
1209+
Enabled: false
1210+
<% end %>
1211+
11151212
Style/KeywordParametersOrder:
11161213
Enabled: false
11171214

@@ -1366,6 +1463,11 @@ Style/RedundantInitialize:
13661463
Style/RedundantInterpolation:
13671464
Enabled: false
13681465

1466+
<% if rubocop_version >= "1.66" %>
1467+
Style/RedundantInterpolationUnfreeze:
1468+
Enabled: false
1469+
<% end %>
1470+
13691471
Style/RedundantLineContinuation:
13701472
Enabled: false
13711473

@@ -1424,6 +1526,11 @@ Style/ReturnNilInPredicateMethodDefinition:
14241526
Style/SafeNavigation:
14251527
Enabled: false
14261528

1529+
<% if rubocop_version >= "1.68" %>
1530+
Style/SafeNavigationChainLength:
1531+
Enabled: false
1532+
<% end %>
1533+
14271534
Style/Sample:
14281535
Enabled: false
14291536

@@ -1436,6 +1543,11 @@ Style/SelfAssignment:
14361543
Style/Semicolon:
14371544
Enabled: false
14381545

1546+
<% if rubocop_version >= "1.64" %>
1547+
Style/SendWithLiteralMethodName:
1548+
Enabled: false
1549+
<% end %>
1550+
14391551
Style/SignalException:
14401552
Enabled: false
14411553

@@ -1483,6 +1595,11 @@ Style/Strip:
14831595
Style/StructInheritance:
14841596
Enabled: false
14851597

1598+
<% if rubocop_version >= "1.64" %>
1599+
Style/SuperArguments:
1600+
Enabled: false
1601+
<% end %>
1602+
14861603
Style/SuperWithArgsParentheses:
14871604
Enabled: false
14881605

0 commit comments

Comments
 (0)