leftovers 0.10.0 → 0.11.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2cb691dc74d8b0d43765f899ea718a4d06c1ba8fa36ea3a68c44ece27531920
4
- data.tar.gz: e24ade3f01a888de2e9438736d71b0e4f2d159a6783b3278e8ec7e58e7c8c626
3
+ metadata.gz: 16d46e25de2c0e4f243f396b910e3eb61e6342dd626fcceb9f30bd3734196d7b
4
+ data.tar.gz: e8c6c55c70e25167126fa2fa5ac3037f41a37b9ae8415f10b86cfea183436be1
5
5
  SHA512:
6
- metadata.gz: a734ec1916762c5bc51fc212bfc254eb3d4083c968e6bcd128aa0c10ee9085762c6edbd86eb8afd3dd17ac5fa8b883d343bf34df3a3caaea1b84db5bc720bfaa
7
- data.tar.gz: 7b80b90518a6a3e45aa3739394c18f4c7884ea07d75021dc919c62d23d6d110714c9969ab78b8078d6c219bfd9289a821bb4b828bc4e248a82a63f235cb7758f
6
+ metadata.gz: 609975369757068764cc179848f973aa6579dcf422a36ad54a7e7697cb257b1ec1043c3da8b106741869d1a0f113e4aa95bf824c7dca1c9766b05db90cddb7a8
7
+ data.tar.gz: c74f1643e44ad2f87490f8f2745c35286f746881bcac839c43bc0400863c0733a5246c5cf4d4b5be88d1501512aa6fb35debc637404262ee0902766e28a87b86
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # v0.11.0
2
+ - Fixed an issue with active_record's `before_save` with multiple callbacks #18, #17 - thanks @palexvs for raising the issue and creating a pr
3
+ - Due to this pr, i reviewed everything else that i think calls `ActiveSupport::Callbacks.set_callback`, and ensured they all:
4
+ - can have multiple args if relevant
5
+ - accept single values and array values for the if/unless args
6
+ - don't eval strings, that's not been a rails feature for a while
7
+ - Fix active_model & active_record validation methods to more comprehensively handle all the keys that could be given symbols of method names, instead of only the documented ones
8
+
1
9
  # v0.10.0
2
10
  - Fixed an issue with t.belongs_to (within the migration generated by rails active_storage:install - thanks @veganstraightedge)
3
11
  - this was two issues:
@@ -15,7 +15,10 @@ keep:
15
15
  dynamic:
16
16
  # https://api.rubyonrails.org/v7.0.2.2/classes/ActionMailbox/Base.html
17
17
  - names: [before_processing, after_processing, around_processing]
18
- calls: ['*', if, unless]
18
+ calls:
19
+ - arguments: '*'
20
+ - arguments: [if, unless]
21
+ nested: '*'
19
22
 
20
23
  # https://guides.rubyonrails.org/action_mailbox_basics.html#examples
21
24
  # i'm guessing a lot about how this is supposed to work
@@ -26,7 +26,10 @@ dynamic:
26
26
  - before_action
27
27
  - after_action
28
28
  - around_action
29
- calls: ['*', if, unless]
29
+ calls:
30
+ - arguments: '*'
31
+ - arguments: [if, unless]
32
+ nested: '*'
30
33
 
31
34
  # https://guides.rubyonrails.org/action_mailer_basics.html#intercepting-emails
32
35
  - names: interceptors=
@@ -37,21 +37,29 @@ dynamic:
37
37
  - prepend_around_action
38
38
  - prepend_before_action
39
39
  calls:
40
- - arguments: ['*', if, unless]
40
+ - arguments: '*'
41
+ - arguments: [if, unless]
42
+ nested: '*'
41
43
 
42
44
  - names:
43
45
  - skip_after_action
44
46
  - skip_around_action
45
47
  - skip_before_action
46
- calls: [if, unless]
48
+ calls:
49
+ arguments: [if, unless]
50
+ nested: '*'
47
51
 
48
52
  - names: protect_from_forgery
49
- calls: [if, unless]
53
+ calls:
54
+ arguments: [if, unless]
55
+ nested: '*'
50
56
 
51
57
 
52
58
  # https://edgeapi.rubyonrails.org/classes/ActionController/Logging/ClassMethods.html#method-i-log_at
53
59
  - names: log_at
54
- calls: [if, unless]
60
+ calls:
61
+ arguments: [if, unless]
62
+ nested: '*'
55
63
 
56
64
 
57
65
  - name: helper
@@ -23,10 +23,9 @@ dynamic:
23
23
  - around_perform
24
24
  - after_perform
25
25
  calls:
26
- - arguments: 0
26
+ - arguments: '*'
27
27
  - arguments: [if, unless]
28
- nested:
29
- arguments: '*'
28
+ nested: '*'
30
29
 
31
30
  # https://api.rubyonrails.org/v7.0.2.2/classes/ActiveJob/Exceptions/ClassMethods.html#method-i-discard_on
32
31
  # https://api.rubyonrails.org/v7.0.2.2/classes/ActiveJob/Exceptions/ClassMethods.html#method-i-retry_on
@@ -82,25 +82,26 @@ dynamic:
82
82
  - before_validation
83
83
  - after_validation
84
84
  calls:
85
- - arguments: 0
85
+ - arguments: '*'
86
86
  - arguments: [if, unless]
87
- nested:
88
- arguments: '*'
87
+ nested: '*'
89
88
  - name:
90
89
  - validates_associated
91
90
  calls:
92
- - arguments: ['*', if, unless]
91
+ - arguments: '*'
92
+ - arguments: [if, unless]
93
+ nested: '*'
94
+
93
95
  # https://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validates
94
96
  - name: [validates, validates!]
95
97
  calls:
96
98
  - arguments:
97
99
  - '*'
100
+ - 'in'
98
101
  - within
99
- - inclusion
100
- - exclusion
101
102
  - scope
102
- - if
103
- - unless
103
+ - with
104
+ - without
104
105
  - arguments: [if, unless]
105
106
  nested: '*'
106
107
  - arguments: [inclusion, exclusion]
@@ -108,6 +109,17 @@ dynamic:
108
109
  arguments:
109
110
  - 'in'
110
111
  - within
112
+ - arguments: format
113
+ nested:
114
+ arguments:
115
+ - with
116
+ - without
117
+ - arguments: length
118
+ nested:
119
+ arguments:
120
+ - is
121
+ - minimum
122
+ - maximum
111
123
  - arguments: [comparison, numericality]
112
124
  nested:
113
125
  arguments:
@@ -118,14 +130,10 @@ dynamic:
118
130
  - less_than_or_equal_to
119
131
  - other_than
120
132
  - keywords:
121
- unless: [if, unless]
133
+ unless: [if, unless, 'on', allow_blank, allow_nil, strict]
122
134
  camelize: true
123
135
  add_suffix: Validator
124
136
  split: '::'
125
- eval:
126
- - arguments: [if, unless]
127
- - arguments: [if, unless]
128
- nested: '*'
129
137
 
130
138
  - name: validates_confirmation_of
131
139
  calls:
@@ -139,10 +147,9 @@ dynamic:
139
147
  argument: '*'
140
148
  add_suffix: _confirmation
141
149
 
142
- - name: validates_comparison_of
150
+ - name: [validates_comparison_of, validates_numericality_of]
143
151
  calls:
144
152
  argument:
145
- - '*'
146
153
  - greater_than
147
154
  - greater_than_or_equal_to
148
155
  - equal_to
@@ -150,13 +157,24 @@ dynamic:
150
157
  - less_than_or_equal_to
151
158
  - other_than
152
159
 
160
+ # why!?
161
+ - name: validates_numericality_of
162
+ calls:
163
+ argument:
164
+ - only_integer
165
+
153
166
  - name: [validates_exclusion_of, validates_inclusion_of]
154
167
  calls:
155
168
  argument:
156
- - '*'
157
169
  - 'in'
158
170
  - within
159
171
 
172
+ - name: validates_length_of
173
+ calls: [is, minimum, maximum]
174
+
175
+ - name: validates_format_of
176
+ calls: [with, without]
177
+
160
178
  - name:
161
179
  - validates_absence_of
162
180
  - validates_acceptance_of
@@ -170,9 +188,7 @@ dynamic:
170
188
  - validates_presence_of
171
189
  - validates_size_of
172
190
  calls:
173
- - arguments: ['*', if, unless]
174
- eval:
175
- - arguments: [if, unless]
191
+ - arguments: '*'
176
192
  - arguments: [if, unless]
177
193
  nested: '*'
178
194
 
@@ -183,9 +199,7 @@ dynamic:
183
199
  - validate_associated
184
200
  - validates_each
185
201
  calls:
186
- - arguments: ['*', if, unless]
187
- eval:
188
- - arguments: [if, unless]
202
+ - arguments: '*'
189
203
  - arguments: [if, unless]
190
204
  nested: '*'
191
205
 
@@ -193,10 +207,7 @@ dynamic:
193
207
  - name: validates_with
194
208
  calls:
195
209
  arguments: [if, unless]
196
- eval:
197
- - arguments: [if, unless]
198
- - arguments: [if, unless]
199
- nested: '*'
210
+ nested: '*'
200
211
 
201
212
  # https://api.rubyonrails.org/classes/ActiveModel/AttributeMethods/ClassMethods.html#method-i-alias_attribute
202
213
  # https://api.rubyonrails.org/classes/ActiveModel/Dirty.html
@@ -22,7 +22,23 @@ dynamic:
22
22
  - validates_numericality_of
23
23
  - validates_presence_of
24
24
  - validates_uniqueness_of
25
- calls: ['*', if, unless]
25
+ calls:
26
+ - arguments: '*'
27
+ - arguments: [if, unless]
28
+ nested: '*'
29
+
30
+ - name: validates_uniqueness_of
31
+ calls:
32
+ arguments: scope
33
+ nested: '*'
34
+
35
+ - name: [validates, validates!]
36
+ calls:
37
+ - arguments: scope
38
+ - arguments: uniqueness
39
+ nested:
40
+ arguments: scope
41
+ nested: '*'
26
42
 
27
43
  # https://edgeapi.rubyonrails.org/classes/ActiveRecord/Aggregations/ClassMethods.html
28
44
  # i had to read the code for this
@@ -367,10 +383,9 @@ dynamic:
367
383
  - before_save
368
384
  - before_update
369
385
  calls:
370
- - arguments: 0
386
+ - arguments: '*'
371
387
  - arguments: [if, unless]
372
- nested:
373
- arguments: '*'
388
+ nested: '*'
374
389
 
375
390
  - name:
376
391
  - includes
@@ -146,8 +146,12 @@ dynamic:
146
146
 
147
147
  # https://api.rubyonrails.org/classes/ActiveSupport/Callbacks/ClassMethods.html#method-i-set_callback
148
148
  - name: set_callback
149
- calls: [2, if, unless]
149
+ calls:
150
+ - arguments: '2+'
151
+ - arguments: [if, unless]
152
+ nested: '*'
150
153
 
154
+ # The second argument indicates whether the callback is to be run :before, :after, or :around the event. If omitted, :before is assumed.
151
155
  - name: set_callback
152
156
  calls: 1
153
157
  unless:
@@ -156,7 +160,9 @@ dynamic:
156
160
 
157
161
  # https://api.rubyonrails.org/classes/ActiveSupport/Callbacks/ClassMethods.html#method-i-skip_callback
158
162
  - name: skip_callback
159
- calls: [if, unless]
163
+ calls:
164
+ arguments: [if, unless]
165
+ nested: '*'
160
166
 
161
167
  # https://api.rubyonrails.org/classes/ActiveSupport/Configurable/ClassMethods.html#method-i-config_accessor
162
168
  - name: config_accessor
@@ -203,7 +209,11 @@ dynamic:
203
209
  # https://api.rubyonrails.org/classes/ActiveSupport/Reloader.html#method-c-to_prepare
204
210
  # this is not well documented but uses set_callback internally so we can just guess
205
211
  - name: [before_class_unload, after_class_unload, to_prepare]
206
- calls: [0, if, unless]
212
+ calls:
213
+ - arguments: '*'
214
+ - arguments: [if, unless]
215
+ nested:
216
+ arguments: '*'
207
217
 
208
218
  # https://api.rubyonrails.org/classes/Module/Concerning.html#method-i-concern
209
219
  - name: concern
@@ -35,8 +35,8 @@ module Leftovers
35
35
  end
36
36
 
37
37
  def print_definition(definition)
38
- puts "#{aqua definition.location_s} "\
39
- "#{definition} "\
38
+ puts "#{aqua definition.location_s} " \
39
+ "#{definition} " \
40
40
  "#{grey definition.highlighted_source("\e[33m", "\e[0;2m")}"
41
41
  end
42
42
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leftovers
4
- VERSION = '0.10.0'
4
+ VERSION = '0.11.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leftovers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Sherson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-02 00:00:00.000000000 Z
11
+ date: 2022-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -588,8 +588,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
588
588
  - !ruby/object:Gem::Version
589
589
  version: '0'
590
590
  requirements: []
591
- rubyforge_project:
592
- rubygems_version: 2.7.6
591
+ rubygems_version: 3.2.15
593
592
  signing_key:
594
593
  specification_version: 4
595
594
  summary: Find unused methods and classes/modules