leftovers 0.9.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/docs/Configuration.md +28 -6
- data/lib/config/actionmailbox.yml +4 -1
- data/lib/config/actionmailer.yml +4 -1
- data/lib/config/actionpack.yml +12 -4
- data/lib/config/activejob.yml +2 -3
- data/lib/config/activemodel.yml +37 -26
- data/lib/config/activerecord.yml +47 -10
- data/lib/config/activesupport.yml +13 -3
- data/lib/leftovers/config_loader/has_receiver_schema.rb +15 -0
- data/lib/leftovers/config_loader/has_value_schema.rb +1 -1
- data/lib/leftovers/config_loader/rule_pattern_schema.rb +1 -1
- data/lib/leftovers/config_loader/value_matcher_condition_schema.rb +1 -1
- data/lib/leftovers/config_loader.rb +1 -0
- data/lib/leftovers/definition_node.rb +8 -14
- data/lib/leftovers/file_collector/node_processor.rb +1 -0
- data/lib/leftovers/file_collector.rb +3 -2
- data/lib/leftovers/matcher_builders/node_has_receiver.rb +12 -3
- data/lib/leftovers/matcher_builders/node_value.rb +2 -0
- data/lib/leftovers/matchers/node_has_any_receiver.rb +13 -0
- data/lib/leftovers/matchers.rb +1 -0
- data/lib/leftovers/reporter.rb +2 -2
- data/lib/leftovers/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99d72b44b74c747074583f8c9254872a175563d0f25135b7798c5e76f42c19ef
|
4
|
+
data.tar.gz: 6b4bd9219256b8734df956978892da7ffe028e0539367a1f98d46c73912ae79e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d51c93c652bdd0aa55a176c1600e9d557fd29e7e9726411d7ac6eb086178a655e17e96e8d7530c97945f169d32961649358dd712daf9e50cb82b30caa1b55c10
|
7
|
+
data.tar.gz: b8ca04321b17c7d9c9b831f3fb2fab47554d859f910d38f08a04d41f344c4585a1008019af12d13b3e2807027fe6ba7d6fd6a4d1eca3fb947d68d6812249bc39
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
# v0.11.1
|
2
|
+
- Fixed an issue with parsing files that have `MyConstant ||= value` patterns #19 (thanks for the pr - @kamoh)
|
3
|
+
|
4
|
+
# v0.11.0
|
5
|
+
- Fixed an issue with active_record's `before_save` with multiple callbacks #18, #17 - thanks @palexvs for raising the issue and creating a pr
|
6
|
+
- Due to this pr, i reviewed everything else that i think calls `ActiveSupport::Callbacks.set_callback`, and ensured they all:
|
7
|
+
- can have multiple args if relevant
|
8
|
+
- accept single values and array values for the if/unless args
|
9
|
+
- don't eval strings, that's not been a rails feature for a while
|
10
|
+
- 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
|
11
|
+
|
12
|
+
# v0.10.0
|
13
|
+
- Fixed an issue with t.belongs_to (within the migration generated by rails active_storage:install - thanks @veganstraightedge)
|
14
|
+
- this was two issues:
|
15
|
+
1. it was raising an error because the DefinitionNode didn't act enough like an AST::Node, now it does
|
16
|
+
2. this should never have been defining anything anyway as the activerecord method was being assumed to be used, now if there's an explicit receiver for belongs_to/has_many etc, don't consider them the active record association methods.
|
17
|
+
|
18
|
+
- now `has_receiver: true` and `has_receiver: false/nil` act differently, they refer to the presence or absence of any receiver, instead of the receiver being literally true or false or nil.
|
19
|
+
- to have the previous behaviour, use the new `has_receiver: { literal: true }` or `literal: false` or `literal: null`
|
20
|
+
|
1
21
|
# v0.9.0
|
2
22
|
- Automatically test the config examples in the documentation, and fix the errors
|
3
23
|
- simplify the `type: Proc` matcher
|
data/docs/Configuration.md
CHANGED
@@ -504,7 +504,7 @@ and when used in:
|
|
504
504
|
|
505
505
|
It can have any of these properties:
|
506
506
|
- [`at:`](#at)
|
507
|
-
- [`has_value:`](#
|
507
|
+
- [`has_value:`](#has_value)
|
508
508
|
|
509
509
|
Arrays are not necessary for single values and if the rule contains only `at:` it can be omitted, and the values moved up a level.
|
510
510
|
|
@@ -522,7 +522,7 @@ The method call/constant variable/assignment will be considered matching if it h
|
|
522
522
|
|
523
523
|
It can have any of these properties:
|
524
524
|
- [`at:`](#at)
|
525
|
-
- [`has_value:`](#
|
525
|
+
- [`has_value:`](#has_value)
|
526
526
|
|
527
527
|
Arrays are not necessary for single values and if the rule contains only `at:` it can be omitted, and the values moved up a level
|
528
528
|
|
@@ -603,9 +603,9 @@ dynamic:
|
|
603
603
|
will match the first argument of anything named my_method or with the receiver MyReceiver, that have both the keyword arguments part_a and part_b
|
604
604
|
|
605
605
|
|
606
|
-
## `has_value
|
606
|
+
## `has_value:`
|
607
607
|
|
608
|
-
filter [`arguments:`](#arguments), [`has_arguments:`](#has_arguments), and [`keywords:`](#keywords), by the argument/assigned
|
608
|
+
filter [`arguments:`](#arguments), [`has_arguments:`](#has_arguments), and [`keywords:`](#keywords), by the argument/assigned value
|
609
609
|
|
610
610
|
Each entry can be one of
|
611
611
|
- `true`, `false`, `nil`, or an Integer. matches the literal value
|
@@ -616,11 +616,33 @@ Each entry can be one of
|
|
616
616
|
- [`matches:`](#matches)
|
617
617
|
- or have at least one of the following properties to match within an array or hash:
|
618
618
|
- [`at`](#at)
|
619
|
-
- [`has_value`](#
|
619
|
+
- [`has_value`](#has_value)
|
620
620
|
- or have the following property to match the value type
|
621
621
|
- [`type`](#type)
|
622
622
|
- or have the following property to match the receiver
|
623
|
-
- [`has_receiver`](#
|
623
|
+
- [`has_receiver`](#has_receiver)
|
624
|
+
|
625
|
+
## `has_receiver:`
|
626
|
+
|
627
|
+
filter [`dynamic:`](#dynamic), and [`keep:`](#keep), by the receiver presence or value
|
628
|
+
|
629
|
+
Each entry can be one of
|
630
|
+
- `true`, `false`, matches the presence of any receiver or not
|
631
|
+
- an Integer. matches the literal value
|
632
|
+
- a String. matches the literal string or symbol value
|
633
|
+
- or have at least one of the following properties to match the name:
|
634
|
+
- [`has_prefix:`](#has_prefix)
|
635
|
+
- [`has_suffix:`](#has_suffix)
|
636
|
+
- [`matches:`](#matches)
|
637
|
+
- or have at least one of the following properties to match the literal value or match within an array or hash:
|
638
|
+
- [`at`](#at)
|
639
|
+
- [`has_value`](#has_value)
|
640
|
+
- or have the following property to match the value type
|
641
|
+
- [`type`](#type)
|
642
|
+
- or have the following property to match the receiver of the receiver
|
643
|
+
- [`has_receiver`](#has_receiver)
|
644
|
+
- or have the following property to match a literal true, false, or nil value:
|
645
|
+
- `literal: true`, or `literal: false`, or `literal: nil`
|
624
646
|
|
625
647
|
## `privacy:`
|
626
648
|
|
@@ -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:
|
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
|
data/lib/config/actionmailer.yml
CHANGED
@@ -26,7 +26,10 @@ dynamic:
|
|
26
26
|
- before_action
|
27
27
|
- after_action
|
28
28
|
- around_action
|
29
|
-
calls:
|
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=
|
data/lib/config/actionpack.yml
CHANGED
@@ -37,21 +37,29 @@ dynamic:
|
|
37
37
|
- prepend_around_action
|
38
38
|
- prepend_before_action
|
39
39
|
calls:
|
40
|
-
- arguments:
|
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:
|
48
|
+
calls:
|
49
|
+
arguments: [if, unless]
|
50
|
+
nested: '*'
|
47
51
|
|
48
52
|
- names: protect_from_forgery
|
49
|
-
calls:
|
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:
|
60
|
+
calls:
|
61
|
+
arguments: [if, unless]
|
62
|
+
nested: '*'
|
55
63
|
|
56
64
|
|
57
65
|
- name: helper
|
data/lib/config/activejob.yml
CHANGED
@@ -23,10 +23,9 @@ dynamic:
|
|
23
23
|
- around_perform
|
24
24
|
- after_perform
|
25
25
|
calls:
|
26
|
-
- arguments:
|
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
|
data/lib/config/activemodel.yml
CHANGED
@@ -82,25 +82,26 @@ dynamic:
|
|
82
82
|
- before_validation
|
83
83
|
- after_validation
|
84
84
|
calls:
|
85
|
-
- arguments:
|
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:
|
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
|
-
-
|
103
|
-
-
|
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:
|
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:
|
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
|
-
|
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
|
data/lib/config/activerecord.yml
CHANGED
@@ -22,7 +22,23 @@ dynamic:
|
|
22
22
|
- validates_numericality_of
|
23
23
|
- validates_presence_of
|
24
24
|
- validates_uniqueness_of
|
25
|
-
calls:
|
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
|
@@ -88,6 +104,8 @@ dynamic:
|
|
88
104
|
|
89
105
|
# https://edgeapi.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html
|
90
106
|
- name: has_one
|
107
|
+
unless:
|
108
|
+
has_receiver: true
|
91
109
|
defines:
|
92
110
|
argument: 0
|
93
111
|
transforms:
|
@@ -100,6 +118,8 @@ dynamic:
|
|
100
118
|
|
101
119
|
- name: belongs_to
|
102
120
|
has_argument: polymorphic
|
121
|
+
unless:
|
122
|
+
has_receiver: true
|
103
123
|
defines:
|
104
124
|
argument: 0
|
105
125
|
transforms:
|
@@ -111,7 +131,9 @@ dynamic:
|
|
111
131
|
|
112
132
|
- name: belongs_to
|
113
133
|
unless:
|
114
|
-
|
134
|
+
any:
|
135
|
+
- has_argument: polymorphic
|
136
|
+
- has_receiver: true
|
115
137
|
defines:
|
116
138
|
argument: 0
|
117
139
|
transforms:
|
@@ -125,6 +147,8 @@ dynamic:
|
|
125
147
|
- add_suffix: _previously_changed?
|
126
148
|
|
127
149
|
- name: [has_and_belongs_to_many, has_many]
|
150
|
+
unless:
|
151
|
+
has_receiver: true
|
128
152
|
defines:
|
129
153
|
argument: 0
|
130
154
|
transforms:
|
@@ -139,7 +163,9 @@ dynamic:
|
|
139
163
|
- has_one
|
140
164
|
- belongs_to
|
141
165
|
unless:
|
142
|
-
|
166
|
+
any:
|
167
|
+
- has_argument: [class_name, polymorphic]
|
168
|
+
- has_receiver: true
|
143
169
|
calls:
|
144
170
|
argument: 0
|
145
171
|
camelize: true
|
@@ -149,7 +175,9 @@ dynamic:
|
|
149
175
|
- has_many
|
150
176
|
- has_and_belongs_to_many
|
151
177
|
unless:
|
152
|
-
|
178
|
+
any:
|
179
|
+
- has_argument: [class_name, polymorphic]
|
180
|
+
- has_receiver: true
|
153
181
|
calls:
|
154
182
|
- argument: 0
|
155
183
|
camelize: true
|
@@ -174,9 +202,11 @@ dynamic:
|
|
174
202
|
|
175
203
|
- name: belongs_to
|
176
204
|
unless:
|
177
|
-
|
178
|
-
|
179
|
-
|
205
|
+
any:
|
206
|
+
- has_argument:
|
207
|
+
at: optional
|
208
|
+
has_value: true
|
209
|
+
- has_receiver: true
|
180
210
|
calls:
|
181
211
|
argument: 0
|
182
212
|
|
@@ -185,6 +215,8 @@ dynamic:
|
|
185
215
|
- has_many
|
186
216
|
- belongs_to
|
187
217
|
- has_and_belongs_to_many
|
218
|
+
unless:
|
219
|
+
has_receiver: true
|
188
220
|
calls:
|
189
221
|
- argument: class_name
|
190
222
|
split: '::'
|
@@ -193,6 +225,8 @@ dynamic:
|
|
193
225
|
add_suffix: '='
|
194
226
|
|
195
227
|
- name: belongs_to
|
228
|
+
unless:
|
229
|
+
has_receiver: true
|
196
230
|
calls:
|
197
231
|
argument: ensuring_owner_was
|
198
232
|
|
@@ -202,6 +236,8 @@ dynamic:
|
|
202
236
|
- has_many
|
203
237
|
- belongs_to
|
204
238
|
- has_and_belongs_to_many
|
239
|
+
unless:
|
240
|
+
has_receiver: true
|
205
241
|
has_argument:
|
206
242
|
at:
|
207
243
|
- dependent
|
@@ -219,6 +255,8 @@ dynamic:
|
|
219
255
|
argument: 0
|
220
256
|
|
221
257
|
- name: [has_one, has_many, belongs_to, has_and_belongs_to_many]
|
258
|
+
unless:
|
259
|
+
has_receiver: true
|
222
260
|
calls:
|
223
261
|
argument: [before_add, after_add, before_remove, after_remove]
|
224
262
|
nested: '*'
|
@@ -345,10 +383,9 @@ dynamic:
|
|
345
383
|
- before_save
|
346
384
|
- before_update
|
347
385
|
calls:
|
348
|
-
- arguments:
|
386
|
+
- arguments: '*'
|
349
387
|
- arguments: [if, unless]
|
350
|
-
nested:
|
351
|
-
arguments: '*'
|
388
|
+
nested: '*'
|
352
389
|
|
353
390
|
- name:
|
354
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:
|
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:
|
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:
|
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
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Leftovers
|
4
|
+
class ConfigLoader
|
5
|
+
class HasReceiverSchema < ValueOrObjectSchema
|
6
|
+
inherit_attributes_from HasValueSchema, except: :unless
|
7
|
+
|
8
|
+
attribute :literal, ValueOrArraySchema[ScalarValueSchema],
|
9
|
+
require_group: :matcher
|
10
|
+
attribute :unless, ValueOrArraySchema[HasReceiverSchema], require_group: :matcher
|
11
|
+
|
12
|
+
self.or_value_schema = ScalarValueSchema
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -12,7 +12,7 @@ module Leftovers
|
|
12
12
|
attribute :at, ValueOrArraySchema[ArgumentPositionSchema], require_group: :matcher
|
13
13
|
attribute :has_value, ValueOrArraySchema[HasValueSchema], require_group: :matcher
|
14
14
|
|
15
|
-
attribute :has_receiver, ValueOrArraySchema[
|
15
|
+
attribute :has_receiver, ValueOrArraySchema[HasReceiverSchema], require_group: :matcher
|
16
16
|
attribute :type, ValueOrArraySchema[ValueTypeSchema], require_group: :matcher
|
17
17
|
attribute :unless, ValueOrArraySchema[HasValueSchema], require_group: :matcher
|
18
18
|
|
@@ -9,7 +9,7 @@ module Leftovers
|
|
9
9
|
attribute :document, TrueSchema, require_group: :matcher
|
10
10
|
attribute :has_arguments, ValueOrArraySchema[HasArgumentSchema], aliases: :has_argument,
|
11
11
|
require_group: :matcher
|
12
|
-
attribute :has_receiver, ValueOrArraySchema[
|
12
|
+
attribute :has_receiver, ValueOrArraySchema[HasReceiverSchema], require_group: :matcher
|
13
13
|
attribute :type, ValueOrArraySchema[ValueTypeSchema], require_group: :matcher
|
14
14
|
attribute :privacy, ValueOrArraySchema[PrivacySchema], require_group: :matcher
|
15
15
|
attribute :unless, ValueOrArraySchema[RulePatternSchema], require_group: :matcher
|
@@ -4,7 +4,7 @@ module Leftovers
|
|
4
4
|
class ConfigLoader
|
5
5
|
class ValueMatcherConditionSchema < ObjectSchema
|
6
6
|
attribute :has_arguments, ValueOrArraySchema[HasArgumentSchema], aliases: :has_argument
|
7
|
-
attribute :has_receiver, ValueOrArraySchema[
|
7
|
+
attribute :has_receiver, ValueOrArraySchema[HasReceiverSchema]
|
8
8
|
attribute :unless, ValueOrArraySchema[ValueMatcherConditionSchema]
|
9
9
|
attribute :all, ArraySchema[ValueMatcherConditionSchema]
|
10
10
|
attribute :any, ArraySchema[ValueMatcherConditionSchema]
|
@@ -13,6 +13,7 @@ module Leftovers
|
|
13
13
|
autoload(:DynamicSchema, "#{__dir__}/config_loader/dynamic_schema")
|
14
14
|
autoload(:HasArgumentSchema, "#{__dir__}/config_loader/has_argument_schema")
|
15
15
|
autoload(:HasValueSchema, "#{__dir__}/config_loader/has_value_schema")
|
16
|
+
autoload(:HasReceiverSchema, "#{__dir__}/config_loader/has_receiver_schema")
|
16
17
|
autoload(:InheritSchemaAttributes, "#{__dir__}/config_loader/inherit_schema_attributes")
|
17
18
|
autoload(:KeepTestOnlySchema, "#{__dir__}/config_loader/keep_test_only_schema")
|
18
19
|
autoload(:KeywordArgumentSchema, "#{__dir__}/config_loader/keyword_argument_schema")
|
@@ -1,25 +1,19 @@
|
|
1
1
|
# frozen-string-literal: true
|
2
2
|
|
3
3
|
module Leftovers
|
4
|
-
class DefinitionNode
|
5
|
-
attr_reader :name, :
|
4
|
+
class DefinitionNode < ::Leftovers::AST::Node
|
5
|
+
attr_reader :name, :path
|
6
|
+
alias_method :to_sym, :name
|
6
7
|
|
7
8
|
def initialize(node, name:, location: node.loc.expression)
|
8
|
-
@node = node
|
9
9
|
@name = name
|
10
|
-
@
|
10
|
+
@path = node.path
|
11
|
+
@location = location
|
12
|
+
super(:leftovers_definition)
|
11
13
|
end
|
12
14
|
|
13
|
-
def
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
def positional_arguments
|
18
|
-
nil
|
19
|
-
end
|
20
|
-
|
21
|
-
def path
|
22
|
-
node.path
|
15
|
+
def to_s
|
16
|
+
name.to_s
|
23
17
|
end
|
24
18
|
end
|
25
19
|
end
|
@@ -96,8 +96,9 @@ module Leftovers
|
|
96
96
|
# just collects the :call=, super will collect the :call
|
97
97
|
when :send, :csend then calls << :"#{node.name}="
|
98
98
|
# just collects the call, super will collect the definition
|
99
|
-
when :ivasgn, :gvasgn, :cvasgn then calls << node.name
|
100
|
-
when :lvasgn then nil # we don't
|
99
|
+
when :ivasgn, :gvasgn, :cvasgn, :casgn then calls << node.name
|
100
|
+
when :lvasgn then nil # we don't check local variable use, rubocop already covers this
|
101
|
+
|
101
102
|
# :nocov:
|
102
103
|
else raise Leftovers::UnexpectedCase, "Unhandled value #{node.type.inspect}"
|
103
104
|
# :nocov:
|
@@ -4,10 +4,19 @@ module Leftovers
|
|
4
4
|
module MatcherBuilders
|
5
5
|
module NodeHasReceiver
|
6
6
|
class << self
|
7
|
-
def build(pattern)
|
8
|
-
|
7
|
+
def build(pattern) # rubocop:disable Metrics/MethodLength
|
8
|
+
case pattern
|
9
|
+
when true
|
10
|
+
::Leftovers::Matchers::NodeHasAnyReceiver
|
11
|
+
when false, :_leftovers_nil_value
|
12
|
+
::Leftovers::Matchers::Not.new(
|
13
|
+
::Leftovers::Matchers::NodeHasAnyReceiver
|
14
|
+
)
|
15
|
+
else
|
16
|
+
matcher = ::Leftovers::MatcherBuilders::NodeValue.build(pattern)
|
9
17
|
|
10
|
-
|
18
|
+
::Leftovers::Matchers::NodeHasReceiver.new(matcher) if matcher
|
19
|
+
end
|
11
20
|
end
|
12
21
|
end
|
13
22
|
end
|
@@ -53,6 +53,7 @@ module Leftovers
|
|
53
53
|
names: nil, match: nil, has_prefix: nil, has_suffix: nil,
|
54
54
|
type: nil,
|
55
55
|
has_receiver: nil,
|
56
|
+
literal: nil,
|
56
57
|
unless_arg: nil
|
57
58
|
)
|
58
59
|
::Leftovers::MatcherBuilders::And.build([
|
@@ -60,6 +61,7 @@ module Leftovers
|
|
60
61
|
build_node_name_matcher(names, match, has_prefix, has_suffix),
|
61
62
|
::Leftovers::MatcherBuilders::NodeType.build(type),
|
62
63
|
::Leftovers::MatcherBuilders::NodeHasReceiver.build(has_receiver),
|
64
|
+
::Leftovers::MatcherBuilders::NodeValue.build(literal),
|
63
65
|
build_unless(unless_arg)
|
64
66
|
])
|
65
67
|
end
|
data/lib/leftovers/matchers.rb
CHANGED
@@ -10,6 +10,7 @@ module Leftovers
|
|
10
10
|
:NodeHasAnyPositionalArgumentWithValue,
|
11
11
|
"#{__dir__}/matchers/node_has_any_positional_argument_with_value"
|
12
12
|
)
|
13
|
+
autoload(:NodeHasAnyReceiver, "#{__dir__}/matchers/node_has_any_receiver")
|
13
14
|
autoload(
|
14
15
|
:NodeHasPositionalArgumentWithValue,
|
15
16
|
"#{__dir__}/matchers/node_has_positional_argument_with_value"
|
data/lib/leftovers/reporter.rb
CHANGED
@@ -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
|
|
data/lib/leftovers/version.rb
CHANGED
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.
|
4
|
+
version: 0.11.1
|
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-03
|
11
|
+
date: 2022-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -409,6 +409,7 @@ files:
|
|
409
409
|
- lib/leftovers/config_loader/document_schema.rb
|
410
410
|
- lib/leftovers/config_loader/dynamic_schema.rb
|
411
411
|
- lib/leftovers/config_loader/has_argument_schema.rb
|
412
|
+
- lib/leftovers/config_loader/has_receiver_schema.rb
|
412
413
|
- lib/leftovers/config_loader/has_value_schema.rb
|
413
414
|
- lib/leftovers/config_loader/inherit_schema_attributes.rb
|
414
415
|
- lib/leftovers/config_loader/keep_test_only_schema.rb
|
@@ -477,6 +478,7 @@ files:
|
|
477
478
|
- lib/leftovers/matchers/any.rb
|
478
479
|
- lib/leftovers/matchers/node_has_any_keyword_argument.rb
|
479
480
|
- lib/leftovers/matchers/node_has_any_positional_argument_with_value.rb
|
481
|
+
- lib/leftovers/matchers/node_has_any_receiver.rb
|
480
482
|
- lib/leftovers/matchers/node_has_positional_argument.rb
|
481
483
|
- lib/leftovers/matchers/node_has_positional_argument_with_value.rb
|
482
484
|
- lib/leftovers/matchers/node_has_receiver.rb
|