leftovers 0.5.5 → 0.8.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 +40 -2
- data/README.md +22 -1
- data/docs/Configuration.md +173 -42
- data/docs/Custom-Precompilers.md +38 -0
- data/leftovers.gemspec +8 -5
- data/lib/config/actionmailer.yml +11 -11
- data/lib/config/actionpack.yml +5 -3
- data/lib/config/activesupport.yml +1 -1
- data/lib/config/haml.yml +4 -2
- data/lib/config/rails.yml +1 -1
- data/lib/config/railties.yml +11 -0
- data/lib/config/ruby.yml +76 -8
- data/lib/config/slim.yml +4 -2
- data/lib/leftovers/ast/node.rb +16 -11
- data/lib/leftovers/cli.rb +5 -0
- data/lib/leftovers/collector.rb +5 -2
- data/lib/leftovers/config.rb +3 -38
- 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 +56 -0
- data/lib/leftovers/config_loader/built_in_precompiler_schema.rb +13 -0
- data/lib/leftovers/config_loader/document_schema.rb +48 -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/inherit_schema_attributes.rb +22 -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 +117 -0
- data/lib/leftovers/config_loader/precompile_schema.rb +12 -0
- data/lib/leftovers/config_loader/precompiler_schema.rb +11 -0
- data/lib/leftovers/config_loader/privacy_processor_schema.rb +10 -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 +23 -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 +26 -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 +66 -0
- data/lib/leftovers/config_loader/value_or_object_schema.rb +40 -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 +86 -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 +12 -12
- data/lib/leftovers/file_collector/comments_processor.rb +57 -0
- data/lib/leftovers/file_collector/node_processor.rb +131 -0
- data/lib/leftovers/file_collector.rb +66 -169
- data/lib/leftovers/matcher_builders/and_not.rb +7 -5
- data/lib/leftovers/matcher_builders/document.rb +13 -0
- data/lib/leftovers/matcher_builders/name.rb +18 -17
- data/lib/leftovers/matcher_builders/node.rb +48 -28
- data/lib/leftovers/matcher_builders/node_has_argument.rb +48 -53
- data/lib/leftovers/matcher_builders/node_has_keyword_argument.rb +13 -10
- data/lib/leftovers/matcher_builders/node_has_positional_argument.rb +29 -15
- 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 +28 -23
- data/lib/leftovers/matcher_builders/or.rb +50 -50
- 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 +15 -33
- data/lib/leftovers/precompilers/erb.rb +22 -0
- data/lib/leftovers/precompilers/haml.rb +15 -0
- data/lib/leftovers/precompilers/json.rb +27 -0
- data/lib/leftovers/precompilers/precompiler.rb +28 -0
- data/lib/leftovers/precompilers/slim.rb +15 -0
- data/lib/leftovers/precompilers/yaml.rb +75 -0
- data/lib/leftovers/precompilers.rb +50 -0
- data/lib/leftovers/processor_builders/action.rb +48 -39
- data/lib/leftovers/processor_builders/add_prefix.rb +2 -2
- data/lib/leftovers/processor_builders/add_suffix.rb +2 -2
- data/lib/leftovers/processor_builders/argument.rb +8 -11
- data/lib/leftovers/processor_builders/dynamic.rb +51 -16
- data/lib/leftovers/processor_builders/each.rb +2 -2
- data/lib/leftovers/processor_builders/each_action.rb +33 -33
- data/lib/leftovers/processor_builders/each_dynamic.rb +4 -8
- data/lib/leftovers/processor_builders/each_for_definition_set.rb +25 -21
- data/lib/leftovers/processor_builders/keyword.rb +3 -4
- data/lib/leftovers/processor_builders/transform.rb +4 -4
- data/lib/leftovers/processor_builders/transform_chain.rb +16 -8
- data/lib/leftovers/processor_builders/transform_set.rb +32 -28
- data/lib/leftovers/rake_task.rb +1 -1
- data/lib/leftovers/todo_reporter.rb +10 -35
- data/lib/leftovers/value_processors/add_dynamic_prefix.rb +3 -10
- data/lib/leftovers/value_processors/add_dynamic_suffix.rb +3 -10
- 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.rb +1 -1
- data/lib/leftovers/value_processors/each_for_definition_set.rb +4 -10
- data/lib/leftovers/value_processors/each_keyword.rb +1 -1
- data/lib/leftovers/value_processors/each_keyword_argument.rb +1 -1
- data/lib/leftovers/value_processors/each_positional_argument.rb +3 -2
- data/lib/leftovers/value_processors/keyword.rb +3 -11
- data/lib/leftovers/value_processors/keyword_argument.rb +2 -10
- 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/split.rb +2 -2
- data/lib/leftovers/value_processors.rb +2 -2
- data/lib/leftovers/version.rb +1 -1
- data/lib/leftovers.rb +66 -23
- metadata +98 -39
- 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/erb.rb +0 -20
- data/lib/leftovers/haml.rb +0 -21
- data/lib/leftovers/slim.rb +0 -21
- data/lib/leftovers/value_processors/return_definition.rb +0 -26
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.8.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-02-
|
11
|
+
date: 2022-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: did_you_mean
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: haml
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,44 +126,58 @@ dependencies:
|
|
112
126
|
name: rubocop
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- - "
|
129
|
+
- - ">="
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0
|
131
|
+
version: '0'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- - "
|
136
|
+
- - ">="
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: rubocop-performance
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
|
-
- - "
|
143
|
+
- - ">="
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
145
|
+
version: '0'
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
|
-
- - "
|
150
|
+
- - ">="
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop-rake
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
139
167
|
- !ruby/object:Gem::Dependency
|
140
168
|
name: rubocop-rspec
|
141
169
|
requirement: !ruby/object:Gem::Requirement
|
142
170
|
requirements:
|
143
|
-
- - "
|
171
|
+
- - ">="
|
144
172
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
173
|
+
version: '0'
|
146
174
|
type: :development
|
147
175
|
prerelease: false
|
148
176
|
version_requirements: !ruby/object:Gem::Requirement
|
149
177
|
requirements:
|
150
|
-
- - "
|
178
|
+
- - ">="
|
151
179
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
180
|
+
version: '0'
|
153
181
|
- !ruby/object:Gem::Dependency
|
154
182
|
name: simplecov
|
155
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -248,20 +276,6 @@ dependencies:
|
|
248
276
|
- - ">="
|
249
277
|
- !ruby/object:Gem::Version
|
250
278
|
version: 0.15.1
|
251
|
-
- !ruby/object:Gem::Dependency
|
252
|
-
name: json_schemer
|
253
|
-
requirement: !ruby/object:Gem::Requirement
|
254
|
-
requirements:
|
255
|
-
- - ">="
|
256
|
-
- !ruby/object:Gem::Version
|
257
|
-
version: '0'
|
258
|
-
type: :runtime
|
259
|
-
prerelease: false
|
260
|
-
version_requirements: !ruby/object:Gem::Requirement
|
261
|
-
requirements:
|
262
|
-
- - ">="
|
263
|
-
- !ruby/object:Gem::Version
|
264
|
-
version: '0'
|
265
279
|
- !ruby/object:Gem::Dependency
|
266
280
|
name: parallel
|
267
281
|
requirement: !ruby/object:Gem::Requirement
|
@@ -303,10 +317,10 @@ files:
|
|
303
317
|
- LICENSE.txt
|
304
318
|
- README.md
|
305
319
|
- docs/Configuration.md
|
320
|
+
- docs/Custom-Precompilers.md
|
306
321
|
- exe/leftovers
|
307
322
|
- leftovers.gemspec
|
308
323
|
- lib/.DS_Store
|
309
|
-
- lib/config/actioncable.yml
|
310
324
|
- lib/config/actionmailer.yml
|
311
325
|
- lib/config/actionpack.yml
|
312
326
|
- lib/config/actionview.yml
|
@@ -329,6 +343,7 @@ files:
|
|
329
343
|
- lib/config/pry.yml
|
330
344
|
- lib/config/rack.yml
|
331
345
|
- lib/config/rails.yml
|
346
|
+
- lib/config/railties.yml
|
332
347
|
- lib/config/rake.yml
|
333
348
|
- lib/config/redcarpet.yml
|
334
349
|
- lib/config/rollbar.yml
|
@@ -343,30 +358,65 @@ files:
|
|
343
358
|
- lib/leftovers/ast.rb
|
344
359
|
- lib/leftovers/ast/builder.rb
|
345
360
|
- lib/leftovers/ast/node.rb
|
346
|
-
- lib/leftovers/backports.rb
|
347
361
|
- lib/leftovers/cli.rb
|
348
362
|
- lib/leftovers/collector.rb
|
349
363
|
- lib/leftovers/config.rb
|
350
|
-
- lib/leftovers/
|
351
|
-
- lib/leftovers/
|
352
|
-
- lib/leftovers/
|
364
|
+
- lib/leftovers/config_loader.rb
|
365
|
+
- lib/leftovers/config_loader/argument_position_schema.rb
|
366
|
+
- lib/leftovers/config_loader/argumentless_transform_schema.rb
|
367
|
+
- lib/leftovers/config_loader/attribute.rb
|
368
|
+
- lib/leftovers/config_loader/built_in_precompiler_schema.rb
|
369
|
+
- lib/leftovers/config_loader/document_schema.rb
|
370
|
+
- lib/leftovers/config_loader/dynamic_schema.rb
|
371
|
+
- lib/leftovers/config_loader/has_argument_schema.rb
|
372
|
+
- lib/leftovers/config_loader/has_value_schema.rb
|
373
|
+
- lib/leftovers/config_loader/inherit_schema_attributes.rb
|
374
|
+
- lib/leftovers/config_loader/keep_test_only_schema.rb
|
375
|
+
- lib/leftovers/config_loader/node.rb
|
376
|
+
- lib/leftovers/config_loader/object_schema.rb
|
377
|
+
- lib/leftovers/config_loader/precompile_schema.rb
|
378
|
+
- lib/leftovers/config_loader/precompiler_schema.rb
|
379
|
+
- lib/leftovers/config_loader/privacy_processor_schema.rb
|
380
|
+
- lib/leftovers/config_loader/privacy_schema.rb
|
381
|
+
- lib/leftovers/config_loader/require_schema.rb
|
382
|
+
- lib/leftovers/config_loader/rule_pattern_schema.rb
|
383
|
+
- lib/leftovers/config_loader/scalar_argument_schema.rb
|
384
|
+
- lib/leftovers/config_loader/scalar_value_schema.rb
|
385
|
+
- lib/leftovers/config_loader/schema.rb
|
386
|
+
- lib/leftovers/config_loader/string_enum_schema.rb
|
387
|
+
- lib/leftovers/config_loader/string_pattern_schema.rb
|
388
|
+
- lib/leftovers/config_loader/string_schema.rb
|
389
|
+
- lib/leftovers/config_loader/string_value_processor_schema.rb
|
390
|
+
- lib/leftovers/config_loader/suggester.rb
|
391
|
+
- lib/leftovers/config_loader/transform_schema.rb
|
392
|
+
- lib/leftovers/config_loader/true_schema.rb
|
393
|
+
- lib/leftovers/config_loader/value_matcher_schema.rb
|
394
|
+
- lib/leftovers/config_loader/value_or_array_schema.rb
|
395
|
+
- lib/leftovers/config_loader/value_or_object_schema.rb
|
396
|
+
- lib/leftovers/config_loader/value_processor_schema.rb
|
397
|
+
- lib/leftovers/config_loader/value_type_schema.rb
|
353
398
|
- lib/leftovers/definition.rb
|
354
399
|
- lib/leftovers/definition_node.rb
|
400
|
+
- lib/leftovers/definition_node_set.rb
|
355
401
|
- lib/leftovers/definition_set.rb
|
402
|
+
- lib/leftovers/definition_to_add.rb
|
356
403
|
- lib/leftovers/dynamic_processors.rb
|
357
404
|
- lib/leftovers/dynamic_processors/call.rb
|
358
405
|
- lib/leftovers/dynamic_processors/call_definition.rb
|
359
406
|
- lib/leftovers/dynamic_processors/definition.rb
|
360
407
|
- lib/leftovers/dynamic_processors/each.rb
|
361
408
|
- lib/leftovers/dynamic_processors/null.rb
|
362
|
-
- lib/leftovers/
|
409
|
+
- lib/leftovers/dynamic_processors/set_default_privacy.rb
|
410
|
+
- lib/leftovers/dynamic_processors/set_privacy.rb
|
363
411
|
- lib/leftovers/file.rb
|
364
412
|
- lib/leftovers/file_collector.rb
|
413
|
+
- lib/leftovers/file_collector/comments_processor.rb
|
414
|
+
- lib/leftovers/file_collector/node_processor.rb
|
365
415
|
- lib/leftovers/file_list.rb
|
366
|
-
- lib/leftovers/haml.rb
|
367
416
|
- lib/leftovers/matcher_builders.rb
|
368
417
|
- lib/leftovers/matcher_builders/and.rb
|
369
418
|
- lib/leftovers/matcher_builders/and_not.rb
|
419
|
+
- lib/leftovers/matcher_builders/document.rb
|
370
420
|
- lib/leftovers/matcher_builders/name.rb
|
371
421
|
- lib/leftovers/matcher_builders/node.rb
|
372
422
|
- lib/leftovers/matcher_builders/node_has_argument.rb
|
@@ -377,6 +427,7 @@ files:
|
|
377
427
|
- lib/leftovers/matcher_builders/node_pair_name.rb
|
378
428
|
- lib/leftovers/matcher_builders/node_pair_value.rb
|
379
429
|
- lib/leftovers/matcher_builders/node_path.rb
|
430
|
+
- lib/leftovers/matcher_builders/node_privacy.rb
|
380
431
|
- lib/leftovers/matcher_builders/node_type.rb
|
381
432
|
- lib/leftovers/matcher_builders/node_value.rb
|
382
433
|
- lib/leftovers/matcher_builders/or.rb
|
@@ -396,6 +447,7 @@ files:
|
|
396
447
|
- lib/leftovers/matchers/node_name.rb
|
397
448
|
- lib/leftovers/matchers/node_pair_value.rb
|
398
449
|
- lib/leftovers/matchers/node_path.rb
|
450
|
+
- lib/leftovers/matchers/node_privacy.rb
|
399
451
|
- lib/leftovers/matchers/node_scalar_value.rb
|
400
452
|
- lib/leftovers/matchers/node_type.rb
|
401
453
|
- lib/leftovers/matchers/not.rb
|
@@ -403,6 +455,13 @@ files:
|
|
403
455
|
- lib/leftovers/matchers/predicate.rb
|
404
456
|
- lib/leftovers/merged_config.rb
|
405
457
|
- lib/leftovers/parser.rb
|
458
|
+
- lib/leftovers/precompilers.rb
|
459
|
+
- lib/leftovers/precompilers/erb.rb
|
460
|
+
- lib/leftovers/precompilers/haml.rb
|
461
|
+
- lib/leftovers/precompilers/json.rb
|
462
|
+
- lib/leftovers/precompilers/precompiler.rb
|
463
|
+
- lib/leftovers/precompilers/slim.rb
|
464
|
+
- lib/leftovers/precompilers/yaml.rb
|
406
465
|
- lib/leftovers/processor_builders.rb
|
407
466
|
- lib/leftovers/processor_builders/action.rb
|
408
467
|
- lib/leftovers/processor_builders/add_prefix.rb
|
@@ -422,7 +481,6 @@ files:
|
|
422
481
|
- lib/leftovers/processor_builders/value.rb
|
423
482
|
- lib/leftovers/rake_task.rb
|
424
483
|
- lib/leftovers/reporter.rb
|
425
|
-
- lib/leftovers/slim.rb
|
426
484
|
- lib/leftovers/todo_reporter.rb
|
427
485
|
- lib/leftovers/value_processors.rb
|
428
486
|
- lib/leftovers/value_processors/add_dynamic_prefix.rb
|
@@ -451,8 +509,8 @@ files:
|
|
451
509
|
- lib/leftovers/value_processors/pluralize.rb
|
452
510
|
- lib/leftovers/value_processors/positional_argument.rb
|
453
511
|
- lib/leftovers/value_processors/replace_value.rb
|
454
|
-
- lib/leftovers/value_processors/
|
455
|
-
- lib/leftovers/value_processors/
|
512
|
+
- lib/leftovers/value_processors/return_definition_node.rb
|
513
|
+
- lib/leftovers/value_processors/return_sym.rb
|
456
514
|
- lib/leftovers/value_processors/singularize.rb
|
457
515
|
- lib/leftovers/value_processors/split.rb
|
458
516
|
- lib/leftovers/value_processors/swapcase.rb
|
@@ -467,6 +525,7 @@ metadata:
|
|
467
525
|
homepage_uri: http://github.com/robotdana/leftovers
|
468
526
|
source_code_uri: http://github.com/robotdana/leftovers
|
469
527
|
changelog_uri: http://github.com/robotdana/leftovers/blob/main/CHANGELOG.md
|
528
|
+
rubygems_mfa_required: 'true'
|
470
529
|
post_install_message:
|
471
530
|
rdoc_options: []
|
472
531
|
require_paths:
|
@@ -475,7 +534,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
475
534
|
requirements:
|
476
535
|
- - ">="
|
477
536
|
- !ruby/object:Gem::Version
|
478
|
-
version: 2.
|
537
|
+
version: 2.5.0
|
479
538
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
480
539
|
requirements:
|
481
540
|
- - ">="
|
data/lib/config/actioncable.yml
DELETED
data/lib/leftovers/backports.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Leftovers
|
4
|
-
module Backports
|
5
|
-
ruby_version = Gem::Version.new(RUBY_VERSION)
|
6
|
-
|
7
|
-
unless ruby_version >= Gem::Version.new('2.5')
|
8
|
-
require 'set'
|
9
|
-
module SetCaseEq
|
10
|
-
refine ::Set do
|
11
|
-
def ===(value)
|
12
|
-
include?(value)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
module StringDeletePrefixSuffix
|
18
|
-
refine ::String do
|
19
|
-
def delete_prefix!(str)
|
20
|
-
slice!(0..(str.length - 1)) if start_with?(str)
|
21
|
-
self
|
22
|
-
end
|
23
|
-
|
24
|
-
def delete_suffix!(str)
|
25
|
-
slice!(-str.length..-1) if end_with?(str)
|
26
|
-
self
|
27
|
-
end
|
28
|
-
|
29
|
-
def delete_prefix(str)
|
30
|
-
dup.delete_prefix!(str)
|
31
|
-
end
|
32
|
-
|
33
|
-
def delete_suffix(str)
|
34
|
-
dup.delete_suffix!(str)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,196 +0,0 @@
|
|
1
|
-
# frozen-string-literal: true
|
2
|
-
|
3
|
-
::Leftovers.try_require 'did_you_mean'
|
4
|
-
|
5
|
-
module Leftovers
|
6
|
-
module ConfigValidator
|
7
|
-
module ErrorProcessor # rubocop:disable Metrics/ModuleLength
|
8
|
-
LENGTH_TYPE = %w{minItems minLength minProperties}.freeze
|
9
|
-
TYPE_TYPE = %w{null string boolean integer number array object}.freeze
|
10
|
-
VALUE_TYPE = %w{enum const}.freeze
|
11
|
-
REQUIRED_TYPE = %w{required}.freeze
|
12
|
-
|
13
|
-
class << self
|
14
|
-
def process(errors) # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize
|
15
|
-
error_data_pointers = []
|
16
|
-
errors = group_errors(errors)
|
17
|
-
errors.flat_map do |data_pointer, error_group| # rubocop:disable Metrics/BlockLength
|
18
|
-
next if error_data_pointers.find { |x| x.start_with?(data_pointer) }
|
19
|
-
|
20
|
-
# original_error_group = error_group.dup
|
21
|
-
length_errors = error_group.select { |x| LENGTH_TYPE.include?(x['type']) }
|
22
|
-
value_errors = error_group.select { |x| VALUE_TYPE.include?(x['type']) }
|
23
|
-
type_errors = error_group.select { |x| TYPE_TYPE.include?(x['type']) }
|
24
|
-
required_errors = error_group.select { |x| REQUIRED_TYPE.include?(x['type']) }
|
25
|
-
messages = []
|
26
|
-
|
27
|
-
if !type_errors.empty? && (error_group - type_errors).empty?
|
28
|
-
error_group -= type_errors
|
29
|
-
error_data_pointers << data_pointer
|
30
|
-
any_of = group_by_same_any_of(type_errors)
|
31
|
-
if any_of.length == 1
|
32
|
-
was_class = to_json_type(type_errors.first['data'])
|
33
|
-
error_types = type_errors.map { |x| x['type'] }
|
34
|
-
|
35
|
-
messages << <<~MESSAGE.chomp
|
36
|
-
#{data_pointer}: must be #{an to_sentence(error_types, 'or')} (was #{an was_class})
|
37
|
-
MESSAGE
|
38
|
-
# :nocov:
|
39
|
-
else
|
40
|
-
nil
|
41
|
-
# :nocov:
|
42
|
-
end
|
43
|
-
elsif !required_errors.empty? && error_group.first['data'].is_a?(Hash)
|
44
|
-
error_data_pointers << data_pointer
|
45
|
-
group_by_same_any_of(required_errors).each do |_any_of_key, any_of_value|
|
46
|
-
required_keywords = any_of_value.flat_map { |x| x['details']['missing_keys'] }
|
47
|
-
error_group -= any_of_value
|
48
|
-
if any_of_value.length > 1
|
49
|
-
messages << <<~MESSAGE
|
50
|
-
#{data_pointer}: requires at least one of these keywords: #{to_sentence(required_keywords, 'or')}
|
51
|
-
MESSAGE
|
52
|
-
|
53
|
-
# :nocov:
|
54
|
-
else
|
55
|
-
nil
|
56
|
-
# :nocov:
|
57
|
-
# messages << "#{data_pointer}: requires keyword: #{required_keywords.first}"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
elsif !length_errors.empty?
|
61
|
-
error_data_pointers << data_pointer
|
62
|
-
messages << "#{data_pointer}: can't be empty"
|
63
|
-
end
|
64
|
-
|
65
|
-
error_group.each do |error| # rubocop:disable Metrics/BlockLength
|
66
|
-
type = error['type']
|
67
|
-
case type
|
68
|
-
when 'schema'
|
69
|
-
error_data_pointers << data_pointer
|
70
|
-
parent_pointer = parent(data_pointer)
|
71
|
-
if ::File.basename(error['schema_pointer']) == 'additionalProperties'
|
72
|
-
keyword = tail(data_pointer)
|
73
|
-
parent_schema_pointer = parent(error['schema_pointer'])
|
74
|
-
actual_keywords = schema_hash_dig(parent_schema_pointer)['properties'].keys
|
75
|
-
corrections = did_you_mean(keyword, actual_keywords)
|
76
|
-
|
77
|
-
messages << <<~MESSAGE.chomp
|
78
|
-
#{parent_pointer}: invalid property keyword: #{keyword}
|
79
|
-
Valid keywords: #{to_sentence actual_keywords}
|
80
|
-
#{"Did you mean? #{to_sentence corrections, 'or'}" unless corrections.empty?}
|
81
|
-
MESSAGE
|
82
|
-
# :nocov:
|
83
|
-
else
|
84
|
-
nil
|
85
|
-
# :nocov:
|
86
|
-
end
|
87
|
-
when 'enum'
|
88
|
-
next if error['data'].is_a?(Hash)
|
89
|
-
|
90
|
-
error_data_pointers << data_pointer
|
91
|
-
given_value = error['data']
|
92
|
-
valid_values = value_errors.first['schema']['enum']
|
93
|
-
corrections = did_you_mean(given_value, valid_values)
|
94
|
-
messages << <<~MESSAGE
|
95
|
-
#{data_pointer}: can't be: #{given_value}
|
96
|
-
Valid values: #{to_sentence valid_values, 'or'}
|
97
|
-
#{"Did you mean? #{to_sentence corrections, 'or'}" unless corrections.empty?}
|
98
|
-
MESSAGE
|
99
|
-
when 'not'
|
100
|
-
next unless error['data'].is_a?(Hash)
|
101
|
-
|
102
|
-
error_data_pointers << data_pointer
|
103
|
-
if error['schema']['required']
|
104
|
-
invalid_combinations = error['schema']['required'] & error['data'].keys
|
105
|
-
messages << <<~MESSAGE
|
106
|
-
#{data_pointer}: use only one of: #{to_sentence invalid_combinations, 'or'}
|
107
|
-
MESSAGE
|
108
|
-
# :nocov:
|
109
|
-
else
|
110
|
-
end
|
111
|
-
else
|
112
|
-
end
|
113
|
-
# :nocov:
|
114
|
-
end
|
115
|
-
|
116
|
-
if messages.empty?
|
117
|
-
error_data_pointers << data_pointer
|
118
|
-
"#{data_pointer} is invalid"
|
119
|
-
else
|
120
|
-
messages
|
121
|
-
end
|
122
|
-
end.compact.map(&:strip)
|
123
|
-
end
|
124
|
-
|
125
|
-
private
|
126
|
-
|
127
|
-
def did_you_mean(word, dictionary)
|
128
|
-
# :nocov:
|
129
|
-
if defined?(::DidYouMean::SpellChecker)
|
130
|
-
::DidYouMean::SpellChecker.new(dictionary: dictionary).correct(word)
|
131
|
-
else
|
132
|
-
[]
|
133
|
-
end
|
134
|
-
# :nocov:
|
135
|
-
end
|
136
|
-
|
137
|
-
def schema_hash_dig(schema_pointer)
|
138
|
-
::Leftovers::ConfigValidator::SCHEMA_HASH.dig(
|
139
|
-
*schema_pointer.split('/').drop(1).map { |x| x.match?(/\A\d+\z/) ? x.to_i : x }
|
140
|
-
)
|
141
|
-
end
|
142
|
-
|
143
|
-
def parent(pointer)
|
144
|
-
::File.dirname(pointer)
|
145
|
-
end
|
146
|
-
|
147
|
-
def tail(pointer)
|
148
|
-
::File.basename(pointer)
|
149
|
-
end
|
150
|
-
|
151
|
-
def to_json_type(value)
|
152
|
-
case value
|
153
|
-
when Hash then 'object'
|
154
|
-
when Float then 'number'
|
155
|
-
when true, false then 'boolean'
|
156
|
-
when nil then 'null'
|
157
|
-
else value.class.name.downcase
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
def an(str)
|
162
|
-
case str[0]
|
163
|
-
# when nil then ""
|
164
|
-
when 'a', 'e', 'i', 'o', 'u' then "an #{str}"
|
165
|
-
else "a #{str}"
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
def to_sentence(ary, join_word = 'and')
|
170
|
-
case ary.length
|
171
|
-
when 1 then ary.first
|
172
|
-
when 2 then ary.join(" #{join_word} ")
|
173
|
-
else
|
174
|
-
ary = ary.dup
|
175
|
-
last = ary.pop(2)
|
176
|
-
[*ary, last.join(", #{join_word} ")].join(', ')
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
def group_errors(errors)
|
181
|
-
errors = errors.map do |x|
|
182
|
-
x.delete('root_schema')
|
183
|
-
x
|
184
|
-
end
|
185
|
-
errors.group_by { |x| x['data_pointer'] }.sort.reverse.to_h
|
186
|
-
end
|
187
|
-
|
188
|
-
def group_by_same_any_of(errors)
|
189
|
-
errors.group_by do |x|
|
190
|
-
x['schema_pointer'].match?(%r{/anyOf/\d+$}) && parent(parent(x['schema_pointer']))
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|