rubocop-rails 2.20.1 → 2.20.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 227ce5b698e456412c24917c5644b2a938531440ab8c64e2b5036d6f2857a548
|
4
|
+
data.tar.gz: 41c6157da73215cca0b5d56ffa254711c2f9f4f5399c8aa3d85ac7c719958b28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afafd2f9293f4592cc914fdb42c6742900681574d5d0a27dc2031eddb3446b419ac04a77a149e0169ab89a0bb7afe4e0481b3ff889631345a0227b0d24a2c185
|
7
|
+
data.tar.gz: a90108eed94c1cedbe1b9a059b60cae51465cffd5a8612f56a0548182b6f992e3e626125e4a4f2f74ceda491a91cdcacb0bd8206ebf94d7d245841572639b556
|
@@ -55,7 +55,7 @@ module RuboCop
|
|
55
55
|
|
56
56
|
ACCEPTED_METHODS = %i[in_time_zone utc getlocal xmlschema iso8601 jisx0301 rfc3339 httpdate to_i to_f].freeze
|
57
57
|
|
58
|
-
TIMEZONE_SPECIFIER = /([A-z]|[+-]\d{2}:?\d{2})\z/.freeze
|
58
|
+
TIMEZONE_SPECIFIER = /([A-Za-z]|[+-]\d{2}:?\d{2})\z/.freeze
|
59
59
|
|
60
60
|
def on_const(node)
|
61
61
|
mod, klass = *node
|
@@ -31,11 +31,11 @@ module RuboCop
|
|
31
31
|
RESTRICT_ON_SEND = %i[validates].freeze
|
32
32
|
|
33
33
|
def on_send(node)
|
34
|
-
return if uniqueness_part(node)&.falsey_literal?
|
35
|
-
return if condition_part?(node)
|
36
34
|
return unless schema
|
35
|
+
return unless (uniqueness_part = uniqueness_part(node))
|
36
|
+
return if uniqueness_part.falsey_literal? || condition_part?(node, uniqueness_part)
|
37
37
|
|
38
|
-
klass, table, names = find_schema_information(node)
|
38
|
+
klass, table, names = find_schema_information(node, uniqueness_part)
|
39
39
|
return unless names
|
40
40
|
return if with_index?(klass, table, names)
|
41
41
|
|
@@ -44,12 +44,12 @@ module RuboCop
|
|
44
44
|
|
45
45
|
private
|
46
46
|
|
47
|
-
def find_schema_information(node)
|
47
|
+
def find_schema_information(node, uniqueness_part)
|
48
48
|
klass = class_node(node)
|
49
49
|
return unless klass
|
50
50
|
|
51
51
|
table = schema.table_by(name: table_name(klass))
|
52
|
-
names = column_names(node)
|
52
|
+
names = column_names(node, uniqueness_part)
|
53
53
|
|
54
54
|
[klass, table, names]
|
55
55
|
end
|
@@ -71,12 +71,12 @@ module RuboCop
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
def column_names(node)
|
74
|
+
def column_names(node, uniqueness_part)
|
75
75
|
arg = node.first_argument
|
76
76
|
return unless arg.str_type? || arg.sym_type?
|
77
77
|
|
78
78
|
ret = [arg.value]
|
79
|
-
names_from_scope = column_names_from_scope(
|
79
|
+
names_from_scope = column_names_from_scope(uniqueness_part)
|
80
80
|
ret.concat(names_from_scope) if names_from_scope
|
81
81
|
|
82
82
|
ret = ret.flat_map do |name|
|
@@ -90,11 +90,10 @@ module RuboCop
|
|
90
90
|
ret.include?(nil) ? nil : ret.to_set
|
91
91
|
end
|
92
92
|
|
93
|
-
def column_names_from_scope(
|
94
|
-
|
95
|
-
return unless uniq.hash_type?
|
93
|
+
def column_names_from_scope(uniqueness_part)
|
94
|
+
return unless uniqueness_part.hash_type?
|
96
95
|
|
97
|
-
scope = find_scope(
|
96
|
+
scope = find_scope(uniqueness_part)
|
98
97
|
return unless scope
|
99
98
|
|
100
99
|
scope = unfreeze_scope(scope)
|
@@ -135,14 +134,11 @@ module RuboCop
|
|
135
134
|
end
|
136
135
|
end
|
137
136
|
|
138
|
-
def condition_part?(node)
|
139
|
-
pairs = node.
|
140
|
-
return unless pairs.hash_type?
|
141
|
-
|
137
|
+
def condition_part?(node, uniqueness_node)
|
138
|
+
pairs = node.last_argument
|
139
|
+
return false unless pairs.hash_type?
|
142
140
|
return true if condition_hash_part?(pairs, keys: %i[if unless])
|
143
|
-
|
144
|
-
uniqueness_node = uniqueness_part(node)
|
145
|
-
return unless uniqueness_node&.hash_type?
|
141
|
+
return false unless uniqueness_node.hash_type?
|
146
142
|
|
147
143
|
condition_hash_part?(uniqueness_node, keys: %i[if unless conditions])
|
148
144
|
end
|