leftovers 0.5.5 → 0.6.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 +7 -0
- data/README.md +21 -1
- data/docs/Configuration.md +106 -2
- data/leftovers.gemspec +7 -4
- data/lib/config/ruby.yml +7 -0
- data/lib/leftovers/collector.rb +3 -1
- data/lib/leftovers/config.rb +8 -4
- data/lib/leftovers/config_validator/schema_hash.rb +170 -149
- data/lib/leftovers/config_validator.rb +1 -0
- data/lib/leftovers/definition.rb +1 -1
- data/lib/leftovers/dynamic_processors/call.rb +0 -4
- data/lib/leftovers/dynamic_processors/call_definition.rb +0 -4
- data/lib/leftovers/dynamic_processors/definition.rb +0 -4
- data/lib/leftovers/file.rb +52 -10
- data/lib/leftovers/file_collector.rb +33 -2
- data/lib/leftovers/json.rb +28 -0
- data/lib/leftovers/matcher_builders/document.rb +13 -0
- data/lib/leftovers/matcher_builders/node.rb +3 -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.rb +1 -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_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/merged_config.rb +19 -1
- data/lib/leftovers/processor_builders/dynamic.rb +2 -1
- 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/keyword.rb +0 -4
- data/lib/leftovers/value_processors/keyword_argument.rb +0 -4
- data/lib/leftovers/value_processors/return_definition.rb +0 -4
- data/lib/leftovers/version.rb +1 -1
- data/lib/leftovers/yaml.rb +73 -0
- data/lib/leftovers.rb +6 -7
- metadata +33 -16
- data/lib/leftovers/backports.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32e8f2762f7f513145ea799b64a059c7228dd7e9a4e08c2762abe92aad1370b1
|
4
|
+
data.tar.gz: 9134e7d5c66bcbb25bb5fba15f5b1bb661ce18972cf91e179f165af52f955662
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e361dc15e0a3496dadf81f91d356183631b1ad9f0b44951f976785622aa8550ccd0d8a6632064ab646a65231c4b772236cf1136b9267ceb81c59217d36bb4f78
|
7
|
+
data.tar.gz: d82fd190746370c9ead45a27e5a660f81aafadf58736afd644d5fafad816daa450f25eebcf30d18875b185ab7d76b3215a696ed35bb75ad33509a474cff87736
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 0.6.0
|
2
|
+
- drop ruby 2.4 support, allowing for some performance improvements
|
3
|
+
- Add ability to parse JSON and YAML files
|
4
|
+
- Add magic comment that points to a particular dynamic rule
|
5
|
+
- repeated calls to --write-todo won't have ordering differences
|
6
|
+
- fix issue with --write-todo and unused methods defined in test files
|
7
|
+
|
1
8
|
# 0.5.5
|
2
9
|
- Fix rails resource/resources method signatures
|
3
10
|
|
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)
|
@@ -117,6 +119,76 @@ erb_paths:
|
|
117
119
|
|
118
120
|
Arrays are not necessary for single values. `*.erb` is recognized by default
|
119
121
|
|
122
|
+
## `yaml_paths:`
|
123
|
+
|
124
|
+
list filenames/paths of test directories that are in the yaml format
|
125
|
+
Defined using the [.gitignore pattern format](https://git-scm.com/docs/gitignore#_pattern_format)
|
126
|
+
|
127
|
+
```yml
|
128
|
+
include:
|
129
|
+
- 'config/*.yml'
|
130
|
+
yaml_paths:
|
131
|
+
- '*.yml'
|
132
|
+
```
|
133
|
+
|
134
|
+
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.
|
135
|
+
|
136
|
+
so you could, e.g. read the class name out of a yaml document like:
|
137
|
+
|
138
|
+
```yml
|
139
|
+
class_name: MyClass
|
140
|
+
```
|
141
|
+
|
142
|
+
with config like:
|
143
|
+
|
144
|
+
```yml
|
145
|
+
include_paths:
|
146
|
+
- 'config/*.yml'
|
147
|
+
|
148
|
+
dynamic:
|
149
|
+
document: true
|
150
|
+
path: config/*.yml
|
151
|
+
calls:
|
152
|
+
argument: class_name
|
153
|
+
```
|
154
|
+
|
155
|
+
[`nested:`](#nested) may be useful for more complex yaml structures
|
156
|
+
|
157
|
+
## `json_paths:`
|
158
|
+
|
159
|
+
list filenames/paths of test directories that are in the json format
|
160
|
+
Defined using the [.gitignore pattern format](https://git-scm.com/docs/gitignore#_pattern_format)
|
161
|
+
|
162
|
+
```yml
|
163
|
+
include:
|
164
|
+
- 'config/*.json'
|
165
|
+
json_paths:
|
166
|
+
- '*.json'
|
167
|
+
```
|
168
|
+
|
169
|
+
These documents render the structure of the yaml as arguments for the [`document:true`](#document-true) rule.
|
170
|
+
|
171
|
+
so you could, e.g. read the class name out of a yaml document like:
|
172
|
+
|
173
|
+
```json
|
174
|
+
{ "class_name": "MyClass" }
|
175
|
+
```
|
176
|
+
|
177
|
+
with config like:
|
178
|
+
|
179
|
+
```yml
|
180
|
+
include_paths:
|
181
|
+
- 'config/*.json'
|
182
|
+
|
183
|
+
dynamic:
|
184
|
+
document: true
|
185
|
+
path: config/*.json
|
186
|
+
calls:
|
187
|
+
argument: class_name
|
188
|
+
```
|
189
|
+
|
190
|
+
[`nested:`](#nested) may be useful for more complex json structures
|
191
|
+
|
120
192
|
## `gems:`
|
121
193
|
_alias `gem:`_
|
122
194
|
|
@@ -202,7 +274,8 @@ Each entry must have at least one of the following properties to restrict which
|
|
202
274
|
- [`paths:`](#paths)
|
203
275
|
- [`has_arguments:`](#has_arguments)
|
204
276
|
- [`has_receiver:`](#has_receiver)
|
205
|
-
- [`unless
|
277
|
+
- [`unless:`](#unless)
|
278
|
+
- [`document: true`](#document-true)
|
206
279
|
|
207
280
|
And must have one or both of
|
208
281
|
- ['calls:`](#calls-defines)
|
@@ -299,6 +372,33 @@ keep:
|
|
299
372
|
path: /app/helpers
|
300
373
|
```
|
301
374
|
|
375
|
+
## `document: true`
|
376
|
+
|
377
|
+
Instructs to consider the whole document. this is useful when parsing [YAML](#yaml-paths) or [JSON](#json-paths) config files for various values.
|
378
|
+
|
379
|
+
e.g.
|
380
|
+
|
381
|
+
```yml
|
382
|
+
includes: /config/roles.yml
|
383
|
+
dynamic:
|
384
|
+
- document: true
|
385
|
+
path: /config/roles.yml
|
386
|
+
defines:
|
387
|
+
arguments: '*'
|
388
|
+
add_suffix: '?'
|
389
|
+
add_prefix: can_
|
390
|
+
```
|
391
|
+
|
392
|
+
will parse "config/roles.yml"
|
393
|
+
```yml
|
394
|
+
- build_house
|
395
|
+
- drive_car
|
396
|
+
```
|
397
|
+
|
398
|
+
and consider it to have created methods like `can_build_house?` and `can_drive_car?`
|
399
|
+
|
400
|
+
[`nested:`](#nested) may be useful for more complex data structures
|
401
|
+
|
302
402
|
## `calls:`, `defines:`
|
303
403
|
_aliases `call:`, `define:`_
|
304
404
|
|
@@ -366,7 +466,9 @@ It can have any of these properties:
|
|
366
466
|
- [`at:`](#at)
|
367
467
|
- [`has_value:`](#has_value_has_receiver)
|
368
468
|
|
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
|
469
|
+
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.
|
470
|
+
|
471
|
+
Positional arguments are zero indexed
|
370
472
|
|
371
473
|
## `has_arguments:`
|
372
474
|
_alias `has_argument:`_
|
@@ -384,6 +486,8 @@ It can have any of these properties:
|
|
384
486
|
|
385
487
|
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
488
|
|
489
|
+
Positional arguments are zero indexed
|
490
|
+
|
387
491
|
## `keywords:`
|
388
492
|
When the keyword argument **keywords** are the thing being called.
|
389
493
|
|
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
|
@@ -37,9 +39,10 @@ Gem::Specification.new do |spec|
|
|
37
39
|
spec.add_development_dependency 'pry', '~> 0.1'
|
38
40
|
spec.add_development_dependency 'rake', '>= 13'
|
39
41
|
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-
|
42
|
+
spec.add_development_dependency 'rubocop'
|
43
|
+
spec.add_development_dependency 'rubocop-performance'
|
44
|
+
spec.add_development_dependency 'rubocop-rake'
|
45
|
+
spec.add_development_dependency 'rubocop-rspec'
|
43
46
|
spec.add_development_dependency 'simplecov', '>= 0.18.5'
|
44
47
|
spec.add_development_dependency 'simplecov-console'
|
45
48
|
spec.add_development_dependency 'slim'
|
data/lib/config/ruby.yml
CHANGED
data/lib/leftovers/collector.rb
CHANGED
@@ -28,7 +28,9 @@ module Leftovers
|
|
28
28
|
|
29
29
|
def collect_file_list(list)
|
30
30
|
if Leftovers.parallel?
|
31
|
-
Parallel.each(list, finish: method(:finish_file)
|
31
|
+
Parallel.each(list, finish: method(:finish_file)) do |file|
|
32
|
+
collect_file(file)
|
33
|
+
end
|
32
34
|
else
|
33
35
|
list.each { |file| finish_file(nil, nil, collect_file(file)) }
|
34
36
|
end
|
data/lib/leftovers/config.rb
CHANGED
@@ -4,10 +4,6 @@ require 'yaml'
|
|
4
4
|
|
5
5
|
module Leftovers
|
6
6
|
class Config
|
7
|
-
# :nocov:
|
8
|
-
using ::Leftovers::Backports::SetCaseEq if defined?(::Leftovers::Backports::SetCaseEq)
|
9
|
-
# :nocov:
|
10
|
-
|
11
7
|
attr_reader :name
|
12
8
|
|
13
9
|
def initialize(name, path: nil, content: nil)
|
@@ -40,6 +36,14 @@ module Leftovers
|
|
40
36
|
@slim_paths ||= Array(yaml[:slim_paths])
|
41
37
|
end
|
42
38
|
|
39
|
+
def yaml_paths
|
40
|
+
@yaml_paths ||= Array(yaml[:yaml_paths])
|
41
|
+
end
|
42
|
+
|
43
|
+
def json_paths
|
44
|
+
@json_paths ||= Array(yaml[:json_paths])
|
45
|
+
end
|
46
|
+
|
43
47
|
def erb_paths
|
44
48
|
@erb_paths ||= Array(yaml[:erb_paths])
|
45
49
|
end
|