rubocop-rails 2.15.0 → 2.15.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e850e3f6c08903dd860f5865cb24cab1037189bbd7418c0db047d36094808d8
4
- data.tar.gz: a91a77471ae5e9a4c7a188d5fb958402844ba04c3641f14a6bf82161ea43ebf7
3
+ metadata.gz: 9dc39965bea5c1a04b65aed496d749cc59a8ed9eeccef6d010ff8ce1970dabb9
4
+ data.tar.gz: f827dd6365f66a1464ae9433985960a99a90a8ba35b1b7c683c9dc3d7a0209ce
5
5
  SHA512:
6
- metadata.gz: 753768200576274520f9f6a8d8ab959436e0b87c44a7b51a6eb20803fee0ec842fb1d0debb4c4fef997e8b51f7caee4198692bb8de3e1603ce16fdadf386692f
7
- data.tar.gz: eeabca82a842cea89cb8f3b5fbb54abe83c4d6405112a6493e30aeaa9ebb4df39b67c71a6e43342e77d80b2ca901978d48b77e7a52952254f20545ab9eaaf74a
6
+ metadata.gz: eea7efbff824ab7a3bdae13bdbbdb2c33b4cd04ba74c2f9a7f89971ddf2da0d7a3f68a4508e9ca81314425fe9ba593f6675e014a5b385923e3790a7357bba6f5
7
+ data.tar.gz: 28990bc579868dcd5ce06332558f1bd5bb97ae13895bdf690b46650e86f7e4cf37e1d64e5a18c681f3cfa17347c338f30511b1d34788617bbaf311c5fea37126
data/config/default.yml CHANGED
@@ -160,7 +160,7 @@ Rails/AttributeDefaultBlockValue:
160
160
  Enabled: pending
161
161
  VersionAdded: '2.9'
162
162
  Include:
163
- - 'models/**/*'
163
+ - 'app/models/**/*'
164
164
 
165
165
  Rails/BelongsTo:
166
166
  Description: >-
@@ -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
@@ -53,7 +53,7 @@ module RuboCop
53
53
  end
54
54
 
55
55
  def new_key(key_node, scope_node)
56
- "'#{scopes(scope_node).map(&:value).join('.')}.#{key_node.value}'"
56
+ "'#{scopes(scope_node).map(&:value).join('.')}.#{key_node.value}'".squeeze('.')
57
57
  end
58
58
 
59
59
  def scopes(scope_node)
@@ -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 :time_zone_assignement?, <<~PATTERN
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 time_zone_assignement?(node)
30
+ return unless time_zone_assignment?(node)
31
31
 
32
32
  add_offense(node)
33
33
  end
@@ -39,6 +39,7 @@ module RuboCop
39
39
  corrector.replace(node.loc.selector, style)
40
40
  end
41
41
  end
42
+ alias on_csend on_send
42
43
  end
43
44
  end
44
45
  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
- # exitted using these statements are being rollbacked rather than
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
- add_indicies = schema.add_indicies_by(table_name: table_name(klass))
59
+ add_indices = schema.add_indices_by(table_name: table_name(klass))
60
60
 
61
- (table.indices + add_indicies).any? do |index|
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, :add_indicies
8
+ attr_reader :tables, :add_indices
9
9
 
10
10
  def initialize(ast)
11
11
  @tables = []
12
- @add_indicies = []
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 add_indicies_by(table_name:)
24
- add_indicies.select do |add_index|
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
- @add_indicies << AddIndex.new(add_index_def)
42
+ @add_indices << AddIndex.new(add_index_def)
43
43
  end
44
44
  end
45
45
 
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Rails
5
5
  # This module holds the RuboCop Rails version information.
6
6
  module Version
7
- STRING = '2.15.0'
7
+ STRING = '2.15.1'
8
8
 
9
9
  def self.document_version
10
10
  STRING.match('\d+\.\d+').to_s
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.0
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-14 00:00:00.000000000 Z
13
+ date: 2022-06-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport