rubocop-rails 2.23.1 → 2.26.2
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 +4 -4
- data/README.md +16 -2
- data/config/default.yml +32 -7
- data/lib/rubocop/cop/mixin/active_record_helper.rb +6 -1
- data/lib/rubocop/cop/mixin/target_rails_version.rb +29 -2
- data/lib/rubocop/cop/rails/action_controller_flash_before_render.rb +2 -0
- data/lib/rubocop/cop/rails/action_order.rb +1 -5
- data/lib/rubocop/cop/rails/active_record_callbacks_order.rb +1 -5
- data/lib/rubocop/cop/rails/active_support_on_load.rb +21 -1
- data/lib/rubocop/cop/rails/application_record.rb +4 -0
- data/lib/rubocop/cop/rails/bulk_change_table.rb +10 -4
- data/lib/rubocop/cop/rails/compact_blank.rb +29 -8
- data/lib/rubocop/cop/rails/dangerous_column_names.rb +1 -2
- data/lib/rubocop/cop/rails/date.rb +2 -2
- data/lib/rubocop/cop/rails/enum_hash.rb +31 -8
- data/lib/rubocop/cop/rails/enum_syntax.rb +128 -0
- data/lib/rubocop/cop/rails/enum_uniqueness.rb +29 -7
- data/lib/rubocop/cop/rails/expanded_date_range.rb +1 -1
- data/lib/rubocop/cop/rails/file_path.rb +1 -1
- data/lib/rubocop/cop/rails/find_by.rb +1 -1
- data/lib/rubocop/cop/rails/http_status.rb +12 -2
- data/lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb +1 -1
- data/lib/rubocop/cop/rails/link_to_blank.rb +2 -2
- data/lib/rubocop/cop/rails/not_null_column.rb +93 -13
- data/lib/rubocop/cop/rails/pick.rb +4 -0
- data/lib/rubocop/cop/rails/pluck_in_where.rb +17 -8
- data/lib/rubocop/cop/rails/pluralization_grammar.rb +29 -15
- data/lib/rubocop/cop/rails/present.rb +0 -2
- data/lib/rubocop/cop/rails/redundant_active_record_all_method.rb +0 -29
- data/lib/rubocop/cop/rails/redundant_foreign_key.rb +1 -1
- data/lib/rubocop/cop/rails/redundant_presence_validation_on_belongs_to.rb +9 -0
- data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +1 -1
- data/lib/rubocop/cop/rails/reflection_class_name.rb +1 -1
- data/lib/rubocop/cop/rails/render_plain_text.rb +6 -3
- data/lib/rubocop/cop/rails/request_referer.rb +1 -1
- data/lib/rubocop/cop/rails/reversible_migration.rb +1 -1
- data/lib/rubocop/cop/rails/root_pathname_methods.rb +15 -11
- data/lib/rubocop/cop/rails/save_bang.rb +2 -0
- data/lib/rubocop/cop/rails/skips_model_validations.rb +8 -3
- data/lib/rubocop/cop/rails/time_zone.rb +2 -1
- data/lib/rubocop/cop/rails/uniq_before_pluck.rb +12 -4
- data/lib/rubocop/cop/rails/unknown_env.rb +1 -1
- data/lib/rubocop/cop/rails/unused_ignored_columns.rb +6 -0
- data/lib/rubocop/cop/rails/validation.rb +8 -3
- data/lib/rubocop/cop/rails/where_equals.rb +28 -12
- data/lib/rubocop/cop/rails/where_exists.rb +3 -3
- data/lib/rubocop/cop/rails/where_missing.rb +5 -1
- data/lib/rubocop/cop/rails/where_not.rb +11 -6
- data/lib/rubocop/cop/rails/where_range.rb +203 -0
- data/lib/rubocop/cop/rails_cops.rb +2 -0
- data/lib/rubocop/rails/schema_loader/schema.rb +2 -1
- data/lib/rubocop/rails/schema_loader.rb +5 -15
- data/lib/rubocop/rails/version.rb +1 -1
- metadata +10 -8
|
@@ -46,6 +46,7 @@ require_relative 'rails/duration_arithmetic'
|
|
|
46
46
|
require_relative 'rails/dynamic_find_by'
|
|
47
47
|
require_relative 'rails/eager_evaluation_log_message'
|
|
48
48
|
require_relative 'rails/enum_hash'
|
|
49
|
+
require_relative 'rails/enum_syntax'
|
|
49
50
|
require_relative 'rails/enum_uniqueness'
|
|
50
51
|
require_relative 'rails/env_local'
|
|
51
52
|
require_relative 'rails/environment_comparison'
|
|
@@ -138,3 +139,4 @@ require_relative 'rails/where_exists'
|
|
|
138
139
|
require_relative 'rails/where_missing'
|
|
139
140
|
require_relative 'rails/where_not'
|
|
140
141
|
require_relative 'rails/where_not_with_multiple_conditions'
|
|
142
|
+
require_relative 'rails/where_range'
|
|
@@ -30,6 +30,7 @@ module RuboCop
|
|
|
30
30
|
|
|
31
31
|
def build!(ast)
|
|
32
32
|
raise "Unexpected type: #{ast.type}" unless ast.block_type?
|
|
33
|
+
return unless ast.body
|
|
33
34
|
|
|
34
35
|
each_table(ast) do |table_def|
|
|
35
36
|
next unless table_def.method?(:create_table)
|
|
@@ -177,7 +178,7 @@ module RuboCop
|
|
|
177
178
|
attr_reader :table_name
|
|
178
179
|
|
|
179
180
|
def initialize(node)
|
|
180
|
-
super
|
|
181
|
+
super
|
|
181
182
|
|
|
182
183
|
@table_name = node.first_argument.value
|
|
183
184
|
@columns, @expression = build_columns_or_expr(node.arguments[1])
|
|
@@ -12,10 +12,10 @@ module RuboCop
|
|
|
12
12
|
# So a cop that uses the loader should handle `nil` properly.
|
|
13
13
|
#
|
|
14
14
|
# @return [Schema, nil]
|
|
15
|
-
def load(target_ruby_version)
|
|
15
|
+
def load(target_ruby_version, parser_engine)
|
|
16
16
|
return @load if defined?(@load)
|
|
17
17
|
|
|
18
|
-
@load = load!(target_ruby_version)
|
|
18
|
+
@load = load!(target_ruby_version, parser_engine)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def reset!
|
|
@@ -38,23 +38,13 @@ module RuboCop
|
|
|
38
38
|
|
|
39
39
|
private
|
|
40
40
|
|
|
41
|
-
def load!(target_ruby_version)
|
|
41
|
+
def load!(target_ruby_version, parser_engine)
|
|
42
42
|
path = db_schema_path
|
|
43
43
|
return unless path
|
|
44
44
|
|
|
45
|
-
ast =
|
|
46
|
-
Schema.new(ast) if ast
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def parse(path, target_ruby_version)
|
|
50
|
-
klass_name = :"Ruby#{target_ruby_version.to_s.sub('.', '')}"
|
|
51
|
-
klass = ::Parser.const_get(klass_name)
|
|
52
|
-
parser = klass.new(RuboCop::AST::Builder.new)
|
|
45
|
+
ast = RuboCop::ProcessedSource.new(File.read(path), target_ruby_version, path, parser_engine: parser_engine).ast
|
|
53
46
|
|
|
54
|
-
|
|
55
|
-
buffer.source = path.read
|
|
56
|
-
|
|
57
|
-
parser.parse(buffer)
|
|
47
|
+
Schema.new(ast) if ast
|
|
58
48
|
end
|
|
59
49
|
end
|
|
60
50
|
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.
|
|
4
|
+
version: 2.26.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:
|
|
13
|
+
date: 2024-09-21 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activesupport
|
|
@@ -46,7 +46,7 @@ dependencies:
|
|
|
46
46
|
requirements:
|
|
47
47
|
- - ">="
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
|
-
version: 1.
|
|
49
|
+
version: 1.52.0
|
|
50
50
|
- - "<"
|
|
51
51
|
- !ruby/object:Gem::Version
|
|
52
52
|
version: '2.0'
|
|
@@ -56,7 +56,7 @@ dependencies:
|
|
|
56
56
|
requirements:
|
|
57
57
|
- - ">="
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: 1.
|
|
59
|
+
version: 1.52.0
|
|
60
60
|
- - "<"
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
62
|
version: '2.0'
|
|
@@ -66,7 +66,7 @@ dependencies:
|
|
|
66
66
|
requirements:
|
|
67
67
|
- - ">="
|
|
68
68
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: 1.
|
|
69
|
+
version: 1.31.1
|
|
70
70
|
- - "<"
|
|
71
71
|
- !ruby/object:Gem::Version
|
|
72
72
|
version: '2.0'
|
|
@@ -76,7 +76,7 @@ dependencies:
|
|
|
76
76
|
requirements:
|
|
77
77
|
- - ">="
|
|
78
78
|
- !ruby/object:Gem::Version
|
|
79
|
-
version: 1.
|
|
79
|
+
version: 1.31.1
|
|
80
80
|
- - "<"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '2.0'
|
|
@@ -140,6 +140,7 @@ files:
|
|
|
140
140
|
- lib/rubocop/cop/rails/dynamic_find_by.rb
|
|
141
141
|
- lib/rubocop/cop/rails/eager_evaluation_log_message.rb
|
|
142
142
|
- lib/rubocop/cop/rails/enum_hash.rb
|
|
143
|
+
- lib/rubocop/cop/rails/enum_syntax.rb
|
|
143
144
|
- lib/rubocop/cop/rails/enum_uniqueness.rb
|
|
144
145
|
- lib/rubocop/cop/rails/env_local.rb
|
|
145
146
|
- lib/rubocop/cop/rails/environment_comparison.rb
|
|
@@ -232,6 +233,7 @@ files:
|
|
|
232
233
|
- lib/rubocop/cop/rails/where_missing.rb
|
|
233
234
|
- lib/rubocop/cop/rails/where_not.rb
|
|
234
235
|
- lib/rubocop/cop/rails/where_not_with_multiple_conditions.rb
|
|
236
|
+
- lib/rubocop/cop/rails/where_range.rb
|
|
235
237
|
- lib/rubocop/cop/rails_cops.rb
|
|
236
238
|
- lib/rubocop/rails.rb
|
|
237
239
|
- lib/rubocop/rails/inject.rb
|
|
@@ -245,7 +247,7 @@ metadata:
|
|
|
245
247
|
homepage_uri: https://docs.rubocop.org/rubocop-rails/
|
|
246
248
|
changelog_uri: https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md
|
|
247
249
|
source_code_uri: https://github.com/rubocop/rubocop-rails/
|
|
248
|
-
documentation_uri: https://docs.rubocop.org/rubocop-rails/2.
|
|
250
|
+
documentation_uri: https://docs.rubocop.org/rubocop-rails/2.26/
|
|
249
251
|
bug_tracker_uri: https://github.com/rubocop/rubocop-rails/issues
|
|
250
252
|
rubygems_mfa_required: 'true'
|
|
251
253
|
post_install_message:
|
|
@@ -263,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
263
265
|
- !ruby/object:Gem::Version
|
|
264
266
|
version: '0'
|
|
265
267
|
requirements: []
|
|
266
|
-
rubygems_version: 3.
|
|
268
|
+
rubygems_version: 3.5.16
|
|
267
269
|
signing_key:
|
|
268
270
|
specification_version: 4
|
|
269
271
|
summary: Automatic Rails code style checking tool.
|