Skip to content

Commit 8b4e92f

Browse files
committed
Point rubocop to ruby 3.1
1 parent 9d18dc8 commit 8b4e92f

File tree

11 files changed

+20
-29
lines changed

11 files changed

+20
-29
lines changed

.rubocop.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require:
66
- rubocop-md
77

88
AllCops:
9-
TargetRubyVersion: 2.7
9+
TargetRubyVersion: 3.1
1010
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
1111
# to ignore them, so only the ones explicitly set in this file are enabled.
1212
DisabledByDefault: true
@@ -107,6 +107,7 @@ Layout/EmptyLinesAroundModuleBody:
107107
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
108108
Style/HashSyntax:
109109
Enabled: true
110+
EnforcedShorthandSyntax: either
110111

111112
# Method definitions after `private` or `protected` isolated calls need one
112113
# extra level of indentation.
@@ -238,10 +239,19 @@ Lint/ErbNewArguments:
238239
Lint/EnsureReturn:
239240
Enabled: true
240241

242+
Lint/MissingCopEnableDirective:
243+
Enabled: true
244+
241245
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
242246
Lint/RequireParentheses:
243247
Enabled: true
244248

249+
Lint/RedundantCopDisableDirective:
250+
Enabled: true
251+
252+
Lint/RedundantCopEnableDirective:
253+
Enabled: true
254+
245255
Lint/RedundantStringCoercion:
246256
Enabled: true
247257

actionpack/lib/action_controller/metal/redirecting.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Redirecting
99

1010
class UnsafeRedirectError < StandardError; end
1111

12-
ILLEGAL_HEADER_VALUE_REGEX = /[\x00-\x08\x0A-\x1F]/.freeze
12+
ILLEGAL_HEADER_VALUE_REGEX = /[\x00-\x08\x0A-\x1F]/
1313

1414
included do
1515
mattr_accessor :raise_on_open_redirects, default: false

actionpack/lib/action_dispatch/journey/router/utils.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ class UriEncoder # :nodoc:
4242
UNRESERVED = "#{ALPHA}#{DIGIT}\\-\\._~"
4343
SUB_DELIMS = "!\\$&'\\(\\)\\*\\+,;="
4444

45-
ESCAPED = /%[a-zA-Z0-9]{2}/.freeze
45+
ESCAPED = /%[a-zA-Z0-9]{2}/
4646

47-
FRAGMENT = /[^#{UNRESERVED}#{SUB_DELIMS}:@\/?]/.freeze
48-
SEGMENT = /[^#{UNRESERVED}#{SUB_DELIMS}:@]/.freeze
49-
PATH = /[^#{UNRESERVED}#{SUB_DELIMS}:@\/]/.freeze
47+
FRAGMENT = /[^#{UNRESERVED}#{SUB_DELIMS}:@\/?]/
48+
SEGMENT = /[^#{UNRESERVED}#{SUB_DELIMS}:@]/
49+
PATH = /[^#{UNRESERVED}#{SUB_DELIMS}:@\/]/
5050

5151
def escape_fragment(fragment)
5252
escape(fragment, FRAGMENT)

actionpack/test/dispatch/test_response_test.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,12 @@ def assert_response_code_range(range, predicate)
4343
test "JSON response Hash pattern matching" do
4444
response = ActionDispatch::TestResponse.create(200, { "Content-Type" => "application/json" }, '{ "foo": "fighters" }')
4545

46-
# rubocop:disable Lint/Syntax
4746
assert_pattern { response.parsed_body => { foo: /fighter/ } }
48-
# rubocop:enable Lint/Syntax
4947
end
5048

5149
test "JSON response Array pattern matching" do
5250
response = ActionDispatch::TestResponse.create(200, { "Content-Type" => "application/json" }, '[{ "foo": "fighters" }, { "nir": "vana" }]')
53-
# rubocop:disable Lint/Syntax
5451
assert_pattern { response.parsed_body => [{ foo: /fighter/ }, { nir: /vana/ }] }
55-
# rubocop:enable Lint/Syntax
5652
end
5753

5854
test "HTML response pattern matching" do
@@ -66,17 +62,12 @@ def assert_response_code_range(range, predicate)
6662
HTML
6763
html = response.parsed_body
6864

69-
# rubocop:disable Lint/Syntax
7065
html.at("main") => {name:, content:}
71-
# rubocop:enable Lint/Syntax
72-
7366
assert_equal "main", name
7467
assert_equal "Some main content", content
7568

76-
# rubocop:disable Lint/Syntax
7769
assert_pattern { html.at("main") => { content: "Some main content" } }
7870
assert_pattern { html.at("main") => { content: /content/ } }
7971
assert_pattern { html.at("main") => { children: [{ name: "h1", content: /content/ }] } }
80-
# rubocop:enable Lint/Syntax
8172
end
8273
end

actionview/test/template/test_case_test.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ class PatternMatchingTestCases < ActionView::TestCase
460460

461461
render "developers/developer_with_h1", developer: developer
462462

463-
# rubocop:disable Lint/Syntax
464463
assert_pattern { document_root_element.at("h1") => { content: "Eloy", attributes: [{ name: "id", value: "name" }] } }
465464
refute_pattern { document_root_element.at("h1") => { content: "Not Eloy" } }
466465
end
@@ -470,21 +469,17 @@ class PatternMatchingTestCases < ActionView::TestCase
470469

471470
render "developers/developer", developer: developer
472471

473-
# rubocop:disable Lint/Syntax
474472
assert_pattern { rendered.html => { content: "Eloy" } }
475473
refute_pattern { rendered.html => { content: "Not Eloy" } }
476-
# rubocop:enable Lint/Syntax
477474
end
478475

479476
test "rendered.json integrates with pattern matching" do
480477
developer = DeveloperStruct.new("Eloy")
481478

482479
render formats: :json, partial: "developers/developer", locals: { developer: developer }
483480

484-
# rubocop:disable Lint/Syntax
485481
assert_pattern { rendered.json => { name: "Eloy" } }
486482
refute_pattern { rendered.json => { name: "Not Eloy" } }
487-
# rubocop:enable Lint/Syntax
488483
end
489484
end
490485
end

activesupport/lib/active_support/core_ext/object/instance_variables.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ def instance_values
2929
def instance_variable_names
3030
instance_variables.map(&:name)
3131
end
32-
end
3332
end

activesupport/lib/active_support/notifications/instrumenter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def now_cpu
210210
Process.clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID, :float_millisecond)
211211
end
212212
rescue
213-
def now_cpu # rubocop:disable Lint/DuplicateMethods
213+
def now_cpu
214214
0.0
215215
end
216216
end

activesupport/test/array_inquirer_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def respond_to_missing?(name, include_private = false)
5555
ensure
5656
Array.class_eval do
5757
undef_method :respond_to_missing?
58-
def respond_to_missing?(name, include_private = false) # rubocop:disable Lint/DuplicateMethods
58+
def respond_to_missing?(name, include_private = false)
5959
super
6060
end
6161
end

activesupport/test/string_inquirer_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def respond_to_missing?(name, include_private = false)
3838
ensure
3939
String.class_eval do
4040
undef_method :respond_to_missing?
41-
def respond_to_missing?(name, include_private = false) # rubocop:disable Lint/DuplicateMethods
41+
def respond_to_missing?(name, include_private = false)
4242
super
4343
end
4444
end

railties/lib/rails/all.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
# rubocop:disable Style/RedundantBegin
4-
53
require "rails"
64

75
%w(
@@ -16,7 +14,7 @@
1614
action_text/engine
1715
rails/test_unit/railtie
1816
).each do |railtie|
19-
begin
17+
begin # rubocop:disable Style/RedundantBegin
2018
require railtie
2119
rescue LoadError
2220
end

0 commit comments

Comments
 (0)