rubocop-rails 2.14.2 → 2.15.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +38 -6
- data/lib/rubocop/cop/rails/action_filter.rb +1 -1
- data/lib/rubocop/cop/rails/active_record_callbacks_order.rb +1 -1
- data/lib/rubocop/cop/rails/active_support_aliases.rb +1 -1
- data/lib/rubocop/cop/rails/add_column_index.rb +1 -1
- data/lib/rubocop/cop/rails/after_commit_override.rb +1 -1
- data/lib/rubocop/cop/rails/application_controller.rb +1 -1
- data/lib/rubocop/cop/rails/application_job.rb +1 -1
- data/lib/rubocop/cop/rails/application_mailer.rb +1 -1
- data/lib/rubocop/cop/rails/application_record.rb +1 -1
- data/lib/rubocop/cop/rails/arel_star.rb +1 -1
- data/lib/rubocop/cop/rails/attribute_default_block_value.rb +1 -1
- data/lib/rubocop/cop/rails/belongs_to.rb +1 -1
- data/lib/rubocop/cop/rails/blank.rb +4 -4
- data/lib/rubocop/cop/rails/bulk_change_table.rb +1 -1
- data/lib/rubocop/cop/rails/compact_blank.rb +1 -1
- data/lib/rubocop/cop/rails/content_tag.rb +1 -1
- data/lib/rubocop/cop/rails/create_table_with_timestamps.rb +1 -1
- data/lib/rubocop/cop/rails/date.rb +8 -8
- data/lib/rubocop/cop/rails/default_scope.rb +1 -1
- data/lib/rubocop/cop/rails/delegate.rb +5 -10
- data/lib/rubocop/cop/rails/delegate_allow_blank.rb +1 -1
- data/lib/rubocop/cop/rails/deprecated_active_model_errors_methods.rb +58 -2
- data/lib/rubocop/cop/rails/dot_separated_keys.rb +71 -0
- data/lib/rubocop/cop/rails/duplicate_association.rb +2 -2
- data/lib/rubocop/cop/rails/duplicate_scope.rb +1 -1
- data/lib/rubocop/cop/rails/duration_arithmetic.rb +1 -1
- data/lib/rubocop/cop/rails/dynamic_find_by.rb +1 -1
- data/lib/rubocop/cop/rails/eager_evaluation_log_message.rb +1 -1
- data/lib/rubocop/cop/rails/enum_hash.rb +2 -3
- data/lib/rubocop/cop/rails/enum_uniqueness.rb +1 -1
- data/lib/rubocop/cop/rails/environment_comparison.rb +1 -1
- data/lib/rubocop/cop/rails/environment_variable_access.rb +1 -1
- data/lib/rubocop/cop/rails/exit.rb +1 -1
- data/lib/rubocop/cop/rails/expanded_date_range.rb +39 -23
- data/lib/rubocop/cop/rails/file_path.rb +12 -9
- data/lib/rubocop/cop/rails/find_by.rb +1 -1
- data/lib/rubocop/cop/rails/find_by_id.rb +1 -1
- data/lib/rubocop/cop/rails/find_each.rb +1 -1
- data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +1 -1
- data/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb +10 -2
- data/lib/rubocop/cop/rails/helper_instance_variable.rb +2 -2
- data/lib/rubocop/cop/rails/http_positional_arguments.rb +1 -1
- data/lib/rubocop/cop/rails/i18n_lazy_lookup.rb +1 -1
- data/lib/rubocop/cop/rails/i18n_locale_assignment.rb +1 -1
- data/lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb +2 -2
- data/lib/rubocop/cop/rails/index_by.rb +1 -1
- data/lib/rubocop/cop/rails/index_with.rb +1 -1
- data/lib/rubocop/cop/rails/inquiry.rb +1 -1
- data/lib/rubocop/cop/rails/inverse_of.rb +1 -1
- data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +3 -3
- data/lib/rubocop/cop/rails/link_to_blank.rb +1 -1
- data/lib/rubocop/cop/rails/mailer_name.rb +1 -1
- data/lib/rubocop/cop/rails/match_route.rb +1 -1
- data/lib/rubocop/cop/rails/migration_class_name.rb +1 -1
- data/lib/rubocop/cop/rails/negate_include.rb +1 -1
- data/lib/rubocop/cop/rails/not_null_column.rb +1 -1
- data/lib/rubocop/cop/rails/order_by_id.rb +2 -3
- data/lib/rubocop/cop/rails/output.rb +1 -1
- data/lib/rubocop/cop/rails/output_safety.rb +1 -1
- data/lib/rubocop/cop/rails/pick.rb +1 -1
- data/lib/rubocop/cop/rails/pluck.rb +1 -1
- data/lib/rubocop/cop/rails/pluck_id.rb +1 -1
- data/lib/rubocop/cop/rails/pluck_in_where.rb +1 -1
- data/lib/rubocop/cop/rails/pluralization_grammar.rb +1 -1
- data/lib/rubocop/cop/rails/presence.rb +1 -1
- data/lib/rubocop/cop/rails/present.rb +2 -2
- data/lib/rubocop/cop/rails/rake_environment.rb +1 -1
- data/lib/rubocop/cop/rails/read_write_attribute.rb +1 -1
- data/lib/rubocop/cop/rails/redundant_foreign_key.rb +1 -1
- data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +1 -1
- data/lib/rubocop/cop/rails/redundant_travel_back.rb +1 -1
- data/lib/rubocop/cop/rails/reflection_class_name.rb +1 -1
- data/lib/rubocop/cop/rails/relative_date_constant.rb +1 -1
- data/lib/rubocop/cop/rails/render_inline.rb +1 -1
- data/lib/rubocop/cop/rails/render_plain_text.rb +1 -1
- data/lib/rubocop/cop/rails/request_referer.rb +1 -1
- data/lib/rubocop/cop/rails/require_dependency.rb +1 -1
- data/lib/rubocop/cop/rails/reversible_migration.rb +1 -1
- data/lib/rubocop/cop/rails/reversible_migration_method_definition.rb +4 -4
- data/lib/rubocop/cop/rails/root_public_path.rb +59 -0
- data/lib/rubocop/cop/rails/safe_navigation.rb +7 -12
- data/lib/rubocop/cop/rails/safe_navigation_with_blank.rb +1 -1
- data/lib/rubocop/cop/rails/save_bang.rb +2 -2
- data/lib/rubocop/cop/rails/schema_comment.rb +1 -1
- data/lib/rubocop/cop/rails/scope_args.rb +1 -1
- data/lib/rubocop/cop/rails/short_i18n.rb +1 -1
- data/lib/rubocop/cop/rails/skips_model_validations.rb +1 -1
- data/lib/rubocop/cop/rails/squished_sql_heredocs.rb +1 -1
- data/lib/rubocop/cop/rails/strip_heredoc.rb +56 -0
- data/lib/rubocop/cop/rails/table_name_assignment.rb +1 -1
- data/lib/rubocop/cop/rails/time_zone.rb +7 -7
- data/lib/rubocop/cop/rails/time_zone_assignment.rb +3 -3
- data/lib/rubocop/cop/rails/to_formatted_s.rb +46 -0
- data/lib/rubocop/cop/rails/transaction_exit_statement.rb +17 -10
- data/lib/rubocop/cop/rails/unique_validation_without_index.rb +2 -2
- data/lib/rubocop/cop/rails/unknown_env.rb +1 -1
- data/lib/rubocop/cop/rails/unused_ignored_columns.rb +1 -1
- data/lib/rubocop/cop/rails/validation.rb +1 -1
- data/lib/rubocop/cop/rails/where_equals.rb +1 -1
- data/lib/rubocop/cop/rails/where_exists.rb +2 -2
- data/lib/rubocop/cop/rails/where_not.rb +1 -1
- data/lib/rubocop/cop/rails_cops.rb +4 -0
- data/lib/rubocop/rails/schema_loader/schema.rb +8 -5
- data/lib/rubocop/rails/version.rb +1 -1
- data/lib/rubocop-rails.rb +8 -0
- metadata +9 -5
@@ -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
|
@@ -32,12 +32,14 @@ module RuboCop
|
|
32
32
|
raise "Unexpected type: #{ast.type}" unless ast.block_type?
|
33
33
|
|
34
34
|
each_table(ast) do |table_def|
|
35
|
+
next unless table_def.method?(:create_table)
|
36
|
+
|
35
37
|
@tables << Table.new(table_def)
|
36
38
|
end
|
37
39
|
|
38
40
|
# Compatibility for Rails 4.2.
|
39
41
|
each_add_index(ast) do |add_index_def|
|
40
|
-
@
|
42
|
+
@add_indices << AddIndex.new(add_index_def)
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
@@ -56,6 +58,7 @@ module RuboCop
|
|
56
58
|
|
57
59
|
def each_add_index(ast)
|
58
60
|
ast.body.children.each do |node|
|
61
|
+
next unless node.respond_to?(:send_type?)
|
59
62
|
next if !node&.send_type? || !node.method?(:add_index)
|
60
63
|
|
61
64
|
yield(node)
|
data/lib/rubocop-rails.rb
CHANGED
@@ -13,3 +13,11 @@ require_relative 'rubocop/rails/schema_loader/schema'
|
|
13
13
|
RuboCop::Rails::Inject.defaults!
|
14
14
|
|
15
15
|
require_relative 'rubocop/cop/rails_cops'
|
16
|
+
|
17
|
+
RuboCop::Cop::Style::RedundantSelf.singleton_class.prepend(
|
18
|
+
Module.new do
|
19
|
+
def autocorrect_incompatible_with
|
20
|
+
super.push(RuboCop::Cop::Rails::SafeNavigation)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
)
|
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.
|
4
|
+
version: 2.15.2
|
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-
|
13
|
+
date: 2022-07-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/rubocop/cop/rails/delegate.rb
|
111
111
|
- lib/rubocop/cop/rails/delegate_allow_blank.rb
|
112
112
|
- lib/rubocop/cop/rails/deprecated_active_model_errors_methods.rb
|
113
|
+
- lib/rubocop/cop/rails/dot_separated_keys.rb
|
113
114
|
- lib/rubocop/cop/rails/duplicate_association.rb
|
114
115
|
- lib/rubocop/cop/rails/duplicate_scope.rb
|
115
116
|
- lib/rubocop/cop/rails/duration_arithmetic.rb
|
@@ -172,6 +173,7 @@ files:
|
|
172
173
|
- lib/rubocop/cop/rails/reversible_migration.rb
|
173
174
|
- lib/rubocop/cop/rails/reversible_migration_method_definition.rb
|
174
175
|
- lib/rubocop/cop/rails/root_join_chain.rb
|
176
|
+
- lib/rubocop/cop/rails/root_public_path.rb
|
175
177
|
- lib/rubocop/cop/rails/safe_navigation.rb
|
176
178
|
- lib/rubocop/cop/rails/safe_navigation_with_blank.rb
|
177
179
|
- lib/rubocop/cop/rails/save_bang.rb
|
@@ -180,9 +182,11 @@ files:
|
|
180
182
|
- lib/rubocop/cop/rails/short_i18n.rb
|
181
183
|
- lib/rubocop/cop/rails/skips_model_validations.rb
|
182
184
|
- lib/rubocop/cop/rails/squished_sql_heredocs.rb
|
185
|
+
- lib/rubocop/cop/rails/strip_heredoc.rb
|
183
186
|
- lib/rubocop/cop/rails/table_name_assignment.rb
|
184
187
|
- lib/rubocop/cop/rails/time_zone.rb
|
185
188
|
- lib/rubocop/cop/rails/time_zone_assignment.rb
|
189
|
+
- lib/rubocop/cop/rails/to_formatted_s.rb
|
186
190
|
- lib/rubocop/cop/rails/transaction_exit_statement.rb
|
187
191
|
- lib/rubocop/cop/rails/uniq_before_pluck.rb
|
188
192
|
- lib/rubocop/cop/rails/unique_validation_without_index.rb
|
@@ -205,7 +209,7 @@ metadata:
|
|
205
209
|
homepage_uri: https://docs.rubocop.org/rubocop-rails/
|
206
210
|
changelog_uri: https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md
|
207
211
|
source_code_uri: https://github.com/rubocop/rubocop-rails/
|
208
|
-
documentation_uri: https://docs.rubocop.org/rubocop-rails/2.
|
212
|
+
documentation_uri: https://docs.rubocop.org/rubocop-rails/2.15/
|
209
213
|
bug_tracker_uri: https://github.com/rubocop/rubocop-rails/issues
|
210
214
|
rubygems_mfa_required: 'true'
|
211
215
|
post_install_message:
|
@@ -216,14 +220,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
220
|
requirements:
|
217
221
|
- - ">="
|
218
222
|
- !ruby/object:Gem::Version
|
219
|
-
version: 2.
|
223
|
+
version: 2.6.0
|
220
224
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
225
|
requirements:
|
222
226
|
- - ">="
|
223
227
|
- !ruby/object:Gem::Version
|
224
228
|
version: '0'
|
225
229
|
requirements: []
|
226
|
-
rubygems_version: 3.
|
230
|
+
rubygems_version: 3.1.6
|
227
231
|
signing_key:
|
228
232
|
specification_version: 4
|
229
233
|
summary: Automatic Rails code style checking tool.
|