Skip to content

Commit 387e13a

Browse files
authored
chore(style): use Ruby 3.4 to run RuboCop with the latest version (#1408)
- Update .rubocop_todo.yml by `rubocop --auto-gen-config`. - One offense is fixed by `--autocorrect`. - Update .github/workflows/rubocop.yml to use Ruby 3.4, and actions/checkout@v5. - Update Gemfile to use the latest RuboCop (1.80.2). Signed-off-by: Takuya Noguchi <[email protected]>
1 parent 84c99f6 commit 387e13a

File tree

4 files changed

+29
-43
lines changed

4 files changed

+29
-43
lines changed

.github/workflows/rubocop.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ jobs:
88
env:
99
BUNDLE_WITHOUT: development
1010
steps:
11-
- uses: actions/checkout@v3
12-
- name: Set up Ruby 2.6
11+
- uses: actions/checkout@v5
12+
- name: Set up Ruby 3.4
1313
uses: ruby/setup-ruby@v1
1414
with:
15-
ruby-version: 2.6
15+
ruby-version: 3.4
1616
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
1717
- name: Run RuboCop
1818
run: bundle exec rubocop

.rubocop_todo.yml

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2022-05-30 13:48:55 UTC using RuboCop version 1.30.0.
3+
# on 2025-09-23 00:00:00 UTC using RuboCop version 1.80.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
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 3
10-
# This cop supports safe autocorrection (--autocorrect).
11-
Layout/HeredocIndentation:
12-
Exclude:
13-
- 'support/ruby_enc_to_mysql.rb'
14-
- 'tasks/compile.rake'
15-
169
# Offense count: 2
1710
# Configuration parameters: AllowedMethods.
1811
# AllowedMethods: enums
@@ -22,23 +15,24 @@ Lint/ConstantDefinitionInBlock:
2215
- 'tasks/rspec.rake'
2316

2417
# Offense count: 1
18+
# Configuration parameters: AllowedParentClasses.
2519
Lint/MissingSuper:
2620
Exclude:
2721
- 'lib/mysql2/em.rb'
2822

2923
# Offense count: 2
30-
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
24+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
3125
Metrics/AbcSize:
32-
Max: 94
26+
Max: 89
3327

3428
# Offense count: 34
35-
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
36-
# IgnoredMethods: refine
29+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
30+
# AllowedMethods: refine
3731
Metrics/BlockLength:
38-
Max: 592
32+
Max: 477
3933

4034
# Offense count: 1
41-
# Configuration parameters: CountBlocks.
35+
# Configuration parameters: CountBlocks, CountModifierForms.
4236
Metrics/BlockNesting:
4337
Max: 5
4438

@@ -48,34 +42,28 @@ Metrics/ClassLength:
4842
Max: 141
4943

5044
# Offense count: 3
51-
# Configuration parameters: IgnoredMethods.
45+
# Configuration parameters: AllowedMethods, AllowedPatterns.
5246
Metrics/CyclomaticComplexity:
53-
Max: 34
47+
Max: 32
5448

5549
# Offense count: 6
56-
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
50+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
5751
Metrics/MethodLength:
58-
Max: 57
52+
Max: 52
5953

6054
# Offense count: 2
61-
# Configuration parameters: IgnoredMethods.
55+
# Configuration parameters: AllowedMethods, AllowedPatterns.
6256
Metrics/PerceivedComplexity:
63-
Max: 32
57+
Max: 30
6458

6559
# Offense count: 2
6660
# Configuration parameters: ForbiddenDelimiters.
67-
# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
61+
# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))
6862
Naming/HeredocDelimiterNaming:
6963
Exclude:
7064
- 'tasks/compile.rake'
7165

72-
# Offense count: 1
73-
# This cop supports unsafe autocorrection (--autocorrect-all).
74-
Style/CaseLikeIf:
75-
Exclude:
76-
- 'ext/mysql2/extconf.rb'
77-
78-
# Offense count: 8
66+
# Offense count: 9
7967
# Configuration parameters: AllowedConstants.
8068
Style/Documentation:
8169
Exclude:
@@ -100,13 +88,13 @@ Style/ExpandPathArguments:
10088
- 'support/mysql_enc_to_ruby.rb'
10189
- 'tasks/compile.rake'
10290

103-
# Offense count: 15
91+
# Offense count: 17
10492
# Configuration parameters: AllowedVariables.
10593
Style/GlobalVars:
10694
Exclude:
10795
- 'ext/mysql2/extconf.rb'
10896

109-
# Offense count: 8
97+
# Offense count: 7
11098
# This cop supports safe autocorrection (--autocorrect).
11199
Style/IfUnlessModifier:
112100
Exclude:
@@ -116,14 +104,14 @@ Style/IfUnlessModifier:
116104

117105
# Offense count: 1
118106
# This cop supports safe autocorrection (--autocorrect).
119-
# Configuration parameters: AllowMethodComparison.
107+
# Configuration parameters: AllowMethodComparison, ComparisonsThreshold.
120108
Style/MultipleComparison:
121109
Exclude:
122110
- 'lib/mysql2/client.rb'
123111

124-
# Offense count: 18
112+
# Offense count: 24
125113
# This cop supports safe autocorrection (--autocorrect).
126-
# Configuration parameters: Strict, AllowedNumbers.
114+
# Configuration parameters: Strict, AllowedNumbers, AllowedPatterns.
127115
Style/NumericLiterals:
128116
MinDigits: 20
129117

@@ -144,7 +132,7 @@ Style/StringConcatenation:
144132
- 'lib/mysql2/client.rb'
145133
- 'tasks/compile.rake'
146134

147-
# Offense count: 782
135+
# Offense count: 805
148136
# This cop supports safe autocorrection (--autocorrect).
149137
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
150138
# SupportedStyles: single_quotes, double_quotes
@@ -159,9 +147,9 @@ Style/WordArray:
159147
EnforcedStyle: percent
160148
MinSize: 4
161149

162-
# Offense count: 32
150+
# Offense count: 43
163151
# This cop supports safe autocorrection (--autocorrect).
164-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
152+
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
165153
# URISchemes: http, https
166154
Layout/LineLength:
167155
Max: 232

Gemfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ group :test do
1616
gem 'eventmachine' unless RUBY_PLATFORM =~ /mswin|mingw/
1717
gem 'rspec', '~> 3.2'
1818

19-
# https://github.com/bbatsov/rubocop/pull/4789
20-
# 1.51 is the last version supporting Ruby 2.6
21-
gem 'rubocop', '>= 1.30.1', '< 1.51' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6')
19+
gem 'rubocop'
2220
end
2321

2422
group :benchmarks, optional: true do

ext/mysql2/extconf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def add_ssl_defines(header)
113113
warn "-----\nUsing --with-mysql-dir=#{File.dirname inc}\n-----"
114114
rpath_dir = lib
115115
have_library('mysqlclient')
116-
elsif (mc = (with_config('mysql-config') || Dir[GLOB].first))
116+
elsif (mc = with_config('mysql-config') || Dir[GLOB].first)
117117
# If the user has provided a --with-mysql-config argument, we must respect it or fail.
118118
# If the user gave --with-mysql-config with no argument means we should try to find it.
119119
mc = Dir[GLOB].first if mc == true

0 commit comments

Comments
 (0)