rubocop-rails 2.7.1 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +18 -2
  4. data/config/default.yml +144 -6
  5. data/config/obsoletion.yml +7 -0
  6. data/lib/rubocop/cop/mixin/active_record_helper.rb +16 -3
  7. data/lib/rubocop/cop/mixin/enforce_superclass.rb +40 -0
  8. data/lib/rubocop/cop/mixin/index_method.rb +25 -11
  9. data/lib/rubocop/cop/rails/action_filter.rb +10 -14
  10. data/lib/rubocop/cop/rails/active_record_aliases.rb +13 -17
  11. data/lib/rubocop/cop/rails/active_record_callbacks_order.rb +19 -16
  12. data/lib/rubocop/cop/rails/active_record_override.rb +1 -1
  13. data/lib/rubocop/cop/rails/active_support_aliases.rb +12 -21
  14. data/lib/rubocop/cop/rails/after_commit_override.rb +91 -0
  15. data/lib/rubocop/cop/rails/application_controller.rb +3 -7
  16. data/lib/rubocop/cop/rails/application_job.rb +2 -1
  17. data/lib/rubocop/cop/rails/application_mailer.rb +2 -7
  18. data/lib/rubocop/cop/rails/application_record.rb +2 -7
  19. data/lib/rubocop/cop/rails/arel_star.rb +41 -0
  20. data/lib/rubocop/cop/rails/assert_not.rb +8 -10
  21. data/lib/rubocop/cop/rails/attribute_default_block_value.rb +90 -0
  22. data/lib/rubocop/cop/rails/belongs_to.rb +10 -19
  23. data/lib/rubocop/cop/rails/blank.rb +31 -27
  24. data/lib/rubocop/cop/rails/bulk_change_table.rb +1 -1
  25. data/lib/rubocop/cop/rails/content_tag.rb +34 -19
  26. data/lib/rubocop/cop/rails/create_table_with_timestamps.rb +2 -1
  27. data/lib/rubocop/cop/rails/date.rb +10 -11
  28. data/lib/rubocop/cop/rails/default_scope.rb +11 -4
  29. data/lib/rubocop/cop/rails/delegate.rb +9 -9
  30. data/lib/rubocop/cop/rails/delegate_allow_blank.rb +7 -8
  31. data/lib/rubocop/cop/rails/dynamic_find_by.rb +15 -12
  32. data/lib/rubocop/cop/rails/enum_hash.rb +11 -10
  33. data/lib/rubocop/cop/rails/enum_uniqueness.rb +2 -1
  34. data/lib/rubocop/cop/rails/environment_comparison.rb +18 -14
  35. data/lib/rubocop/cop/rails/environment_variable_access.rb +67 -0
  36. data/lib/rubocop/cop/rails/exit.rb +4 -10
  37. data/lib/rubocop/cop/rails/file_path.rb +7 -8
  38. data/lib/rubocop/cop/rails/find_by.rb +13 -13
  39. data/lib/rubocop/cop/rails/find_by_id.rb +12 -21
  40. data/lib/rubocop/cop/rails/find_each.rb +19 -18
  41. data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +3 -2
  42. data/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb +37 -10
  43. data/lib/rubocop/cop/rails/helper_instance_variable.rb +30 -2
  44. data/lib/rubocop/cop/rails/http_positional_arguments.rb +32 -21
  45. data/lib/rubocop/cop/rails/http_status.rb +7 -9
  46. data/lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb +8 -6
  47. data/lib/rubocop/cop/rails/index_by.rb +11 -2
  48. data/lib/rubocop/cop/rails/index_with.rb +11 -2
  49. data/lib/rubocop/cop/rails/inquiry.rb +7 -2
  50. data/lib/rubocop/cop/rails/inverse_of.rb +3 -2
  51. data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +17 -15
  52. data/lib/rubocop/cop/rails/link_to_blank.rb +25 -23
  53. data/lib/rubocop/cop/rails/mailer_name.rb +19 -13
  54. data/lib/rubocop/cop/rails/match_route.rb +14 -13
  55. data/lib/rubocop/cop/rails/negate_include.rb +10 -8
  56. data/lib/rubocop/cop/rails/not_null_column.rb +2 -1
  57. data/lib/rubocop/cop/rails/order_by_id.rb +52 -0
  58. data/lib/rubocop/cop/rails/output.rb +5 -2
  59. data/lib/rubocop/cop/rails/output_safety.rb +3 -2
  60. data/lib/rubocop/cop/rails/pick.rb +14 -12
  61. data/lib/rubocop/cop/rails/pluck.rb +6 -9
  62. data/lib/rubocop/cop/rails/pluck_id.rb +4 -6
  63. data/lib/rubocop/cop/rails/pluck_in_where.rb +39 -5
  64. data/lib/rubocop/cop/rails/pluralization_grammar.rb +10 -14
  65. data/lib/rubocop/cop/rails/presence.rb +12 -13
  66. data/lib/rubocop/cop/rails/present.rb +30 -24
  67. data/lib/rubocop/cop/rails/rake_environment.rb +8 -10
  68. data/lib/rubocop/cop/rails/read_write_attribute.rb +12 -11
  69. data/lib/rubocop/cop/rails/redundant_allow_nil.rb +29 -31
  70. data/lib/rubocop/cop/rails/redundant_foreign_key.rb +9 -12
  71. data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +11 -10
  72. data/lib/rubocop/cop/rails/reflection_class_name.rb +18 -4
  73. data/lib/rubocop/cop/rails/refute_methods.rb +9 -10
  74. data/lib/rubocop/cop/rails/relative_date_constant.rb +34 -22
  75. data/lib/rubocop/cop/rails/render_inline.rb +2 -1
  76. data/lib/rubocop/cop/rails/render_plain_text.rb +9 -14
  77. data/lib/rubocop/cop/rails/request_referer.rb +7 -7
  78. data/lib/rubocop/cop/rails/require_dependency.rb +38 -0
  79. data/lib/rubocop/cop/rails/reversible_migration.rb +83 -8
  80. data/lib/rubocop/cop/rails/reversible_migration_method_definition.rb +75 -0
  81. data/lib/rubocop/cop/rails/safe_navigation.rb +30 -11
  82. data/lib/rubocop/cop/rails/safe_navigation_with_blank.rb +5 -10
  83. data/lib/rubocop/cop/rails/save_bang.rb +19 -22
  84. data/lib/rubocop/cop/rails/scope_args.rb +2 -1
  85. data/lib/rubocop/cop/rails/short_i18n.rb +7 -9
  86. data/lib/rubocop/cop/rails/skips_model_validations.rb +4 -4
  87. data/lib/rubocop/cop/rails/squished_sql_heredocs.rb +82 -0
  88. data/lib/rubocop/cop/rails/time_zone.rb +35 -25
  89. data/lib/rubocop/cop/rails/time_zone_assignment.rb +37 -0
  90. data/lib/rubocop/cop/rails/uniq_before_pluck.rb +6 -6
  91. data/lib/rubocop/cop/rails/unique_validation_without_index.rb +18 -8
  92. data/lib/rubocop/cop/rails/unknown_env.rb +3 -3
  93. data/lib/rubocop/cop/rails/validation.rb +15 -14
  94. data/lib/rubocop/cop/rails/where_equals.rb +98 -0
  95. data/lib/rubocop/cop/rails/where_exists.rb +85 -16
  96. data/lib/rubocop/cop/rails/where_not.rb +101 -0
  97. data/lib/rubocop/cop/rails_cops.rb +12 -0
  98. data/lib/rubocop/rails.rb +2 -0
  99. data/lib/rubocop/rails/schema_loader.rb +4 -4
  100. data/lib/rubocop/rails/schema_loader/schema.rb +4 -8
  101. data/lib/rubocop/rails/version.rb +5 -1
  102. metadata +33 -14
data/lib/rubocop/rails.rb CHANGED
@@ -8,5 +8,7 @@ module RuboCop
8
8
  CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
9
9
 
10
10
  private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
11
+
12
+ ::RuboCop::ConfigObsoletion.files << PROJECT_ROOT.join('config', 'obsoletion.yml')
11
13
  end
12
14
  end
@@ -13,15 +13,15 @@ module RuboCop
13
13
  #
14
14
  # @return [Schema, nil]
15
15
  def load(target_ruby_version)
16
- return @schema if defined?(@schema)
16
+ return @load if defined?(@load)
17
17
 
18
- @schema = load!(target_ruby_version)
18
+ @load = load!(target_ruby_version)
19
19
  end
20
20
 
21
21
  def reset!
22
- return unless instance_variable_defined?(:@schema)
22
+ return unless instance_variable_defined?(:@load)
23
23
 
24
- remove_instance_variable(:@schema)
24
+ remove_instance_variable(:@load)
25
25
  end
26
26
 
27
27
  def db_schema_path
@@ -97,14 +97,12 @@ module RuboCop
97
97
  end.compact
98
98
  end
99
99
 
100
- def each_content(node)
101
- return enum_for(__method__, node) unless block_given?
100
+ def each_content(node, &block)
101
+ return enum_for(__method__, node) unless block
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
@@ -130,9 +128,7 @@ module RuboCop
130
128
  return unless pairs.hash_type?
131
129
 
132
130
  pairs.each_pair do |k, v|
133
- if k.value == :null
134
- @not_null = v.true_type? ? false : true
135
- end
131
+ @not_null = !v.true_type? if k.value == :null
136
132
  end
137
133
  end
138
134
  end
@@ -4,7 +4,11 @@ module RuboCop
4
4
  module Rails
5
5
  # This module holds the RuboCop Rails version information.
6
6
  module Version
7
- STRING = '2.7.1'
7
+ STRING = '2.10.0'
8
+
9
+ def self.document_version
10
+ STRING.match('\d+\.\d+').to_s
11
+ end
8
12
  end
9
13
  end
10
14
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
8
8
  - Jonas Arvidsson
9
9
  - Yuji Nakayama
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-07-26 00:00:00.000000000 Z
13
+ date: 2021-05-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -46,14 +46,20 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.87.0
49
+ version: 1.7.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '2.0'
50
53
  type: :runtime
51
54
  prerelease: false
52
55
  version_requirements: !ruby/object:Gem::Requirement
53
56
  requirements:
54
57
  - - ">="
55
58
  - !ruby/object:Gem::Version
56
- version: 0.87.0
59
+ version: 1.7.0
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '2.0'
57
63
  description: |
58
64
  Automatic Rails code style checking tool.
59
65
  A RuboCop extension focused on enforcing Rails best practices and coding conventions.
@@ -68,8 +74,10 @@ files:
68
74
  - README.md
69
75
  - bin/setup
70
76
  - config/default.yml
77
+ - config/obsoletion.yml
71
78
  - lib/rubocop-rails.rb
72
79
  - lib/rubocop/cop/mixin/active_record_helper.rb
80
+ - lib/rubocop/cop/mixin/enforce_superclass.rb
73
81
  - lib/rubocop/cop/mixin/index_method.rb
74
82
  - lib/rubocop/cop/mixin/target_rails_version.rb
75
83
  - lib/rubocop/cop/rails/action_filter.rb
@@ -77,11 +85,14 @@ files:
77
85
  - lib/rubocop/cop/rails/active_record_callbacks_order.rb
78
86
  - lib/rubocop/cop/rails/active_record_override.rb
79
87
  - lib/rubocop/cop/rails/active_support_aliases.rb
88
+ - lib/rubocop/cop/rails/after_commit_override.rb
80
89
  - lib/rubocop/cop/rails/application_controller.rb
81
90
  - lib/rubocop/cop/rails/application_job.rb
82
91
  - lib/rubocop/cop/rails/application_mailer.rb
83
92
  - lib/rubocop/cop/rails/application_record.rb
93
+ - lib/rubocop/cop/rails/arel_star.rb
84
94
  - lib/rubocop/cop/rails/assert_not.rb
95
+ - lib/rubocop/cop/rails/attribute_default_block_value.rb
85
96
  - lib/rubocop/cop/rails/belongs_to.rb
86
97
  - lib/rubocop/cop/rails/blank.rb
87
98
  - lib/rubocop/cop/rails/bulk_change_table.rb
@@ -95,6 +106,7 @@ files:
95
106
  - lib/rubocop/cop/rails/enum_hash.rb
96
107
  - lib/rubocop/cop/rails/enum_uniqueness.rb
97
108
  - lib/rubocop/cop/rails/environment_comparison.rb
109
+ - lib/rubocop/cop/rails/environment_variable_access.rb
98
110
  - lib/rubocop/cop/rails/exit.rb
99
111
  - lib/rubocop/cop/rails/file_path.rb
100
112
  - lib/rubocop/cop/rails/find_by.rb
@@ -116,6 +128,7 @@ files:
116
128
  - lib/rubocop/cop/rails/match_route.rb
117
129
  - lib/rubocop/cop/rails/negate_include.rb
118
130
  - lib/rubocop/cop/rails/not_null_column.rb
131
+ - lib/rubocop/cop/rails/order_by_id.rb
119
132
  - lib/rubocop/cop/rails/output.rb
120
133
  - lib/rubocop/cop/rails/output_safety.rb
121
134
  - lib/rubocop/cop/rails/pick.rb
@@ -136,35 +149,41 @@ files:
136
149
  - lib/rubocop/cop/rails/render_inline.rb
137
150
  - lib/rubocop/cop/rails/render_plain_text.rb
138
151
  - lib/rubocop/cop/rails/request_referer.rb
152
+ - lib/rubocop/cop/rails/require_dependency.rb
139
153
  - lib/rubocop/cop/rails/reversible_migration.rb
154
+ - lib/rubocop/cop/rails/reversible_migration_method_definition.rb
140
155
  - lib/rubocop/cop/rails/safe_navigation.rb
141
156
  - lib/rubocop/cop/rails/safe_navigation_with_blank.rb
142
157
  - lib/rubocop/cop/rails/save_bang.rb
143
158
  - lib/rubocop/cop/rails/scope_args.rb
144
159
  - lib/rubocop/cop/rails/short_i18n.rb
145
160
  - lib/rubocop/cop/rails/skips_model_validations.rb
161
+ - lib/rubocop/cop/rails/squished_sql_heredocs.rb
146
162
  - lib/rubocop/cop/rails/time_zone.rb
163
+ - lib/rubocop/cop/rails/time_zone_assignment.rb
147
164
  - lib/rubocop/cop/rails/uniq_before_pluck.rb
148
165
  - lib/rubocop/cop/rails/unique_validation_without_index.rb
149
166
  - lib/rubocop/cop/rails/unknown_env.rb
150
167
  - lib/rubocop/cop/rails/validation.rb
168
+ - lib/rubocop/cop/rails/where_equals.rb
151
169
  - lib/rubocop/cop/rails/where_exists.rb
170
+ - lib/rubocop/cop/rails/where_not.rb
152
171
  - lib/rubocop/cop/rails_cops.rb
153
172
  - lib/rubocop/rails.rb
154
173
  - lib/rubocop/rails/inject.rb
155
174
  - lib/rubocop/rails/schema_loader.rb
156
175
  - lib/rubocop/rails/schema_loader/schema.rb
157
176
  - lib/rubocop/rails/version.rb
158
- homepage: https://github.com/rubocop-hq/rubocop-rails
177
+ homepage: https://github.com/rubocop/rubocop-rails
159
178
  licenses:
160
179
  - MIT
161
180
  metadata:
162
181
  homepage_uri: https://docs.rubocop.org/rubocop-rails/
163
- changelog_uri: https://github.com/rubocop-hq/rubocop-rails/blob/master/CHANGELOG.md
164
- source_code_uri: https://github.com/rubocop-hq/rubocop-rails/
165
- documentation_uri: https://docs.rubocop.org/rubocop-rails/
166
- bug_tracker_uri: https://github.com/rubocop-hq/rubocop-rails/issues
167
- post_install_message:
182
+ changelog_uri: https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md
183
+ source_code_uri: https://github.com/rubocop/rubocop-rails/
184
+ documentation_uri: https://docs.rubocop.org/rubocop-rails/2.10/
185
+ bug_tracker_uri: https://github.com/rubocop/rubocop-rails/issues
186
+ post_install_message:
168
187
  rdoc_options: []
169
188
  require_paths:
170
189
  - lib
@@ -172,15 +191,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
191
  requirements:
173
192
  - - ">="
174
193
  - !ruby/object:Gem::Version
175
- version: 2.4.0
194
+ version: 2.5.0
176
195
  required_rubygems_version: !ruby/object:Gem::Requirement
177
196
  requirements:
178
197
  - - ">="
179
198
  - !ruby/object:Gem::Version
180
199
  version: '0'
181
200
  requirements: []
182
- rubygems_version: 3.1.4
183
- signing_key:
201
+ rubygems_version: 3.2.16
202
+ signing_key:
184
203
  specification_version: 4
185
204
  summary: Automatic Rails code style checking tool.
186
205
  test_files: []