rubocop-rails 2.20.0 → 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: 22c95e775f271cb0f160d1e57cb8582ce3f57cabef1afd860c88a3d57fe6b248
4
- data.tar.gz: c9471d33b16523be2e193ac789bf98ad9cde3b299e496e42d26f6e15ff6b24fc
3
+ metadata.gz: 227ce5b698e456412c24917c5644b2a938531440ab8c64e2b5036d6f2857a548
4
+ data.tar.gz: 41c6157da73215cca0b5d56ffa254711c2f9f4f5399c8aa3d85ac7c719958b28
5
5
  SHA512:
6
- metadata.gz: a123680bab27b5926384dcc4a245bdbb96fd8112c8a152cde44ada0bedb732ab35765665a5db8630aaa559f072060e78eda1077e82899b0ffc1808851229825f
7
- data.tar.gz: be271e0fadfd44c7dfc7c6547e1793b40da9521eed8466d4ff8ee69de9eed41f681c03e3431faf24c121bc0b979fe3939b6c948ffdc172895e6808174f126691
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(node)
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(node)
94
- uniq = uniqueness_part(node)
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(uniq)
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.arguments.last
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
@@ -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.20.0'
7
+ STRING = '2.20.2'
8
8
 
9
9
  def self.document_version
10
10
  STRING.match('\d+\.\d+').to_s
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.20.0
4
+ version: 2.20.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: 2023-06-18 00:00:00.000000000 Z
13
+ date: 2023-06-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport