rubocop-rails 2.11.0 → 2.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b189297521a834dca247787947efd0f3a7c5fed19b351b37d6c729b0622ff52d
4
- data.tar.gz: e68accc2d7c9c5726b63967f665414d09f9d3597117de042ee9dbc024cbc6350
3
+ metadata.gz: bfb9c60dfc813cddff8b72b3f19b337ec3a6570f6210398841ed3852d9dcfad1
4
+ data.tar.gz: 4d026033a03b8f08ccf51e9503cd83c0266132e677478732b64b4fdbe664b02a
5
5
  SHA512:
6
- metadata.gz: 2474d4d0321548d02443df1ec10e20252c5496fa6df4dd4bc5d8c0544c9ff884f23da90273075d808bfa1ef22659ee8d8b81cff4f5dbf8a8134c054adf298187
7
- data.tar.gz: f7cb276a49bdaffffbc020ac96951f3e5074c4f993f77710b22a48fc7efb357d447853768f6006c7e173640e483601cd6bab61b6ffb3df5a70dffb3a07b49541
6
+ metadata.gz: 1fbc8870d37ee91a53e15f1d067517f8430cd9a0bb383bf27c80c4f84db32ded964c3f345caa6d026aaba187f3e7c78d6a838824433b16d3e9cac9ed7ecd337c
7
+ data.tar.gz: 0cf8c155c3b987a10f581d4983240696fa444d7157e54e4bb2d2ac616721e80a4dacd264e32d15a0165e66d7d1511d97b9c8a07d4e94e1e41accfc71b7803228
@@ -20,8 +20,7 @@ module RuboCop
20
20
 
21
21
  MSG = 'Favor `%<bang>sRails.env.%<env>s?` over `%<source>s`.'
22
22
 
23
- SYM_MSG = 'Do not compare `Rails.env` with a symbol, it will always ' \
24
- 'evaluate to `false`.'
23
+ SYM_MSG = 'Do not compare `Rails.env` with a symbol, it will always evaluate to `false`.'
25
24
 
26
25
  RESTRICT_ON_SEND = %i[== !=].freeze
27
26
 
@@ -32,6 +32,7 @@ module RuboCop
32
32
  RESTRICT_ON_SEND = %i[first take].freeze
33
33
 
34
34
  def on_send(node)
35
+ return unless where_method?(node.receiver)
35
36
  return if ignore_where_first? && node.method?(:first)
36
37
 
37
38
  range = range_between(node.receiver.loc.selector.begin_pos, node.loc.selector.end_pos)
@@ -44,6 +45,12 @@ module RuboCop
44
45
 
45
46
  private
46
47
 
48
+ def where_method?(receiver)
49
+ return false unless receiver
50
+
51
+ receiver.respond_to?(:method?) && receiver.method?(:where)
52
+ end
53
+
47
54
  def autocorrect(corrector, node)
48
55
  return if node.method?(:first)
49
56
 
@@ -130,8 +130,7 @@ module RuboCop
130
130
  # @see https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses
131
131
  class InverseOf < Base
132
132
  SPECIFY_MSG = 'Specify an `:inverse_of` option.'
133
- NIL_MSG = 'You specified `inverse_of: nil`, you probably meant to ' \
134
- 'use `inverse_of: false`.'
133
+ NIL_MSG = 'You specified `inverse_of: nil`, you probably meant to use `inverse_of: false`.'
135
134
  RESTRICT_ON_SEND = %i[has_many has_one belongs_to].freeze
136
135
 
137
136
  def_node_matcher :association_recv_arguments, <<~PATTERN
@@ -40,7 +40,7 @@ module RuboCop
40
40
 
41
41
  def reflection_class_value?(class_value)
42
42
  if class_value.send_type?
43
- !class_value.method?(:to_s) || class_value.receiver.const_type?
43
+ !class_value.method?(:to_s) || class_value.receiver&.const_type?
44
44
  else
45
45
  !ALLOWED_REFLECTION_CLASS_TYPES.include?(class_value.type)
46
46
  end
@@ -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.11.0'
7
+ STRING = '2.11.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.11.0
4
+ version: 2.11.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: 2021-06-21 00:00:00.000000000 Z
13
+ date: 2021-06-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport