rubocop-rails 2.15.0 → 2.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/default.yml +1 -1
- data/lib/rubocop/cop/rails/deprecated_active_model_errors_methods.rb +1 -1
- data/lib/rubocop/cop/rails/dot_separated_keys.rb +1 -1
- data/lib/rubocop/cop/rails/enum_hash.rb +1 -2
- data/lib/rubocop/cop/rails/order_by_id.rb +1 -2
- data/lib/rubocop/cop/rails/time_zone_assignment.rb +2 -2
- data/lib/rubocop/cop/rails/to_formatted_s.rb +1 -0
- data/lib/rubocop/cop/rails/transaction_exit_statement.rb +1 -1
- data/lib/rubocop/cop/rails/unique_validation_without_index.rb +2 -2
- data/lib/rubocop/rails/schema_loader/schema.rb +5 -5
- data/lib/rubocop/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dc39965bea5c1a04b65aed496d749cc59a8ed9eeccef6d010ff8ce1970dabb9
|
4
|
+
data.tar.gz: f827dd6365f66a1464ae9433985960a99a90a8ba35b1b7c683c9dc3d7a0209ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eea7efbff824ab7a3bdae13bdbbdb2c33b4cd04ba74c2f9a7f89971ddf2da0d7a3f68a4508e9ca81314425fe9ba593f6675e014a5b385923e3790a7357bba6f5
|
7
|
+
data.tar.gz: 28990bc579868dcd5ce06332558f1bd5bb97ae13895bdf690b46650e86f7e4cf37e1d64e5a18c681f3cfa17347c338f30511b1d34788617bbaf311c5fea37126
|
data/config/default.yml
CHANGED
@@ -119,7 +119,7 @@ module RuboCop
|
|
119
119
|
def autocorrect(corrector, node)
|
120
120
|
receiver = node.receiver
|
121
121
|
|
122
|
-
if receiver.receiver.method?(:messages)
|
122
|
+
if receiver.receiver.send_type? && receiver.receiver.method?(:messages)
|
123
123
|
corrector.remove(receiver.receiver.loc.dot)
|
124
124
|
corrector.remove(receiver.receiver.loc.selector)
|
125
125
|
end
|
@@ -20,8 +20,7 @@ module RuboCop
|
|
20
20
|
class EnumHash < Base
|
21
21
|
extend AutoCorrector
|
22
22
|
|
23
|
-
MSG = 'Enum defined as an array found in `%<enum>s` enum declaration. '
|
24
|
-
'Use hash syntax instead.'
|
23
|
+
MSG = 'Enum defined as an array found in `%<enum>s` enum declaration. Use hash syntax instead.'
|
25
24
|
RESTRICT_ON_SEND = %i[enum].freeze
|
26
25
|
|
27
26
|
def_node_matcher :enum?, <<~PATTERN
|
@@ -23,8 +23,7 @@ module RuboCop
|
|
23
23
|
class OrderById < Base
|
24
24
|
include RangeHelp
|
25
25
|
|
26
|
-
MSG = 'Do not use the `id` column for ordering. '
|
27
|
-
'Use a timestamp column to order chronologically.'
|
26
|
+
MSG = 'Do not use the `id` column for ordering. Use a timestamp column to order chronologically.'
|
28
27
|
RESTRICT_ON_SEND = %i[order].freeze
|
29
28
|
|
30
29
|
def_node_matcher :order_by_id?, <<~PATTERN
|
@@ -22,12 +22,12 @@ module RuboCop
|
|
22
22
|
MSG = 'Use `Time.use_zone` with block instead of `Time.zone=`.'
|
23
23
|
RESTRICT_ON_SEND = %i[zone=].freeze
|
24
24
|
|
25
|
-
def_node_matcher :
|
25
|
+
def_node_matcher :time_zone_assignment?, <<~PATTERN
|
26
26
|
(send (const nil? :Time) :zone= ...)
|
27
27
|
PATTERN
|
28
28
|
|
29
29
|
def on_send(node)
|
30
|
-
return unless
|
30
|
+
return unless time_zone_assignment?(node)
|
31
31
|
|
32
32
|
add_offense(node)
|
33
33
|
end
|
@@ -6,7 +6,7 @@ module RuboCop
|
|
6
6
|
# Checks for the use of exit statements (namely `return`,
|
7
7
|
# `break` and `throw`) in transactions. This is due to the eventual
|
8
8
|
# unexpected behavior when using ActiveRecord >= 7, where transactions
|
9
|
-
#
|
9
|
+
# exited using these statements are being rollbacked rather than
|
10
10
|
# committed (pre ActiveRecord 7 behavior).
|
11
11
|
#
|
12
12
|
# As alternatives, it would be more intuitive to explicitly raise an
|
@@ -56,9 +56,9 @@ module RuboCop
|
|
56
56
|
|
57
57
|
def with_index?(klass, table, names)
|
58
58
|
# Compatibility for Rails 4.2.
|
59
|
-
|
59
|
+
add_indices = schema.add_indices_by(table_name: table_name(klass))
|
60
60
|
|
61
|
-
(table.indices +
|
61
|
+
(table.indices + add_indices).any? do |index|
|
62
62
|
index.unique &&
|
63
63
|
(index.columns.to_set == names ||
|
64
64
|
include_column_names_in_expression_index?(index, names))
|
@@ -5,11 +5,11 @@ module RuboCop
|
|
5
5
|
module SchemaLoader
|
6
6
|
# Represent db/schema.rb
|
7
7
|
class Schema
|
8
|
-
attr_reader :tables, :
|
8
|
+
attr_reader :tables, :add_indices
|
9
9
|
|
10
10
|
def initialize(ast)
|
11
11
|
@tables = []
|
12
|
-
@
|
12
|
+
@add_indices = []
|
13
13
|
|
14
14
|
build!(ast)
|
15
15
|
end
|
@@ -20,8 +20,8 @@ module RuboCop
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
23
|
+
def add_indices_by(table_name:)
|
24
|
+
add_indices.select do |add_index|
|
25
25
|
add_index.table_name == table_name
|
26
26
|
end
|
27
27
|
end
|
@@ -39,7 +39,7 @@ module RuboCop
|
|
39
39
|
|
40
40
|
# Compatibility for Rails 4.2.
|
41
41
|
each_add_index(ast) do |add_index_def|
|
42
|
-
@
|
42
|
+
@add_indices << AddIndex.new(add_index_def)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.15.
|
4
|
+
version: 2.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-06-
|
13
|
+
date: 2022-06-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|