rubocop-rails 2.8.0 → 2.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/cop/mixin/active_record_helper.rb +1 -0
- data/lib/rubocop/cop/rails/after_commit_override.rb +8 -1
- data/lib/rubocop/cop/rails/dynamic_find_by.rb +1 -0
- data/lib/rubocop/cop/rails/http_positional_arguments.rb +6 -0
- 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/reversible_migration.rb +1 -1
- data/lib/rubocop/cop/rails/unique_validation_without_index.rb +2 -0
- data/lib/rubocop/cop/rails/where_not.rb +4 -2
- data/lib/rubocop/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49338e1944d78e63ec06fc37e16cbe3010f68f94d99ad24d5353be0c156bf8cb
|
4
|
+
data.tar.gz: 90823cd3bac084df9ac449fb6b0cb07a570721d2449c755432f022fb7c558e54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c242d3a6cdea9df1e4e7d9000e55db30d68dfd21317a286ad097c34a52e6cbd53a8fc6442a3333a312373adf8d7bfd05b562cf9a7391a752a7dccdc357a1b87e
|
7
|
+
data.tar.gz: fafe45955b9f0b50e403f37bdb499cdb78c6883f9472faba784e4e6e64a0fa661902d1700d38bd3a1d8c8a1c1cfc7ff2751e01cd37174cdda9025e9ef4195c43
|
@@ -52,6 +52,7 @@ module RuboCop
|
|
52
52
|
# @param table [RuboCop::Rails::SchemaLoader::Table]
|
53
53
|
# @return [String, nil]
|
54
54
|
def resolve_relation_into_column(name:, class_node:, table:)
|
55
|
+
return unless table
|
55
56
|
return name if table.with_column?(name: name)
|
56
57
|
|
57
58
|
find_belongs_to(class_node) do |belongs_to|
|
@@ -59,7 +59,7 @@ module RuboCop
|
|
59
59
|
|
60
60
|
def each_after_commit_callback(class_node)
|
61
61
|
class_send_nodes(class_node).each do |node|
|
62
|
-
yield node if after_commit_callback?(node)
|
62
|
+
yield node if after_commit_callback?(node) && named_callback?(node)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -78,6 +78,13 @@ module RuboCop
|
|
78
78
|
def after_commit_callback?(node)
|
79
79
|
AFTER_COMMIT_CALLBACKS.include?(node.method_name)
|
80
80
|
end
|
81
|
+
|
82
|
+
def named_callback?(node)
|
83
|
+
name = node.first_argument
|
84
|
+
return false unless name
|
85
|
+
|
86
|
+
name.sym_type?
|
87
|
+
end
|
81
88
|
end
|
82
89
|
end
|
83
90
|
end
|
@@ -16,6 +16,7 @@ module RuboCop
|
|
16
16
|
#
|
17
17
|
# # good
|
18
18
|
# get :new, params: { user_id: 1 }
|
19
|
+
# get :new, **options
|
19
20
|
class HttpPositionalArguments < Cop
|
20
21
|
extend TargetRailsVersion
|
21
22
|
|
@@ -32,6 +33,10 @@ module RuboCop
|
|
32
33
|
(send nil? {#{HTTP_METHODS.map(&:inspect).join(' ')}} !nil? $_ ...)
|
33
34
|
PATTERN
|
34
35
|
|
36
|
+
def_node_matcher :kwsplat_hash?, <<~PATTERN
|
37
|
+
(hash (kwsplat _))
|
38
|
+
PATTERN
|
39
|
+
|
35
40
|
def on_send(node)
|
36
41
|
http_request?(node) do |data|
|
37
42
|
return unless needs_conversion?(data)
|
@@ -61,6 +66,7 @@ module RuboCop
|
|
61
66
|
|
62
67
|
def needs_conversion?(data)
|
63
68
|
return true unless data.hash_type?
|
69
|
+
return false if kwsplat_hash?(data)
|
64
70
|
|
65
71
|
data.each_pair.none? do |pair|
|
66
72
|
special_keyword_arg?(pair.key) ||
|
@@ -24,7 +24,7 @@ module RuboCop
|
|
24
24
|
(block
|
25
25
|
({send csend} _ :each_with_object (hash))
|
26
26
|
(args (arg $_el) (arg _memo))
|
27
|
-
({send csend} (lvar _memo) :[]=
|
27
|
+
({send csend} (lvar _memo) :[]= $!`_memo (lvar _el)))
|
28
28
|
PATTERN
|
29
29
|
|
30
30
|
def_node_matcher :on_bad_to_h, <<~PATTERN
|
@@ -27,7 +27,7 @@ module RuboCop
|
|
27
27
|
(block
|
28
28
|
({send csend} _ :each_with_object (hash))
|
29
29
|
(args (arg $_el) (arg _memo))
|
30
|
-
({send csend} (lvar _memo) :[]= (lvar _el)
|
30
|
+
({send csend} (lvar _memo) :[]= (lvar _el) $!`_memo))
|
31
31
|
PATTERN
|
32
32
|
|
33
33
|
def_node_matcher :on_bad_to_h, <<~PATTERN
|
@@ -10,6 +10,8 @@ module RuboCop
|
|
10
10
|
# # bad
|
11
11
|
# User.where('name != ?', 'Gabe')
|
12
12
|
# User.where('name != :name', name: 'Gabe')
|
13
|
+
# User.where('name <> ?', 'Gabe')
|
14
|
+
# User.where('name <> :name', name: 'Gabe')
|
13
15
|
# User.where('name IS NOT NULL')
|
14
16
|
# User.where('name NOT IN (?)', ['john', 'jane'])
|
15
17
|
# User.where('name NOT IN (:names)', names: ['john', 'jane'])
|
@@ -62,9 +64,9 @@ module RuboCop
|
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
|
-
NOT_EQ_ANONYMOUS_RE = /\A([\w.]+)\s
|
67
|
+
NOT_EQ_ANONYMOUS_RE = /\A([\w.]+)\s+(?:!=|<>)\s+\?\z/.freeze # column != ?, column <> ?
|
66
68
|
NOT_IN_ANONYMOUS_RE = /\A([\w.]+)\s+NOT\s+IN\s+\(\?\)\z/i.freeze # column NOT IN (?)
|
67
|
-
NOT_EQ_NAMED_RE = /\A([\w.]+)\s
|
69
|
+
NOT_EQ_NAMED_RE = /\A([\w.]+)\s+(?:!=|<>)\s+:(\w+)\z/.freeze # column != :column, column <> :column
|
68
70
|
NOT_IN_NAMED_RE = /\A([\w.]+)\s+NOT\s+IN\s+\(:(\w+)\)\z/i.freeze # column NOT IN (:column)
|
69
71
|
IS_NOT_NULL_RE = /\A([\w.]+)\s+IS\s+NOT\s+NULL\z/i.freeze # column IS NOT NULL
|
70
72
|
|
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.8.
|
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-09-
|
13
|
+
date: 2020-09-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|