leftovers 0.5.4 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -1
- data/README.md +21 -1
- data/docs/Configuration.md +188 -20
- data/leftovers.gemspec +8 -5
- data/lib/config/actionmailer.yml +11 -11
- data/lib/config/actionpack.yml +11 -0
- data/lib/config/activesupport.yml +1 -1
- data/lib/config/rails.yml +1 -1
- data/lib/config/railties.yml +11 -0
- data/lib/config/ruby.yml +79 -0
- data/lib/leftovers/ast/node.rb +16 -11
- data/lib/leftovers/collector.rb +3 -1
- data/lib/leftovers/config.rb +9 -28
- data/lib/leftovers/config_loader/argument_position_schema.rb +11 -0
- data/lib/leftovers/config_loader/argumentless_transform_schema.rb +21 -0
- data/lib/leftovers/config_loader/attribute.rb +30 -0
- data/lib/leftovers/config_loader/document_schema.rb +21 -0
- data/lib/leftovers/config_loader/dynamic_schema.rb +17 -0
- data/lib/leftovers/config_loader/has_argument_schema.rb +13 -0
- data/lib/leftovers/config_loader/has_value_schema.rb +18 -0
- data/lib/leftovers/config_loader/keep_test_only_schema.rb +13 -0
- data/lib/leftovers/config_loader/node.rb +106 -0
- data/lib/leftovers/config_loader/object_schema.rb +189 -0
- data/lib/leftovers/config_loader/privacy_processor_schema.rb +12 -0
- data/lib/leftovers/config_loader/privacy_schema.rb +15 -0
- data/lib/leftovers/config_loader/require_schema.rb +11 -0
- data/lib/leftovers/config_loader/rule_pattern_schema.rb +18 -0
- data/lib/leftovers/config_loader/scalar_argument_schema.rb +14 -0
- data/lib/leftovers/config_loader/scalar_value_schema.rb +14 -0
- data/lib/leftovers/config_loader/schema.rb +21 -0
- data/lib/leftovers/config_loader/string_enum_schema.rb +62 -0
- data/lib/leftovers/config_loader/string_pattern_schema.rb +14 -0
- data/lib/leftovers/config_loader/string_schema.rb +14 -0
- data/lib/leftovers/config_loader/string_value_processor_schema.rb +11 -0
- data/lib/leftovers/config_loader/suggester.rb +22 -0
- data/lib/leftovers/config_loader/transform_schema.rb +28 -0
- data/lib/leftovers/config_loader/true_schema.rb +18 -0
- data/lib/leftovers/config_loader/value_matcher_schema.rb +18 -0
- data/lib/leftovers/config_loader/value_or_array_schema.rb +64 -0
- data/lib/leftovers/config_loader/value_processor_schema.rb +14 -0
- data/lib/leftovers/config_loader/value_type_schema.rb +17 -0
- data/lib/leftovers/config_loader.rb +82 -0
- data/lib/leftovers/definition.rb +1 -1
- data/lib/leftovers/definition_node.rb +6 -17
- data/lib/leftovers/definition_node_set.rb +11 -0
- data/lib/leftovers/definition_to_add.rb +31 -0
- data/lib/leftovers/dynamic_processors/call.rb +4 -7
- data/lib/leftovers/dynamic_processors/call_definition.rb +14 -11
- data/lib/leftovers/dynamic_processors/definition.rb +8 -7
- data/lib/leftovers/dynamic_processors/set_default_privacy.rb +18 -0
- data/lib/leftovers/dynamic_processors/set_privacy.rb +23 -0
- data/lib/leftovers/dynamic_processors.rb +2 -0
- data/lib/leftovers/file.rb +57 -11
- data/lib/leftovers/file_collector.rb +77 -19
- data/lib/leftovers/json.rb +28 -0
- data/lib/leftovers/matcher_builders/document.rb +13 -0
- data/lib/leftovers/matcher_builders/node.rb +7 -1
- data/lib/leftovers/matcher_builders/node_has_argument.rb +3 -4
- data/lib/leftovers/matcher_builders/node_has_keyword_argument.rb +1 -1
- data/lib/leftovers/matcher_builders/node_has_positional_argument.rb +1 -1
- data/lib/leftovers/matcher_builders/node_privacy.rb +13 -0
- data/lib/leftovers/matcher_builders/node_type.rb +4 -4
- data/lib/leftovers/matcher_builders/node_value.rb +1 -1
- data/lib/leftovers/matcher_builders/string_pattern.rb +14 -5
- data/lib/leftovers/matcher_builders.rb +2 -0
- data/lib/leftovers/matchers/all.rb +0 -4
- data/lib/leftovers/matchers/and.rb +0 -4
- data/lib/leftovers/matchers/any.rb +0 -4
- data/lib/leftovers/matchers/node_has_any_keyword_argument.rb +1 -7
- data/lib/leftovers/matchers/node_has_any_positional_argument_with_value.rb +1 -7
- data/lib/leftovers/matchers/node_has_positional_argument_with_value.rb +0 -4
- data/lib/leftovers/matchers/node_name.rb +0 -4
- data/lib/leftovers/matchers/node_pair_value.rb +0 -4
- data/lib/leftovers/matchers/node_path.rb +0 -4
- data/lib/leftovers/matchers/node_privacy.rb +19 -0
- data/lib/leftovers/matchers/node_scalar_value.rb +0 -4
- data/lib/leftovers/matchers/node_type.rb +0 -4
- data/lib/leftovers/matchers/not.rb +0 -4
- data/lib/leftovers/matchers/or.rb +0 -4
- data/lib/leftovers/matchers.rb +1 -0
- data/lib/leftovers/merged_config.rb +25 -23
- data/lib/leftovers/processor_builders/add_prefix.rb +1 -1
- data/lib/leftovers/processor_builders/add_suffix.rb +1 -1
- data/lib/leftovers/processor_builders/dynamic.rb +51 -16
- data/lib/leftovers/processor_builders/transform.rb +2 -2
- data/lib/leftovers/processor_builders/transform_set.rb +8 -8
- data/lib/leftovers/todo_reporter.rb +10 -35
- data/lib/leftovers/value_processors/delete_prefix.rb +0 -6
- data/lib/leftovers/value_processors/delete_suffix.rb +0 -6
- data/lib/leftovers/value_processors/each_for_definition_set.rb +2 -5
- data/lib/leftovers/value_processors/each_positional_argument.rb +1 -1
- data/lib/leftovers/value_processors/keyword.rb +0 -4
- data/lib/leftovers/value_processors/keyword_argument.rb +0 -4
- data/lib/leftovers/value_processors/return_definition_node.rb +14 -0
- data/lib/leftovers/value_processors/{return_string.rb → return_sym.rb} +1 -1
- data/lib/leftovers/value_processors.rb +2 -2
- data/lib/leftovers/version.rb +1 -1
- data/lib/leftovers/yaml.rb +73 -0
- data/lib/leftovers.rb +29 -21
- metadata +85 -36
- data/lib/config/actioncable.yml +0 -4
- data/lib/leftovers/backports.rb +0 -40
- data/lib/leftovers/config_validator/error_processor.rb +0 -196
- data/lib/leftovers/config_validator/schema_hash.rb +0 -530
- data/lib/leftovers/config_validator.rb +0 -60
- data/lib/leftovers/value_processors/return_definition.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f27830ef42bcbcec33a78126a3b47582fa394714e1d137e802cd5ab166e35df5
|
4
|
+
data.tar.gz: a111ed33a8345fe8dc5d43cb92206d52cbc47a03bc8e961baee8558d677542b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e14c6c1b74d4c13ebcbb4d1184d50257d6aacaf05e8e6708282633f61ea1988374156880d66bb26a037bf4b67b58381246f12357bdaa99ff9248db620d94c152
|
7
|
+
data.tar.gz: 34e766e6ca2374858ee6da35e924287641bc4441d8f642e4d08285a0066185aa865724567b90f91de34b17f340f3f182e9b3f326c5fc63bf6abc414c0dc058b3
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,32 @@
|
|
1
|
-
#
|
1
|
+
# v0.7.0
|
2
|
+
- Rewrite the config parser/validation
|
3
|
+
- to provide clearer error messages with line numbers and everything
|
4
|
+
- to allow removing the json_schemer dependency with its 4 further dependencies
|
5
|
+
- Allow `match:` to be used with `has_prefix:` and/or `has_suffix:`. There's not a good use for this but it was easier than encoding 'this can't be used with that' logic especially for it.
|
6
|
+
- Add the possibility to quiet the `requires:` config, like:
|
7
|
+
```yml
|
8
|
+
requires:
|
9
|
+
- 'active_support/inflections'
|
10
|
+
- quiet: './config/initializers/inflections'
|
11
|
+
```
|
12
|
+
- consider all the public methods in rails custom generators to be used, this required some new features:
|
13
|
+
- add filtering methods/constants by public/protected/private
|
14
|
+
- add the possibility to set the privacy of methods and constants with method calls (`set_privacy:`, and `set_default_privacy:`)
|
15
|
+
- add `Method` and `Constant` as options for the `type:` filter
|
16
|
+
- add type filtering to dynamic.
|
17
|
+
- check `def self.whatever` as a definition, i didn't realise i wasn't checking this.
|
18
|
+
|
19
|
+
# v0.6.0
|
20
|
+
- drop ruby 2.4 support, allowing for some performance improvements
|
21
|
+
- Add ability to parse JSON and YAML files
|
22
|
+
- Add magic comment that points to a particular dynamic rule
|
23
|
+
- repeated calls to --write-todo won't have ordering differences
|
24
|
+
- fix issue with --write-todo and unused methods defined in test files
|
25
|
+
|
26
|
+
# v0.5.5
|
27
|
+
- Fix rails resource/resources method signatures
|
28
|
+
|
29
|
+
# v0.5.4
|
2
30
|
- Add support for slim templates #13 - thanks @veganstraightedge
|
3
31
|
- fix the #how-to-resolve link #11 - thanks @veganstraightedge
|
4
32
|
|
data/README.md
CHANGED
@@ -129,7 +129,7 @@ To do this for all definitions of this name, instead of adding a comment, add th
|
|
129
129
|
|
130
130
|
### `# leftovers:call`
|
131
131
|
_aliases `leftovers:calls`_
|
132
|
-
To mark a
|
132
|
+
To mark a call that doesn't use literal values, use `leftovers:call` with the method name listed
|
133
133
|
```ruby
|
134
134
|
method = [:puts, :warn].sample # leftovers:call puts, warn
|
135
135
|
send(method, 'text')
|
@@ -137,6 +137,26 @@ send(method, 'text')
|
|
137
137
|
|
138
138
|
This would consider `puts` and `warn` to both have been called
|
139
139
|
|
140
|
+
### `# leftovers:dynamic:*`
|
141
|
+
To mark a dynamic call for literal hash and array values without enumerating everything in the comment again, use `leftovers:dynamic:` on the same line as the beginning of the array or hash
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
[ # leftovers:dynamic:call_login
|
145
|
+
:user,
|
146
|
+
:admin
|
147
|
+
].each { |method| send("#{method}_login") }
|
148
|
+
```
|
149
|
+
|
150
|
+
with the following configuration matching the `name: value` to the `leftovers:dynamic:process_name`
|
151
|
+
|
152
|
+
```yaml
|
153
|
+
dynamic:
|
154
|
+
name: call_login
|
155
|
+
arguments: '*'
|
156
|
+
add_suffix: '_login'
|
157
|
+
```
|
158
|
+
This would consider `user_login` and `admin_login` to both have been called.
|
159
|
+
|
140
160
|
## Configuration file
|
141
161
|
|
142
162
|
The configuration is read from `.leftovers.yml` in your project root.
|
data/docs/Configuration.md
CHANGED
@@ -9,6 +9,8 @@ Its presence is optional and all of these settings are optional.
|
|
9
9
|
- [`haml_paths:`](#haml_paths)
|
10
10
|
- [`slim_paths:`](#slim_paths)
|
11
11
|
- [`erb_paths:`](#erb_paths)
|
12
|
+
- [`yaml_paths:`](#yaml_paths)
|
13
|
+
- [`json_paths:`](#json_paths)
|
12
14
|
- [`requires:`](#requires)
|
13
15
|
- [`gems:`](#gems)
|
14
16
|
- [`keep:`](#keep)
|
@@ -57,12 +59,17 @@ List filenames/paths that you want to include
|
|
57
59
|
Unlike other `paths:` configuration, each entry is **not** the gitignore pattern format.
|
58
60
|
Instead it is strings that can be passed directly to ruby's `require` method (relative paths should start with `./`).
|
59
61
|
|
60
|
-
|
62
|
+
```yml
|
63
|
+
require: ./config/initializers/my_other_inflections_file
|
64
|
+
```
|
61
65
|
|
62
|
-
|
66
|
+
Missing files/gems will be a warning, but not a LoadError.
|
67
|
+
To avoid seeing the warning if the file isn't there use `quiet:`.
|
63
68
|
|
64
69
|
```yml
|
65
|
-
|
70
|
+
requires:
|
71
|
+
- 'active_support/inflections' # will warn if it's missing
|
72
|
+
- quiet: './config/initializers/inflections' # will say nothing
|
66
73
|
```
|
67
74
|
|
68
75
|
Arrays are not necessary for single values
|
@@ -117,6 +124,76 @@ erb_paths:
|
|
117
124
|
|
118
125
|
Arrays are not necessary for single values. `*.erb` is recognized by default
|
119
126
|
|
127
|
+
## `yaml_paths:`
|
128
|
+
|
129
|
+
list filenames/paths of test directories that are in the yaml format
|
130
|
+
Defined using the [.gitignore pattern format](https://git-scm.com/docs/gitignore#_pattern_format)
|
131
|
+
|
132
|
+
```yml
|
133
|
+
include:
|
134
|
+
- 'config/*.yml'
|
135
|
+
yaml_paths:
|
136
|
+
- '*.yml'
|
137
|
+
```
|
138
|
+
|
139
|
+
These documents will consider yaml tags like `!ruby/class 'MyClass'` to be a call to `MyClass` and render the structure of the yaml as arguments for the [`document:true`](#document-true) rule.
|
140
|
+
|
141
|
+
so you could, e.g. read the class name out of a yaml document like:
|
142
|
+
|
143
|
+
```yml
|
144
|
+
class_name: MyClass
|
145
|
+
```
|
146
|
+
|
147
|
+
with config like:
|
148
|
+
|
149
|
+
```yml
|
150
|
+
include_paths:
|
151
|
+
- 'config/*.yml'
|
152
|
+
|
153
|
+
dynamic:
|
154
|
+
document: true
|
155
|
+
path: config/*.yml
|
156
|
+
calls:
|
157
|
+
argument: class_name
|
158
|
+
```
|
159
|
+
|
160
|
+
[`nested:`](#nested) may be useful for more complex yaml structures
|
161
|
+
|
162
|
+
## `json_paths:`
|
163
|
+
|
164
|
+
list filenames/paths of test directories that are in the json format
|
165
|
+
Defined using the [.gitignore pattern format](https://git-scm.com/docs/gitignore#_pattern_format)
|
166
|
+
|
167
|
+
```yml
|
168
|
+
include:
|
169
|
+
- 'config/*.json'
|
170
|
+
json_paths:
|
171
|
+
- '*.json'
|
172
|
+
```
|
173
|
+
|
174
|
+
These documents render the structure of the yaml as arguments for the [`document:true`](#document-true) rule.
|
175
|
+
|
176
|
+
so you could, e.g. read the class name out of a yaml document like:
|
177
|
+
|
178
|
+
```json
|
179
|
+
{ "class_name": "MyClass" }
|
180
|
+
```
|
181
|
+
|
182
|
+
with config like:
|
183
|
+
|
184
|
+
```yml
|
185
|
+
include_paths:
|
186
|
+
- 'config/*.json'
|
187
|
+
|
188
|
+
dynamic:
|
189
|
+
document: true
|
190
|
+
path: config/*.json
|
191
|
+
calls:
|
192
|
+
argument: class_name
|
193
|
+
```
|
194
|
+
|
195
|
+
[`nested:`](#nested) may be useful for more complex json structures
|
196
|
+
|
120
197
|
## `gems:`
|
121
198
|
_alias `gem:`_
|
122
199
|
|
@@ -141,10 +218,12 @@ Each entry can be a string (an exact match for a method, constant, or variable n
|
|
141
218
|
or the properties from `names:`
|
142
219
|
- [`has_prefix:`](#has_prefix)
|
143
220
|
- [`has_suffix:`](#has_suffix)
|
144
|
-
- [`matches:`](#matches)
|
221
|
+
- [`matches:`](#matches)
|
145
222
|
- [`paths:`](#paths)
|
146
223
|
- [`has_arguments:`](#has_arguments)
|
147
224
|
- [`has_receiver:`](#has_receiver)
|
225
|
+
- [`type:`](#type)
|
226
|
+
- [`privacy:`](#privacy)
|
148
227
|
- [`unless`](#unless)
|
149
228
|
|
150
229
|
Arrays are not necessary for single values
|
@@ -170,7 +249,7 @@ Each entry can be a string (an exact match for a method, constant, or variable n
|
|
170
249
|
or the properties from `names:`
|
171
250
|
- [`has_prefix:`](#has_prefix)
|
172
251
|
- [`has_suffix:`](#has_suffix)
|
173
|
-
- [`matches:`](#matches)
|
252
|
+
- [`matches:`](#matches)
|
174
253
|
- [`paths:`](#paths)
|
175
254
|
- [`has_arguments:`](#has_arguments)
|
176
255
|
- [`unless`](#unless)
|
@@ -202,11 +281,14 @@ Each entry must have at least one of the following properties to restrict which
|
|
202
281
|
- [`paths:`](#paths)
|
203
282
|
- [`has_arguments:`](#has_arguments)
|
204
283
|
- [`has_receiver:`](#has_receiver)
|
205
|
-
- [`unless
|
284
|
+
- [`unless:`](#unless)
|
285
|
+
- [`document: true`](#document-true)
|
206
286
|
|
207
|
-
And must have
|
287
|
+
And must have at least one of
|
208
288
|
- ['calls:`](#calls-defines)
|
209
289
|
- [`defines:`](#calls-defines)
|
290
|
+
- [`set_privacy:](#set-privacy)
|
291
|
+
- [`set_default_privacy:`](#set-default-privacy)
|
210
292
|
|
211
293
|
Arrays are not necessary for single values.
|
212
294
|
|
@@ -232,7 +314,7 @@ This is a list of methods/constants/variables, and can be used in [`dynamic:`](#
|
|
232
314
|
Each entry can be a string (an exact match for a method, constant, or variable name that includes the sigil), or have at least one of the following properties:
|
233
315
|
- [`has_prefix:`](#has_prefix)
|
234
316
|
- [`has_suffix:`](#has_suffix)
|
235
|
-
- [`matches:`](#matches)
|
317
|
+
- [`matches:`](#matches)
|
236
318
|
|
237
319
|
Arrays are not necessary for single values
|
238
320
|
|
@@ -299,10 +381,37 @@ keep:
|
|
299
381
|
path: /app/helpers
|
300
382
|
```
|
301
383
|
|
384
|
+
## `document: true`
|
385
|
+
|
386
|
+
Instructs to consider the whole document. this is useful when parsing [YAML](#yaml-paths) or [JSON](#json-paths) config files for various values.
|
387
|
+
|
388
|
+
e.g.
|
389
|
+
|
390
|
+
```yml
|
391
|
+
includes: /config/roles.yml
|
392
|
+
dynamic:
|
393
|
+
- document: true
|
394
|
+
path: /config/roles.yml
|
395
|
+
defines:
|
396
|
+
arguments: '*'
|
397
|
+
add_suffix: '?'
|
398
|
+
add_prefix: can_
|
399
|
+
```
|
400
|
+
|
401
|
+
will parse "config/roles.yml"
|
402
|
+
```yml
|
403
|
+
- build_house
|
404
|
+
- drive_car
|
405
|
+
```
|
406
|
+
|
407
|
+
and consider it to have created methods like `can_build_house?` and `can_drive_car?`
|
408
|
+
|
409
|
+
[`nested:`](#nested) may be useful for more complex data structures
|
410
|
+
|
302
411
|
## `calls:`, `defines:`
|
303
412
|
_aliases `call:`, `define:`_
|
304
413
|
|
305
|
-
|
414
|
+
These may be used as entries in [`dynamic:`](#dynamic)
|
306
415
|
|
307
416
|
This is a list of values that are called or defined dynamically by the matched method, or eventually after being assigned to the the matched constant or variable.
|
308
417
|
|
@@ -354,6 +463,43 @@ dynamic:
|
|
354
463
|
calls: 1
|
355
464
|
```
|
356
465
|
|
466
|
+
## `set_privacy:`
|
467
|
+
|
468
|
+
Set privacy has the same requirements as [`calls:` & `defines:`](#calls-defines).
|
469
|
+
|
470
|
+
additional it requires a `to:` with one of either `private`, `public`, or `protected`.
|
471
|
+
|
472
|
+
For example, from the ruby config:
|
473
|
+
```yml
|
474
|
+
dynamic:
|
475
|
+
name: private_class_method
|
476
|
+
has_argument: 0
|
477
|
+
set_privacy:
|
478
|
+
argument: '*'
|
479
|
+
to: private
|
480
|
+
```
|
481
|
+
|
482
|
+
which sets all methods named by the arguments to the privacy_class_method method to private.
|
483
|
+
|
484
|
+
these methods could then be filtered using the [`privacy:`](#privacy) method in another [`dynamic:`](#dynamic) or [`keep:`](#keep) rule.
|
485
|
+
|
486
|
+
Leftovers limits this to only affect methods defined in the same file.
|
487
|
+
|
488
|
+
## `set_default_privacy:`
|
489
|
+
|
490
|
+
This must be one of `public`, `private`, or `protected` and will set all subsequent method definitions in this file to that default privacy (unless its then overridden by [`set_privacy`](#set_privacy))
|
491
|
+
|
492
|
+
For example, from the default ruby config:
|
493
|
+
```yml
|
494
|
+
dynamic:
|
495
|
+
name: private
|
496
|
+
unless:
|
497
|
+
has_argument: 0
|
498
|
+
set_default_privacy: private
|
499
|
+
```
|
500
|
+
|
501
|
+
these methods could then be filtered using the [`privacy:`](#privacy) method in another [`dynamic:`](#dynamic) or [`keep:`](#keep) rule.
|
502
|
+
|
357
503
|
## `arguments:`
|
358
504
|
_alias `argument:`_
|
359
505
|
|
@@ -366,7 +512,9 @@ It can have any of these properties:
|
|
366
512
|
- [`at:`](#at)
|
367
513
|
- [`has_value:`](#has_value_has_receiver)
|
368
514
|
|
369
|
-
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
|
515
|
+
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.
|
516
|
+
|
517
|
+
Positional arguments are zero indexed
|
370
518
|
|
371
519
|
## `has_arguments:`
|
372
520
|
_alias `has_argument:`_
|
@@ -384,6 +532,8 @@ It can have any of these properties:
|
|
384
532
|
|
385
533
|
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
|
386
534
|
|
535
|
+
Positional arguments are zero indexed
|
536
|
+
|
387
537
|
## `keywords:`
|
388
538
|
When the keyword argument **keywords** are the thing being called.
|
389
539
|
|
@@ -418,7 +568,7 @@ Each entry can be any of:
|
|
418
568
|
- or have at least one of the following properties to match the keyword/hash key string or symbol:
|
419
569
|
- [`has_prefix:`](#has_prefix)
|
420
570
|
- [`has_suffix:`](#has_suffix)
|
421
|
-
- [`matches:`](#matches)
|
571
|
+
- [`matches:`](#matches)
|
422
572
|
|
423
573
|
Arrays are not necessary for single values
|
424
574
|
|
@@ -429,10 +579,10 @@ filter [`arguments:`](#arguments), [`has_arguments:`](#has_arguments), and [`key
|
|
429
579
|
Each entry can be one of
|
430
580
|
- `true`, `false`, `nil`, or an Integer. matches the literal value
|
431
581
|
- a String. matches the literal string or symbol value
|
432
|
-
- or have at least one of the following properties to match
|
582
|
+
- or have at least one of the following properties to match the name:
|
433
583
|
- [`has_prefix:`](#has_prefix)
|
434
584
|
- [`has_suffix:`](#has_suffix)
|
435
|
-
- [`matches:`](#matches)
|
585
|
+
- [`matches:`](#matches)
|
436
586
|
- or have at least one of the following properties to match within an array or hash:
|
437
587
|
- [`at`](#at)
|
438
588
|
- [`has_value`](#has_value_has_receiver)
|
@@ -441,17 +591,35 @@ Each entry can be one of
|
|
441
591
|
- or have the following property to match the receiver
|
442
592
|
- [`has_receiver`](#has_value_has_receiver)
|
443
593
|
|
594
|
+
## `privacy:`
|
595
|
+
|
596
|
+
filter [`dynamic:`](#dynamic) and [`keep:`](#keep) by method/constant privacy
|
597
|
+
|
598
|
+
e.g.
|
599
|
+
|
600
|
+
```yml
|
601
|
+
keep:
|
602
|
+
- path: '**/generators/**/*_generator.rb'
|
603
|
+
privacy: public
|
604
|
+
type: Method
|
605
|
+
```
|
606
|
+
|
607
|
+
considers all public methods defined in rails generators to be called.
|
608
|
+
|
444
609
|
## `type:`
|
445
610
|
|
446
|
-
Filter
|
611
|
+
Filter by the literal type
|
447
612
|
|
448
613
|
Each entry can be one of
|
449
|
-
- `'String'`
|
450
|
-
- `'Symbol'`
|
451
|
-
- `'Integer'`
|
452
|
-
- `'Float'`
|
453
|
-
- `'Array'`
|
454
|
-
- `'Hash'`
|
614
|
+
- `'String'` a literal string, defined with "" or '' (not String.new)
|
615
|
+
- `'Symbol'` a literal symbol
|
616
|
+
- `'Integer'` a literal integer
|
617
|
+
- `'Float'` a literal float
|
618
|
+
- `'Array'` a literal array defined with [] (not Array.new)
|
619
|
+
- `'Hash'` a literal hash, defined with {} (not Hash.new)
|
620
|
+
- `'Proc'` a literal proc/lambda, defined with lambda {}, proc {}, or -> {} (not Proc.new)
|
621
|
+
- `'Method'` a method call or definition defined with def, (not define_method {})
|
622
|
+
- `'Constant'` a constant assignment, or a literal module or class defined with keywords, (not Module/Class.new)
|
455
623
|
|
456
624
|
Arrays are not necessary for single values
|
457
625
|
|
data/leftovers.gemspec
CHANGED
@@ -17,7 +17,9 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.metadata['homepage_uri'] = spec.homepage
|
18
18
|
spec.metadata['source_code_uri'] = 'http://github.com/robotdana/leftovers'
|
19
19
|
spec.metadata['changelog_uri'] = 'http://github.com/robotdana/leftovers/blob/main/CHANGELOG.md'
|
20
|
-
|
20
|
+
|
21
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
22
|
+
spec.required_ruby_version = '>= 2.5.0'
|
21
23
|
|
22
24
|
spec.files = Dir.glob('{lib,exe,docs}/**/{*,.*}') + %w{
|
23
25
|
CHANGELOG.md
|
@@ -33,13 +35,15 @@ Gem::Specification.new do |spec|
|
|
33
35
|
spec.add_development_dependency 'activesupport'
|
34
36
|
spec.add_development_dependency 'benchmark-ips'
|
35
37
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
38
|
+
spec.add_development_dependency 'did_you_mean'
|
36
39
|
spec.add_development_dependency 'haml'
|
37
40
|
spec.add_development_dependency 'pry', '~> 0.1'
|
38
41
|
spec.add_development_dependency 'rake', '>= 13'
|
39
42
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
40
|
-
spec.add_development_dependency 'rubocop'
|
41
|
-
spec.add_development_dependency 'rubocop-performance'
|
42
|
-
spec.add_development_dependency 'rubocop-
|
43
|
+
spec.add_development_dependency 'rubocop'
|
44
|
+
spec.add_development_dependency 'rubocop-performance'
|
45
|
+
spec.add_development_dependency 'rubocop-rake'
|
46
|
+
spec.add_development_dependency 'rubocop-rspec'
|
43
47
|
spec.add_development_dependency 'simplecov', '>= 0.18.5'
|
44
48
|
spec.add_development_dependency 'simplecov-console'
|
45
49
|
spec.add_development_dependency 'slim'
|
@@ -48,7 +52,6 @@ Gem::Specification.new do |spec|
|
|
48
52
|
|
49
53
|
spec.add_development_dependency 'spellr', '>= 0.8.1'
|
50
54
|
spec.add_dependency 'fast_ignore', '>= 0.15.1'
|
51
|
-
spec.add_dependency 'json_schemer'
|
52
55
|
spec.add_dependency 'parallel'
|
53
56
|
spec.add_dependency 'parser'
|
54
57
|
end
|
data/lib/config/actionmailer.yml
CHANGED
@@ -9,14 +9,14 @@ keep:
|
|
9
9
|
- delivered_email
|
10
10
|
|
11
11
|
dynamic:
|
12
|
-
names:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
names:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
- names:
|
13
|
+
- deliver_now
|
14
|
+
- deliver_later
|
15
|
+
calls:
|
16
|
+
value:
|
17
|
+
deliver
|
18
|
+
- names:
|
19
|
+
- before_action
|
20
|
+
- after_action
|
21
|
+
- around_action
|
22
|
+
calls: ['*', if, unless]
|
data/lib/config/actionpack.yml
CHANGED
@@ -73,8 +73,12 @@ dynamic:
|
|
73
73
|
- name:
|
74
74
|
- resource
|
75
75
|
- resources
|
76
|
+
has_argument: 0
|
76
77
|
calls:
|
77
78
|
- argument: only
|
79
|
+
- argument: only
|
80
|
+
nested:
|
81
|
+
argument: '*'
|
78
82
|
- argument: controller
|
79
83
|
camelize: true
|
80
84
|
add_suffix: Controller
|
@@ -82,6 +86,7 @@ dynamic:
|
|
82
86
|
- name:
|
83
87
|
- resource
|
84
88
|
- resources
|
89
|
+
has_argument: 0
|
85
90
|
unless:
|
86
91
|
has_argument:
|
87
92
|
- at: only
|
@@ -96,6 +101,7 @@ dynamic:
|
|
96
101
|
- name:
|
97
102
|
- resource
|
98
103
|
- resources
|
104
|
+
has_argument: 0
|
99
105
|
unless:
|
100
106
|
has_argument:
|
101
107
|
- at: only
|
@@ -110,6 +116,7 @@ dynamic:
|
|
110
116
|
- name:
|
111
117
|
- resource
|
112
118
|
- resources
|
119
|
+
has_argument: 0
|
113
120
|
unless:
|
114
121
|
has_argument:
|
115
122
|
- at: only
|
@@ -124,6 +131,7 @@ dynamic:
|
|
124
131
|
- name:
|
125
132
|
- resource
|
126
133
|
- resources
|
134
|
+
has_argument: 0
|
127
135
|
unless:
|
128
136
|
has_argument:
|
129
137
|
- at: only
|
@@ -138,6 +146,7 @@ dynamic:
|
|
138
146
|
- name:
|
139
147
|
- resource
|
140
148
|
- resources
|
149
|
+
has_argument: 0
|
141
150
|
unless:
|
142
151
|
has_argument:
|
143
152
|
- at: only
|
@@ -152,6 +161,7 @@ dynamic:
|
|
152
161
|
- name:
|
153
162
|
- resource
|
154
163
|
- resources
|
164
|
+
has_argument: 0
|
155
165
|
unless:
|
156
166
|
has_argument:
|
157
167
|
- at: only
|
@@ -165,6 +175,7 @@ dynamic:
|
|
165
175
|
- value: destroy
|
166
176
|
- name:
|
167
177
|
- resources
|
178
|
+
- resource
|
168
179
|
- controller
|
169
180
|
- namespace
|
170
181
|
calls:
|
@@ -2,7 +2,7 @@ requires:
|
|
2
2
|
- 'active_support'
|
3
3
|
- 'active_support/core_ext/string'
|
4
4
|
- 'active_support/inflections'
|
5
|
-
- './config/initializers/inflections'
|
5
|
+
- quiet: './config/initializers/inflections'
|
6
6
|
|
7
7
|
# THIS IS INCOMPLETE (you can help by expanding it)
|
8
8
|
# rails is _really complicated_ and has a lot of magic which calls methods for you.
|
data/lib/config/rails.yml
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
# some is currently impossible to handle (with_options).
|
4
4
|
# Some is just corners of rails I haven't hit yet.
|
5
5
|
gems:
|
6
|
-
- actioncable
|
7
6
|
- actionmailer
|
8
7
|
- actionpack
|
9
8
|
- actionview
|
@@ -11,6 +10,7 @@ gems:
|
|
11
10
|
- activemodel
|
12
11
|
- activerecord
|
13
12
|
- activesupport
|
13
|
+
- railties
|
14
14
|
|
15
15
|
keep:
|
16
16
|
- default_url_options # called by url_for, unsure what gem does
|
@@ -0,0 +1,11 @@
|
|
1
|
+
keep:
|
2
|
+
- # https://guides.rubyonrails.org/generators.html#generators-lookup
|
3
|
+
path: '**/generators/**/*_generator.rb'
|
4
|
+
# "When a generator is invoked, each public method in the generator is executed sequentially in
|
5
|
+
# the order that it is defined When a generator is invoked, each public method in the generator
|
6
|
+
# is executed sequentially in the order that it is defined"
|
7
|
+
#
|
8
|
+
# https://guides.rubyonrails.org/generators.html
|
9
|
+
privacy: public
|
10
|
+
type: Method
|
11
|
+
|
data/lib/config/ruby.yml
CHANGED
@@ -10,6 +10,13 @@ include_paths:
|
|
10
10
|
- '*.erb'
|
11
11
|
- '*.rb'
|
12
12
|
|
13
|
+
yaml_paths:
|
14
|
+
- '*.yml'
|
15
|
+
- '*.yaml'
|
16
|
+
|
17
|
+
json_paths:
|
18
|
+
- '*.json'
|
19
|
+
|
13
20
|
test_paths:
|
14
21
|
- /tests/
|
15
22
|
- /test/
|
@@ -91,3 +98,75 @@ dynamic:
|
|
91
98
|
- instance_variable_set
|
92
99
|
- class_variable_set
|
93
100
|
defines: 0
|
101
|
+
|
102
|
+
# Module
|
103
|
+
- name: public
|
104
|
+
unless:
|
105
|
+
has_argument: 0
|
106
|
+
set_default_privacy: public
|
107
|
+
|
108
|
+
- name:
|
109
|
+
- public
|
110
|
+
- public_class_method
|
111
|
+
- public_constant
|
112
|
+
has_argument: 0
|
113
|
+
set_privacy:
|
114
|
+
argument: '*'
|
115
|
+
to: public
|
116
|
+
|
117
|
+
- name:
|
118
|
+
- public
|
119
|
+
- public_class_method
|
120
|
+
has_argument: 0
|
121
|
+
unless:
|
122
|
+
has_argument: 1
|
123
|
+
set_privacy:
|
124
|
+
argument: 0
|
125
|
+
nested:
|
126
|
+
argument: '*'
|
127
|
+
to: public
|
128
|
+
|
129
|
+
- name: protected
|
130
|
+
unless:
|
131
|
+
has_argument: 0
|
132
|
+
set_default_privacy: protected
|
133
|
+
|
134
|
+
- name: protected
|
135
|
+
has_argument: 0
|
136
|
+
set_privacy:
|
137
|
+
argument: '*'
|
138
|
+
to: protected
|
139
|
+
|
140
|
+
- name: protected
|
141
|
+
has_argument: 0
|
142
|
+
unless:
|
143
|
+
has_argument: 1
|
144
|
+
set_privacy:
|
145
|
+
argument: 0
|
146
|
+
nested:
|
147
|
+
argument: '*'
|
148
|
+
to: protected
|
149
|
+
|
150
|
+
- name: private
|
151
|
+
unless:
|
152
|
+
has_argument: 0
|
153
|
+
set_default_privacy: private
|
154
|
+
|
155
|
+
- name:
|
156
|
+
- private
|
157
|
+
- private_class_method
|
158
|
+
- private_constant
|
159
|
+
has_argument: 0
|
160
|
+
set_privacy:
|
161
|
+
argument: '*'
|
162
|
+
to: private
|
163
|
+
|
164
|
+
- name: private
|
165
|
+
has_argument: 0
|
166
|
+
unless:
|
167
|
+
has_argument: 1
|
168
|
+
set_privacy:
|
169
|
+
argument: 0
|
170
|
+
nested:
|
171
|
+
argument: '*'
|
172
|
+
to: private
|