rubocop-rails 2.11.0 → 2.12.0

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: b189297521a834dca247787947efd0f3a7c5fed19b351b37d6c729b0622ff52d
4
- data.tar.gz: e68accc2d7c9c5726b63967f665414d09f9d3597117de042ee9dbc024cbc6350
3
+ metadata.gz: 547615c004c88ace5079ff3c4c0da33bbc3a6187b963baaf82ba34ee9a068224
4
+ data.tar.gz: b7b09ff7ab96257ea329a393158c656f2d92fa3e3528916dc4bd3664f2341f90
5
5
  SHA512:
6
- metadata.gz: 2474d4d0321548d02443df1ec10e20252c5496fa6df4dd4bc5d8c0544c9ff884f23da90273075d808bfa1ef22659ee8d8b81cff4f5dbf8a8134c054adf298187
7
- data.tar.gz: f7cb276a49bdaffffbc020ac96951f3e5074c4f993f77710b22a48fc7efb357d447853768f6006c7e173640e483601cd6bab61b6ffb3df5a70dffb3a07b49541
6
+ metadata.gz: 97f42ef251a1f3bcb91d0e08e3b89fb480a6555aa8f13266c57d0bf6b8319e35b4d200b8c4d2f407c303b8b8bbf72dc354a259688e27f032e625516683f1aafc
7
+ data.tar.gz: c9b8d93ad9c39f1903c2424c0e0e284281e7effe0373fbcfe8e3138b2dd659122fb69cb658b9560f4af8a94cd332ad80066b3617339a21ae24de47cf2987f2c6
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'irb'
6
+ require 'rubocop'
7
+ require 'rubocop-rails'
8
+
9
+ ARGV.clear
10
+
11
+ IRB.start(__FILE__)
data/config/default.yml CHANGED
@@ -181,12 +181,14 @@ Rails/BulkChangeTable:
181
181
  - db/migrate/*.rb
182
182
 
183
183
  Rails/ContentTag:
184
- Description: 'Use `tag` instead of `content_tag`.'
184
+ Description: 'Use `tag.something` instead of `tag(:something)`.'
185
185
  Reference:
186
+ - 'https://github.com/rubocop/rubocop-rails/issues/260'
186
187
  - 'https://github.com/rails/rails/issues/25195'
187
188
  - 'https://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-content_tag'
188
189
  Enabled: true
189
190
  VersionAdded: '2.6'
191
+ VersionChanged: '2.12'
190
192
 
191
193
  Rails/CreateTableWithTimestamps:
192
194
  Description: >-
@@ -499,6 +501,7 @@ Rails/OrderById:
499
501
  Rails/Output:
500
502
  Description: 'Checks for calls to puts, print, etc.'
501
503
  Enabled: true
504
+ SafeAutoCorrect: false
502
505
  VersionAdded: '0.15'
503
506
  VersionChanged: '0.19'
504
507
  Include:
@@ -607,6 +610,14 @@ Rails/RedundantReceiverInWithOptions:
607
610
  Enabled: true
608
611
  VersionAdded: '0.52'
609
612
 
613
+ Rails/RedundantTravelBack:
614
+ Description: This cop checks for redundant `travel_back` calls.
615
+ Enabled: pending
616
+ VersionAdded: '2.12'
617
+ Include:
618
+ - spec/**/*.rb
619
+ - test/**/*.rb
620
+
610
621
  Rails/ReflectionClassName:
611
622
  Description: 'Use a string for `class_name` option value in the definition of a reflection.'
612
623
  Enabled: true
@@ -713,6 +724,7 @@ Rails/ScopeArgs:
713
724
  Description: 'Checks the arguments of ActiveRecord scopes.'
714
725
  Enabled: true
715
726
  VersionAdded: '0.19'
727
+ VersionChanged: '2.12'
716
728
  Include:
717
729
  - app/models/**/*.rb
718
730
 
@@ -57,12 +57,13 @@ module RuboCop
57
57
  # Resolve relation into column name.
58
58
  # It just returns column_name if the column exists.
59
59
  # Or it tries to resolve column_name as a relation.
60
+ # Returns an array of column names if the relation is polymorphic.
60
61
  # It returns `nil` if it can't resolve.
61
62
  #
62
63
  # @param name [String]
63
64
  # @param class_node [RuboCop::AST::Node]
64
65
  # @param table [RuboCop::Rails::SchemaLoader::Table]
65
- # @return [String, nil]
66
+ # @return [Array, String, nil]
66
67
  def resolve_relation_into_column(name:, class_node:, table:)
67
68
  return unless table
68
69
  return name if table.with_column?(name: name)
@@ -71,7 +72,9 @@ module RuboCop
71
72
  next unless belongs_to.first_argument.value.to_s == name
72
73
 
73
74
  fk = foreign_key_of(belongs_to) || "#{name}_id"
74
- return fk if table.with_column?(name: fk)
75
+ next unless table.with_column?(name: fk)
76
+
77
+ return polymorphic?(belongs_to) ? [fk, "#{name}_type"] : fk
75
78
  end
76
79
  nil
77
80
  end
@@ -88,6 +91,15 @@ module RuboCop
88
91
  end
89
92
  end
90
93
 
94
+ def polymorphic?(belongs_to)
95
+ options = belongs_to.last_argument
96
+ return false unless options.hash_type?
97
+
98
+ options.each_pair.any? do |pair|
99
+ pair.key.sym_type? && pair.key.value == :polymorphic && pair.value.true_type?
100
+ end
101
+ end
102
+
91
103
  def in_where?(node)
92
104
  send_node = node.each_ancestor(:send).first
93
105
  send_node && WHERE_METHODS.include?(send_node.method_name)
@@ -71,7 +71,7 @@ module RuboCop
71
71
 
72
72
  # Autocorrect by swapping between two nodes autocorrecting them
73
73
  def autocorrect(corrector, node)
74
- previous = left_siblings_of(node).reverse_each.find do |sibling|
74
+ previous = node.left_siblings.reverse_each.find do |sibling|
75
75
  callback?(sibling)
76
76
  end
77
77
 
@@ -96,14 +96,6 @@ module RuboCop
96
96
  node.send_type? && CALLBACKS_ORDER_MAP.key?(node.method_name)
97
97
  end
98
98
 
99
- def left_siblings_of(node)
100
- siblings_of(node)[0, node.sibling_index]
101
- end
102
-
103
- def siblings_of(node)
104
- node.parent.children
105
- end
106
-
107
99
  def source_range_with_comment(node)
108
100
  begin_pos = begin_pos_with_comment(node)
109
101
  end_pos = end_position_for(node)
@@ -194,7 +194,11 @@ module RuboCop
194
194
  def database_yaml
195
195
  return nil unless File.exist?('config/database.yml')
196
196
 
197
- yaml = YAML.load_file('config/database.yml')
197
+ yaml = if YAML.respond_to?(:unsafe_load_file)
198
+ YAML.unsafe_load_file('config/database.yml')
199
+ else
200
+ YAML.load_file('config/database.yml')
201
+ end
198
202
  return nil unless yaml.is_a? Hash
199
203
 
200
204
  config = yaml['development']
@@ -3,21 +3,21 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Rails
6
- # This cop checks that `tag` is used instead of `content_tag`
7
- # because `content_tag` is legacy syntax.
6
+ # This cop checks legacy syntax usage of `tag`
8
7
  #
9
- # NOTE: Allow `content_tag` when the first argument is a variable because
10
- # `content_tag(name)` is simpler rather than `tag.public_send(name)`.
8
+ # NOTE: Allow `tag` when the first argument is a variable because
9
+ # `tag(name)` is simpler rather than `tag.public_send(name)`.
10
+ # And this cop will be renamed to something like `LegacyTag` in the future. (e.g. RuboCop Rails 2.0)
11
11
  #
12
12
  # @example
13
13
  # # bad
14
- # content_tag(:p, 'Hello world!')
15
- # content_tag(:br)
14
+ # tag(:p)
15
+ # tag(:br, class: 'classname')
16
16
  #
17
17
  # # good
18
- # tag.p('Hello world!')
19
- # tag.br
20
- # content_tag(name, 'Hello world!')
18
+ # tag.p
19
+ # tag.br(class: 'classname')
20
+ # tag(name, class: 'classname')
21
21
  class ContentTag < Base
22
22
  include RangeHelp
23
23
  extend AutoCorrector
@@ -25,8 +25,8 @@ module RuboCop
25
25
 
26
26
  minimum_target_rails_version 5.1
27
27
 
28
- MSG = 'Use `tag` instead of `content_tag`.'
29
- RESTRICT_ON_SEND = %i[content_tag].freeze
28
+ MSG = 'Use `tag.%<preferred_method>s` instead of `tag(%<current_argument>s)`.'
29
+ RESTRICT_ON_SEND = %i[tag].freeze
30
30
 
31
31
  def on_new_investigation
32
32
  @corrected_nodes = nil
@@ -38,8 +38,11 @@ module RuboCop
38
38
  allowed_argument?(first_argument) ||
39
39
  corrected_ancestor?(node)
40
40
 
41
- add_offense(node) do |corrector|
42
- autocorrect(corrector, node)
41
+ preferred_method = node.first_argument.value.to_s.underscore
42
+ message = format(MSG, preferred_method: preferred_method, current_argument: first_argument.source)
43
+
44
+ add_offense(node, message: message) do |corrector|
45
+ autocorrect(corrector, node, preferred_method)
43
46
 
44
47
  @corrected_nodes ||= Set.new.compare_by_identity
45
48
  @corrected_nodes.add(node)
@@ -53,26 +56,26 @@ module RuboCop
53
56
  end
54
57
 
55
58
  def allowed_argument?(argument)
56
- argument.variable? || argument.send_type? || argument.const_type? || argument.splat_type?
59
+ argument.variable? ||
60
+ argument.send_type? ||
61
+ argument.const_type? ||
62
+ argument.splat_type? ||
63
+ allowed_name?(argument)
57
64
  end
58
65
 
59
- def autocorrect(corrector, node)
60
- if method_name?(node.first_argument)
61
- range = correction_range(node)
66
+ def autocorrect(corrector, node, preferred_method)
67
+ range = correction_range(node)
62
68
 
63
- rest_args = node.arguments.drop(1)
64
- replacement = "tag.#{node.first_argument.value.to_s.underscore}(#{rest_args.map(&:source).join(', ')})"
69
+ rest_args = node.arguments.drop(1)
70
+ replacement = "tag.#{preferred_method}(#{rest_args.map(&:source).join(', ')})"
65
71
 
66
- corrector.replace(range, replacement)
67
- else
68
- corrector.replace(node.loc.selector, 'tag')
69
- end
72
+ corrector.replace(range, replacement)
70
73
  end
71
74
 
72
- def method_name?(node)
73
- return false unless node.str_type? || node.sym_type?
75
+ def allowed_name?(argument)
76
+ return false unless argument.str_type? || argument.sym_type?
74
77
 
75
- /^[a-zA-Z_][a-zA-Z_\-0-9]*$/.match?(node.value)
78
+ !/^[a-zA-Z\-][a-zA-Z\-0-9]*$/.match?(argument.value)
76
79
  end
77
80
 
78
81
  def correction_range(node)
@@ -100,7 +100,7 @@ module RuboCop
100
100
 
101
101
  def method_name_matches?(method_name, body)
102
102
  method_name == body.method_name ||
103
- include_prefix_case? && method_name == prefixed_method_name(body)
103
+ (include_prefix_case? && method_name == prefixed_method_name(body))
104
104
  end
105
105
 
106
106
  def include_prefix_case?
@@ -40,7 +40,7 @@ module RuboCop
40
40
  IGNORED_ARGUMENT_TYPES = %i[hash splat].freeze
41
41
 
42
42
  def on_send(node)
43
- return if node.receiver.nil? && !inherit_active_record_base?(node) || allowed_invocation?(node)
43
+ return if (node.receiver.nil? && !inherit_active_record_base?(node)) || allowed_invocation?(node)
44
44
 
45
45
  method_name = node.method_name
46
46
  static_name = static_method_name(method_name)
@@ -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,9 +32,10 @@ module RuboCop
32
32
  RESTRICT_ON_SEND = %i[first take].freeze
33
33
 
34
34
  def on_send(node)
35
+ return unless node.arguments.empty? && where_method?(node.receiver)
35
36
  return if ignore_where_first? && node.method?(:first)
36
37
 
37
- range = range_between(node.receiver.loc.selector.begin_pos, node.loc.selector.end_pos)
38
+ range = offense_range(node)
38
39
 
39
40
  add_offense(range, message: format(MSG, method: node.method_name)) do |corrector|
40
41
  autocorrect(corrector, node)
@@ -44,6 +45,16 @@ 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
+
54
+ def offense_range(node)
55
+ range_between(node.receiver.loc.selector.begin_pos, node.loc.selector.end_pos)
56
+ end
57
+
47
58
  def autocorrect(corrector, node)
48
59
  return if node.method?(:first)
49
60
 
@@ -114,6 +114,8 @@ module RuboCop
114
114
  end
115
115
 
116
116
  def valid_options?(options)
117
+ options = options.first.children.first.pairs if options.first.kwsplat_type?
118
+
117
119
  return true unless options
118
120
  return true if options.any? do |o|
119
121
  dependent_option?(o) || present_option?(o)
@@ -27,6 +27,7 @@ module RuboCop
27
27
  KEYWORD_ARGS = %i[
28
28
  method params session body flash xhr as headers env to
29
29
  ].freeze
30
+ ROUTING_METHODS = %i[draw routes].freeze
30
31
  RESTRICT_ON_SEND = %i[get post put patch delete head].freeze
31
32
 
32
33
  minimum_target_rails_version 5.0
@@ -40,6 +41,8 @@ module RuboCop
40
41
  PATTERN
41
42
 
42
43
  def on_send(node)
44
+ return if in_routing_block?(node)
45
+
43
46
  http_request?(node) do |data|
44
47
  return unless needs_conversion?(data)
45
48
 
@@ -63,13 +66,17 @@ module RuboCop
63
66
 
64
67
  private
65
68
 
69
+ def in_routing_block?(node)
70
+ !!node.each_ancestor(:block).detect { |block| ROUTING_METHODS.include?(block.send_node.method_name) }
71
+ end
72
+
66
73
  def needs_conversion?(data)
67
74
  return true unless data.hash_type?
68
75
  return false if kwsplat_hash?(data)
69
76
 
70
77
  data.each_pair.none? do |pair|
71
78
  special_keyword_arg?(pair.key) ||
72
- format_arg?(pair.key) && data.pairs.one?
79
+ (format_arg?(pair.key) && data.pairs.one?)
73
80
  end
74
81
  end
75
82
 
@@ -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
@@ -124,9 +124,10 @@ module RuboCop
124
124
  block = parent.each_child_node(:begin).first
125
125
  return unless block
126
126
 
127
- defined_methods = block.each_child_node(:def).map(&:method_name)
127
+ defined_action_methods = defined_action_methods(block)
128
+
128
129
  methods = array_values(methods_node).reject do |method|
129
- defined_methods.include?(method)
130
+ defined_action_methods.include?(method)
130
131
  end
131
132
 
132
133
  message = message(methods, parent)
@@ -135,6 +136,26 @@ module RuboCop
135
136
 
136
137
  private
137
138
 
139
+ def defined_action_methods(block)
140
+ defined_methods = block.each_child_node(:def).map(&:method_name)
141
+
142
+ defined_methods + aliased_action_methods(block, defined_methods)
143
+ end
144
+
145
+ def aliased_action_methods(node, defined_methods)
146
+ alias_methods = node.each_child_node(:send).select { |send_node| send_node.method?(:alias_method) }
147
+
148
+ hash_of_alias_methods = alias_methods.each_with_object({}) do |alias_method, result|
149
+ result[alias_method.last_argument.value] = alias_method.first_argument.value
150
+ end
151
+
152
+ defined_methods.each_with_object([]) do |defined_method, aliased_method|
153
+ if (new_method_name = hash_of_alias_methods[defined_method])
154
+ aliased_method << new_method_name
155
+ end
156
+ end
157
+ end
158
+
138
159
  # @param node [RuboCop::AST::Node]
139
160
  # @return [Array<Symbol>]
140
161
  def array_values(node) # rubocop:disable Metrics/MethodLength
@@ -75,8 +75,8 @@ module RuboCop
75
75
  corrector.replace(str_range, "#{existing_rel} noopener")
76
76
  end
77
77
 
78
- def add_rel(send_node, offence_node, corrector)
79
- opening_quote = offence_node.children.last.source[0]
78
+ def add_rel(send_node, offense_node, corrector)
79
+ opening_quote = offense_node.children.last.source[0]
80
80
  closing_quote = opening_quote == ':' ? '' : opening_quote
81
81
  new_rel_exp = ", rel: #{opening_quote}noopener#{closing_quote}"
82
82
  range = if (last_argument = send_node.last_argument).hash_type?
@@ -14,6 +14,9 @@ module RuboCop
14
14
  # # good
15
15
  # Rails.logger.debug 'A debug message'
16
16
  class Output < Base
17
+ include RangeHelp
18
+ extend AutoCorrector
19
+
17
20
  MSG = 'Do not write to stdout. ' \
18
21
  "Use Rails's logger if you want to log."
19
22
  RESTRICT_ON_SEND = %i[
@@ -35,10 +38,13 @@ module RuboCop
35
38
  PATTERN
36
39
 
37
40
  def on_send(node)
38
- return unless (output?(node) || io_output?(node)) &&
39
- node.arguments?
41
+ return unless (output?(node) || io_output?(node)) && node.arguments?
42
+
43
+ range = offense_range(node)
40
44
 
41
- add_offense(node.loc.selector)
45
+ add_offense(range) do |corrector|
46
+ corrector.replace(range, 'Rails.logger.debug')
47
+ end
42
48
  end
43
49
 
44
50
  private
@@ -46,6 +52,14 @@ module RuboCop
46
52
  def match_gvar?(sym)
47
53
  %i[$stdout $stderr].include?(sym)
48
54
  end
55
+
56
+ def offense_range(node)
57
+ if node.receiver
58
+ range_between(node.loc.expression.begin_pos, node.loc.selector.end_pos)
59
+ else
60
+ node.loc.selector
61
+ end
62
+ end
49
63
  end
50
64
  end
51
65
  end
@@ -61,8 +61,8 @@ module RuboCop
61
61
  def offense?(node)
62
62
  number, = *node.receiver
63
63
 
64
- singular_receiver?(number) && plural_method?(node.method_name) ||
65
- plural_receiver?(number) && singular_method?(node.method_name)
64
+ (singular_receiver?(number) && plural_method?(node.method_name)) ||
65
+ (plural_receiver?(number) && singular_method?(node.method_name))
66
66
  end
67
67
 
68
68
  def plural_method?(method_name)
@@ -56,8 +56,8 @@ module RuboCop
56
56
 
57
57
  def register_offense(allow_nil, message)
58
58
  add_offense(allow_nil, message: message) do |corrector|
59
- prv_sib = previous_sibling(allow_nil)
60
- nxt_sib = next_sibling(allow_nil)
59
+ prv_sib = allow_nil.left_sibling
60
+ nxt_sib = allow_nil.right_sibling
61
61
 
62
62
  if nxt_sib
63
63
  corrector.remove(range_between(node_beg(allow_nil), node_beg(nxt_sib)))
@@ -88,14 +88,6 @@ module RuboCop
88
88
  nil
89
89
  end
90
90
 
91
- def previous_sibling(node)
92
- node.parent.children[node.sibling_index - 1]
93
- end
94
-
95
- def next_sibling(node)
96
- node.parent.children[node.sibling_index + 1]
97
- end
98
-
99
91
  def node_beg(node)
100
92
  node.loc.expression.begin_pos
101
93
  end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Rails
6
+ # This cop checks for redundant `travel_back` calls.
7
+ # Since Rails 5.2, `travel_back` is automatically called at the end of the test.
8
+ #
9
+ # @example
10
+ #
11
+ # # bad
12
+ # def teardown
13
+ # do_something
14
+ # travel_back
15
+ # end
16
+ #
17
+ # # good
18
+ # def teardown
19
+ # do_something
20
+ # end
21
+ #
22
+ # # bad
23
+ # after do
24
+ # do_something
25
+ # travel_back
26
+ # end
27
+ #
28
+ # # good
29
+ # after do
30
+ # do_something
31
+ # end
32
+ #
33
+ class RedundantTravelBack < Base
34
+ include RangeHelp
35
+ extend AutoCorrector
36
+ extend TargetRailsVersion
37
+
38
+ minimum_target_rails_version 5.2
39
+
40
+ MSG = 'Redundant `travel_back` detected.'
41
+ RESTRICT_ON_SEND = %i[travel_back].freeze
42
+
43
+ def on_send(node)
44
+ return unless node.each_ancestor(:def, :block).any? do |ancestor|
45
+ method_name = ancestor.def_type? ? :teardown : :after
46
+
47
+ ancestor.method?(method_name)
48
+ end
49
+
50
+ add_offense(node) do |corrector|
51
+ corrector.remove(range_by_whole_lines(node.source_range, include_final_newline: true))
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -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
@@ -343,8 +343,8 @@ module RuboCop
343
343
 
344
344
  def within_reversible_or_up_only_block?(node)
345
345
  node.each_ancestor(:block).any? do |ancestor|
346
- ancestor.block_type? &&
347
- ancestor.send_node.method?(:reversible) ||
346
+ (ancestor.block_type? &&
347
+ ancestor.send_node.method?(:reversible)) ||
348
348
  ancestor.send_node.method?(:up_only)
349
349
  end
350
350
  end
@@ -14,6 +14,8 @@ module RuboCop
14
14
  # # good
15
15
  # scope :something, -> { where(something: true) }
16
16
  class ScopeArgs < Base
17
+ extend AutoCorrector
18
+
17
19
  MSG = 'Use `lambda`/`proc` instead of a plain method call.'
18
20
  RESTRICT_ON_SEND = %i[scope].freeze
19
21
 
@@ -21,7 +23,9 @@ module RuboCop
21
23
 
22
24
  def on_send(node)
23
25
  scope?(node) do |second_arg|
24
- add_offense(second_arg)
26
+ add_offense(second_arg) do |corrector|
27
+ corrector.replace(second_arg, "-> { #{second_arg.source} }")
28
+ end
25
29
  end
26
30
  end
27
31
  end
@@ -81,7 +81,7 @@ module RuboCop
81
81
  names_from_scope = column_names_from_scope(node)
82
82
  ret.concat(names_from_scope) if names_from_scope
83
83
 
84
- ret.map! do |name|
84
+ ret = ret.flat_map do |name|
85
85
  klass = class_node(node)
86
86
  resolve_relation_into_column(
87
87
  name: name.to_s,
@@ -72,6 +72,7 @@ require_relative 'rails/read_write_attribute'
72
72
  require_relative 'rails/redundant_allow_nil'
73
73
  require_relative 'rails/redundant_foreign_key'
74
74
  require_relative 'rails/redundant_receiver_in_with_options'
75
+ require_relative 'rails/redundant_travel_back'
75
76
  require_relative 'rails/reflection_class_name'
76
77
  require_relative 'rails/refute_methods'
77
78
  require_relative 'rails/relative_date_constant'
@@ -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.12.0'
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.12.0
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-09-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -72,6 +72,7 @@ extra_rdoc_files:
72
72
  files:
73
73
  - LICENSE.txt
74
74
  - README.md
75
+ - bin/console
75
76
  - bin/setup
76
77
  - config/default.yml
77
78
  - config/obsoletion.yml
@@ -147,6 +148,7 @@ files:
147
148
  - lib/rubocop/cop/rails/redundant_allow_nil.rb
148
149
  - lib/rubocop/cop/rails/redundant_foreign_key.rb
149
150
  - lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb
151
+ - lib/rubocop/cop/rails/redundant_travel_back.rb
150
152
  - lib/rubocop/cop/rails/reflection_class_name.rb
151
153
  - lib/rubocop/cop/rails/refute_methods.rb
152
154
  - lib/rubocop/cop/rails/relative_date_constant.rb
@@ -186,7 +188,7 @@ metadata:
186
188
  homepage_uri: https://docs.rubocop.org/rubocop-rails/
187
189
  changelog_uri: https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md
188
190
  source_code_uri: https://github.com/rubocop/rubocop-rails/
189
- documentation_uri: https://docs.rubocop.org/rubocop-rails/2.11/
191
+ documentation_uri: https://docs.rubocop.org/rubocop-rails/2.12/
190
192
  bug_tracker_uri: https://github.com/rubocop/rubocop-rails/issues
191
193
  post_install_message:
192
194
  rdoc_options: []