rubocop-rails 2.5.2 → 2.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +2 -2
  4. data/config/default.yml +192 -11
  5. data/lib/rubocop/cop/mixin/active_record_helper.rb +9 -3
  6. data/lib/rubocop/cop/mixin/index_method.rb +25 -1
  7. data/lib/rubocop/cop/rails/active_record_callbacks_order.rb +143 -0
  8. data/lib/rubocop/cop/rails/after_commit_override.rb +91 -0
  9. data/lib/rubocop/cop/rails/content_tag.rb +69 -0
  10. data/lib/rubocop/cop/rails/create_table_with_timestamps.rb +1 -3
  11. data/lib/rubocop/cop/rails/default_scope.rb +54 -0
  12. data/lib/rubocop/cop/rails/delegate.rb +2 -4
  13. data/lib/rubocop/cop/rails/dynamic_find_by.rb +41 -15
  14. data/lib/rubocop/cop/rails/exit.rb +2 -2
  15. data/lib/rubocop/cop/rails/file_path.rb +2 -1
  16. data/lib/rubocop/cop/rails/find_by_id.rb +103 -0
  17. data/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb +1 -5
  18. data/lib/rubocop/cop/rails/helper_instance_variable.rb +2 -0
  19. data/lib/rubocop/cop/rails/http_positional_arguments.rb +7 -1
  20. data/lib/rubocop/cop/rails/http_status.rb +2 -0
  21. data/lib/rubocop/cop/rails/index_by.rb +9 -1
  22. data/lib/rubocop/cop/rails/index_with.rb +9 -1
  23. data/lib/rubocop/cop/rails/inquiry.rb +38 -0
  24. data/lib/rubocop/cop/rails/inverse_of.rb +0 -4
  25. data/lib/rubocop/cop/rails/link_to_blank.rb +3 -3
  26. data/lib/rubocop/cop/rails/mailer_name.rb +80 -0
  27. data/lib/rubocop/cop/rails/match_route.rb +119 -0
  28. data/lib/rubocop/cop/rails/negate_include.rb +39 -0
  29. data/lib/rubocop/cop/rails/order_by_id.rb +53 -0
  30. data/lib/rubocop/cop/rails/pick.rb +55 -0
  31. data/lib/rubocop/cop/rails/pluck.rb +59 -0
  32. data/lib/rubocop/cop/rails/pluck_id.rb +58 -0
  33. data/lib/rubocop/cop/rails/pluck_in_where.rb +70 -0
  34. data/lib/rubocop/cop/rails/presence.rb +2 -6
  35. data/lib/rubocop/cop/rails/rake_environment.rb +17 -0
  36. data/lib/rubocop/cop/rails/redundant_foreign_key.rb +80 -0
  37. data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +0 -3
  38. data/lib/rubocop/cop/rails/reflection_class_name.rb +1 -1
  39. data/lib/rubocop/cop/rails/relative_date_constant.rb +5 -2
  40. data/lib/rubocop/cop/rails/render_inline.rb +40 -0
  41. data/lib/rubocop/cop/rails/render_plain_text.rb +76 -0
  42. data/lib/rubocop/cop/rails/reversible_migration.rb +80 -1
  43. data/lib/rubocop/cop/rails/safe_navigation.rb +1 -1
  44. data/lib/rubocop/cop/rails/save_bang.rb +8 -9
  45. data/lib/rubocop/cop/rails/short_i18n.rb +76 -0
  46. data/lib/rubocop/cop/rails/skips_model_validations.rb +46 -8
  47. data/lib/rubocop/cop/rails/squished_sql_heredocs.rb +83 -0
  48. data/lib/rubocop/cop/rails/time_zone.rb +1 -3
  49. data/lib/rubocop/cop/rails/uniq_before_pluck.rb +14 -12
  50. data/lib/rubocop/cop/rails/unique_validation_without_index.rb +16 -6
  51. data/lib/rubocop/cop/rails/unknown_env.rb +18 -6
  52. data/lib/rubocop/cop/rails/where_exists.rb +131 -0
  53. data/lib/rubocop/cop/rails/where_not.rb +108 -0
  54. data/lib/rubocop/cop/rails_cops.rb +21 -0
  55. data/lib/rubocop/rails/schema_loader/schema.rb +4 -4
  56. data/lib/rubocop/rails/version.rb +1 -1
  57. metadata +31 -10
@@ -6,8 +6,10 @@ require_relative 'mixin/target_rails_version'
6
6
 
7
7
  require_relative 'rails/action_filter'
8
8
  require_relative 'rails/active_record_aliases'
9
+ require_relative 'rails/active_record_callbacks_order'
9
10
  require_relative 'rails/active_record_override'
10
11
  require_relative 'rails/active_support_aliases'
12
+ require_relative 'rails/after_commit_override'
11
13
  require_relative 'rails/application_controller'
12
14
  require_relative 'rails/application_job'
13
15
  require_relative 'rails/application_mailer'
@@ -16,8 +18,10 @@ require_relative 'rails/assert_not'
16
18
  require_relative 'rails/belongs_to'
17
19
  require_relative 'rails/blank'
18
20
  require_relative 'rails/bulk_change_table'
21
+ require_relative 'rails/content_tag'
19
22
  require_relative 'rails/create_table_with_timestamps'
20
23
  require_relative 'rails/date'
24
+ require_relative 'rails/default_scope'
21
25
  require_relative 'rails/delegate'
22
26
  require_relative 'rails/delegate_allow_blank'
23
27
  require_relative 'rails/dynamic_find_by'
@@ -27,6 +31,7 @@ require_relative 'rails/environment_comparison'
27
31
  require_relative 'rails/exit'
28
32
  require_relative 'rails/file_path'
29
33
  require_relative 'rails/find_by'
34
+ require_relative 'rails/find_by_id'
30
35
  require_relative 'rails/find_each'
31
36
  require_relative 'rails/has_and_belongs_to_many'
32
37
  require_relative 'rails/has_many_or_has_one_dependent'
@@ -36,31 +41,47 @@ require_relative 'rails/http_status'
36
41
  require_relative 'rails/ignored_skip_action_filter_option'
37
42
  require_relative 'rails/index_by'
38
43
  require_relative 'rails/index_with'
44
+ require_relative 'rails/inquiry'
39
45
  require_relative 'rails/inverse_of'
40
46
  require_relative 'rails/lexically_scoped_action_filter'
41
47
  require_relative 'rails/link_to_blank'
48
+ require_relative 'rails/mailer_name'
49
+ require_relative 'rails/match_route'
50
+ require_relative 'rails/negate_include'
42
51
  require_relative 'rails/not_null_column'
52
+ require_relative 'rails/order_by_id'
43
53
  require_relative 'rails/output'
44
54
  require_relative 'rails/output_safety'
55
+ require_relative 'rails/pick'
56
+ require_relative 'rails/pluck'
57
+ require_relative 'rails/pluck_id'
58
+ require_relative 'rails/pluck_in_where'
45
59
  require_relative 'rails/pluralization_grammar'
46
60
  require_relative 'rails/presence'
47
61
  require_relative 'rails/present'
48
62
  require_relative 'rails/rake_environment'
49
63
  require_relative 'rails/read_write_attribute'
50
64
  require_relative 'rails/redundant_allow_nil'
65
+ require_relative 'rails/redundant_foreign_key'
51
66
  require_relative 'rails/redundant_receiver_in_with_options'
52
67
  require_relative 'rails/reflection_class_name'
53
68
  require_relative 'rails/refute_methods'
54
69
  require_relative 'rails/relative_date_constant'
70
+ require_relative 'rails/render_inline'
71
+ require_relative 'rails/render_plain_text'
55
72
  require_relative 'rails/request_referer'
56
73
  require_relative 'rails/reversible_migration'
57
74
  require_relative 'rails/safe_navigation'
58
75
  require_relative 'rails/safe_navigation_with_blank'
59
76
  require_relative 'rails/save_bang'
60
77
  require_relative 'rails/scope_args'
78
+ require_relative 'rails/short_i18n'
61
79
  require_relative 'rails/skips_model_validations'
80
+ require_relative 'rails/squished_sql_heredocs'
62
81
  require_relative 'rails/time_zone'
63
82
  require_relative 'rails/uniq_before_pluck'
64
83
  require_relative 'rails/unique_validation_without_index'
65
84
  require_relative 'rails/unknown_env'
66
85
  require_relative 'rails/validation'
86
+ require_relative 'rails/where_exists'
87
+ require_relative 'rails/where_not'
@@ -97,14 +97,12 @@ module RuboCop
97
97
  end.compact
98
98
  end
99
99
 
100
- def each_content(node)
100
+ def each_content(node, &block)
101
101
  return enum_for(__method__, node) unless block_given?
102
102
 
103
103
  case node.body&.type
104
104
  when :begin
105
- node.body.children.each do |child|
106
- yield(child)
107
- end
105
+ node.body.children.each(&block)
108
106
  else
109
107
  yield(node.body)
110
108
  end
@@ -178,6 +176,8 @@ module RuboCop
178
176
  attr_reader :table_name
179
177
 
180
178
  def initialize(node)
179
+ super(node)
180
+
181
181
  @table_name = node.first_argument.value
182
182
  @columns, @expression = build_columns_or_expr(node.arguments[1])
183
183
  @unique = nil
@@ -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.5.2'
7
+ STRING = '2.8.1'
8
8
  end
9
9
  end
10
10
  end
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.5.2
4
+ version: 2.8.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: 2020-04-09 00:00:00.000000000 Z
13
+ date: 2020-09-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 4.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '0'
28
+ version: 4.2.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rack
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -46,14 +46,14 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.72.0
49
+ version: 0.87.0
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 0.72.0
56
+ version: 0.87.0
57
57
  description: |
58
58
  Automatic Rails code style checking tool.
59
59
  A RuboCop extension focused on enforcing Rails best practices and coding conventions.
@@ -74,8 +74,10 @@ files:
74
74
  - lib/rubocop/cop/mixin/target_rails_version.rb
75
75
  - lib/rubocop/cop/rails/action_filter.rb
76
76
  - lib/rubocop/cop/rails/active_record_aliases.rb
77
+ - lib/rubocop/cop/rails/active_record_callbacks_order.rb
77
78
  - lib/rubocop/cop/rails/active_record_override.rb
78
79
  - lib/rubocop/cop/rails/active_support_aliases.rb
80
+ - lib/rubocop/cop/rails/after_commit_override.rb
79
81
  - lib/rubocop/cop/rails/application_controller.rb
80
82
  - lib/rubocop/cop/rails/application_job.rb
81
83
  - lib/rubocop/cop/rails/application_mailer.rb
@@ -84,8 +86,10 @@ files:
84
86
  - lib/rubocop/cop/rails/belongs_to.rb
85
87
  - lib/rubocop/cop/rails/blank.rb
86
88
  - lib/rubocop/cop/rails/bulk_change_table.rb
89
+ - lib/rubocop/cop/rails/content_tag.rb
87
90
  - lib/rubocop/cop/rails/create_table_with_timestamps.rb
88
91
  - lib/rubocop/cop/rails/date.rb
92
+ - lib/rubocop/cop/rails/default_scope.rb
89
93
  - lib/rubocop/cop/rails/delegate.rb
90
94
  - lib/rubocop/cop/rails/delegate_allow_blank.rb
91
95
  - lib/rubocop/cop/rails/dynamic_find_by.rb
@@ -95,6 +99,7 @@ files:
95
99
  - lib/rubocop/cop/rails/exit.rb
96
100
  - lib/rubocop/cop/rails/file_path.rb
97
101
  - lib/rubocop/cop/rails/find_by.rb
102
+ - lib/rubocop/cop/rails/find_by_id.rb
98
103
  - lib/rubocop/cop/rails/find_each.rb
99
104
  - lib/rubocop/cop/rails/has_and_belongs_to_many.rb
100
105
  - lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb
@@ -104,34 +109,50 @@ files:
104
109
  - lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb
105
110
  - lib/rubocop/cop/rails/index_by.rb
106
111
  - lib/rubocop/cop/rails/index_with.rb
112
+ - lib/rubocop/cop/rails/inquiry.rb
107
113
  - lib/rubocop/cop/rails/inverse_of.rb
108
114
  - lib/rubocop/cop/rails/lexically_scoped_action_filter.rb
109
115
  - lib/rubocop/cop/rails/link_to_blank.rb
116
+ - lib/rubocop/cop/rails/mailer_name.rb
117
+ - lib/rubocop/cop/rails/match_route.rb
118
+ - lib/rubocop/cop/rails/negate_include.rb
110
119
  - lib/rubocop/cop/rails/not_null_column.rb
120
+ - lib/rubocop/cop/rails/order_by_id.rb
111
121
  - lib/rubocop/cop/rails/output.rb
112
122
  - lib/rubocop/cop/rails/output_safety.rb
123
+ - lib/rubocop/cop/rails/pick.rb
124
+ - lib/rubocop/cop/rails/pluck.rb
125
+ - lib/rubocop/cop/rails/pluck_id.rb
126
+ - lib/rubocop/cop/rails/pluck_in_where.rb
113
127
  - lib/rubocop/cop/rails/pluralization_grammar.rb
114
128
  - lib/rubocop/cop/rails/presence.rb
115
129
  - lib/rubocop/cop/rails/present.rb
116
130
  - lib/rubocop/cop/rails/rake_environment.rb
117
131
  - lib/rubocop/cop/rails/read_write_attribute.rb
118
132
  - lib/rubocop/cop/rails/redundant_allow_nil.rb
133
+ - lib/rubocop/cop/rails/redundant_foreign_key.rb
119
134
  - lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb
120
135
  - lib/rubocop/cop/rails/reflection_class_name.rb
121
136
  - lib/rubocop/cop/rails/refute_methods.rb
122
137
  - lib/rubocop/cop/rails/relative_date_constant.rb
138
+ - lib/rubocop/cop/rails/render_inline.rb
139
+ - lib/rubocop/cop/rails/render_plain_text.rb
123
140
  - lib/rubocop/cop/rails/request_referer.rb
124
141
  - lib/rubocop/cop/rails/reversible_migration.rb
125
142
  - lib/rubocop/cop/rails/safe_navigation.rb
126
143
  - lib/rubocop/cop/rails/safe_navigation_with_blank.rb
127
144
  - lib/rubocop/cop/rails/save_bang.rb
128
145
  - lib/rubocop/cop/rails/scope_args.rb
146
+ - lib/rubocop/cop/rails/short_i18n.rb
129
147
  - lib/rubocop/cop/rails/skips_model_validations.rb
148
+ - lib/rubocop/cop/rails/squished_sql_heredocs.rb
130
149
  - lib/rubocop/cop/rails/time_zone.rb
131
150
  - lib/rubocop/cop/rails/uniq_before_pluck.rb
132
151
  - lib/rubocop/cop/rails/unique_validation_without_index.rb
133
152
  - lib/rubocop/cop/rails/unknown_env.rb
134
153
  - lib/rubocop/cop/rails/validation.rb
154
+ - lib/rubocop/cop/rails/where_exists.rb
155
+ - lib/rubocop/cop/rails/where_not.rb
135
156
  - lib/rubocop/cop/rails_cops.rb
136
157
  - lib/rubocop/rails.rb
137
158
  - lib/rubocop/rails/inject.rb
@@ -142,10 +163,10 @@ homepage: https://github.com/rubocop-hq/rubocop-rails
142
163
  licenses:
143
164
  - MIT
144
165
  metadata:
145
- homepage_uri: https://docs.rubocop.org/projects/rails/
166
+ homepage_uri: https://docs.rubocop.org/rubocop-rails/
146
167
  changelog_uri: https://github.com/rubocop-hq/rubocop-rails/blob/master/CHANGELOG.md
147
168
  source_code_uri: https://github.com/rubocop-hq/rubocop-rails/
148
- documentation_uri: https://docs.rubocop.org/projects/rails/
169
+ documentation_uri: https://docs.rubocop.org/rubocop-rails/
149
170
  bug_tracker_uri: https://github.com/rubocop-hq/rubocop-rails/issues
150
171
  post_install_message:
151
172
  rdoc_options: []
@@ -155,14 +176,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
176
  requirements:
156
177
  - - ">="
157
178
  - !ruby/object:Gem::Version
158
- version: 2.3.0
179
+ version: 2.4.0
159
180
  required_rubygems_version: !ruby/object:Gem::Requirement
160
181
  requirements:
161
182
  - - ">="
162
183
  - !ruby/object:Gem::Version
163
184
  version: '0'
164
185
  requirements: []
165
- rubygems_version: 3.1.2
186
+ rubygems_version: 3.1.4
166
187
  signing_key:
167
188
  specification_version: 4
168
189
  summary: Automatic Rails code style checking tool.