leftovers 0.2.3 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -0
  3. data/README.md +65 -49
  4. data/docs/Configuration.md +627 -0
  5. data/exe/leftovers +2 -2
  6. data/leftovers.gemspec +13 -6
  7. data/lib/config/attr_encrypted.yml +3 -4
  8. data/lib/config/audited.yml +9 -4
  9. data/lib/config/datagrid.yml +1 -1
  10. data/lib/config/flipper.yml +1 -3
  11. data/lib/config/graphql.yml +15 -13
  12. data/lib/config/okcomputer.yml +1 -3
  13. data/lib/config/parser.yml +89 -91
  14. data/lib/config/rails.yml +126 -107
  15. data/lib/config/redcarpet.yml +35 -38
  16. data/lib/config/rollbar.yml +1 -3
  17. data/lib/config/rspec.yml +18 -10
  18. data/lib/config/ruby.yml +42 -49
  19. data/lib/config/selenium-webdriver.yml +19 -0
  20. data/lib/config/sidekiq.yml +4 -8
  21. data/lib/config/will_paginate.yml +12 -14
  22. data/lib/leftovers.rb +66 -54
  23. data/lib/leftovers/ast.rb +8 -0
  24. data/lib/leftovers/ast/builder.rb +6 -3
  25. data/lib/leftovers/ast/node.rb +66 -107
  26. data/lib/leftovers/backports.rb +24 -40
  27. data/lib/leftovers/cli.rb +27 -15
  28. data/lib/leftovers/collector.rb +8 -11
  29. data/lib/leftovers/config.rb +38 -13
  30. data/lib/leftovers/config_validator.rb +60 -0
  31. data/lib/leftovers/config_validator/error_processor.rb +196 -0
  32. data/lib/leftovers/config_validator/schema_hash.rb +496 -0
  33. data/lib/leftovers/definition.rb +16 -41
  34. data/lib/leftovers/definition_node.rb +36 -0
  35. data/lib/leftovers/definition_set.rb +17 -24
  36. data/lib/leftovers/dynamic_processors.rb +11 -0
  37. data/lib/leftovers/dynamic_processors/call.rb +25 -0
  38. data/lib/leftovers/dynamic_processors/call_definition.rb +31 -0
  39. data/lib/leftovers/dynamic_processors/definition.rb +26 -0
  40. data/lib/leftovers/dynamic_processors/each.rb +19 -0
  41. data/lib/leftovers/dynamic_processors/null.rb +9 -0
  42. data/lib/leftovers/erb.rb +2 -2
  43. data/lib/leftovers/file.rb +3 -5
  44. data/lib/leftovers/file_collector.rb +79 -61
  45. data/lib/leftovers/file_list.rb +9 -15
  46. data/lib/leftovers/haml.rb +9 -12
  47. data/lib/leftovers/matcher_builders.rb +24 -0
  48. data/lib/leftovers/matcher_builders/and.rb +19 -0
  49. data/lib/leftovers/matcher_builders/and_not.rb +14 -0
  50. data/lib/leftovers/matcher_builders/argument_node_value.rb +21 -0
  51. data/lib/leftovers/matcher_builders/name.rb +29 -0
  52. data/lib/leftovers/matcher_builders/node.rb +40 -0
  53. data/lib/leftovers/matcher_builders/node_has_argument.rb +71 -0
  54. data/lib/leftovers/matcher_builders/node_has_keyword_argument.rb +22 -0
  55. data/lib/leftovers/matcher_builders/node_has_positional_argument.rb +24 -0
  56. data/lib/leftovers/matcher_builders/node_name.rb +15 -0
  57. data/lib/leftovers/matcher_builders/node_pair_name.rb +18 -0
  58. data/lib/leftovers/matcher_builders/node_pair_value.rb +16 -0
  59. data/lib/leftovers/matcher_builders/node_path.rb +14 -0
  60. data/lib/leftovers/matcher_builders/node_type.rb +28 -0
  61. data/lib/leftovers/matcher_builders/or.rb +73 -0
  62. data/lib/leftovers/matcher_builders/path.rb +15 -0
  63. data/lib/leftovers/matcher_builders/string.rb +11 -0
  64. data/lib/leftovers/matcher_builders/string_pattern.rb +19 -0
  65. data/lib/leftovers/matcher_builders/unless.rb +13 -0
  66. data/lib/leftovers/matchers.rb +26 -0
  67. data/lib/leftovers/matchers/all.rb +25 -0
  68. data/lib/leftovers/matchers/and.rb +24 -0
  69. data/lib/leftovers/matchers/any.rb +27 -0
  70. data/lib/leftovers/matchers/node_has_any_keyword_argument.rb +28 -0
  71. data/lib/leftovers/matchers/node_has_any_positional_argument_with_value.rb +25 -0
  72. data/lib/leftovers/matchers/node_has_positional_argument.rb +23 -0
  73. data/lib/leftovers/matchers/node_has_positional_argument_with_value.rb +25 -0
  74. data/lib/leftovers/matchers/node_name.rb +23 -0
  75. data/lib/leftovers/matchers/node_pair_value.rb +23 -0
  76. data/lib/leftovers/matchers/node_path.rb +23 -0
  77. data/lib/leftovers/matchers/node_scalar_value.rb +25 -0
  78. data/lib/leftovers/matchers/node_type.rb +23 -0
  79. data/lib/leftovers/matchers/not.rb +23 -0
  80. data/lib/leftovers/matchers/or.rb +26 -0
  81. data/lib/leftovers/merged_config.rb +29 -14
  82. data/lib/leftovers/parser.rb +1 -4
  83. data/lib/leftovers/processor_builders.rb +22 -0
  84. data/lib/leftovers/processor_builders/action.rb +63 -0
  85. data/lib/leftovers/processor_builders/add_prefix.rb +20 -0
  86. data/lib/leftovers/processor_builders/add_suffix.rb +20 -0
  87. data/lib/leftovers/processor_builders/argument.rb +25 -0
  88. data/lib/leftovers/processor_builders/dynamic.rb +27 -0
  89. data/lib/leftovers/processor_builders/each.rb +36 -0
  90. data/lib/leftovers/processor_builders/each_action.rb +51 -0
  91. data/lib/leftovers/processor_builders/each_dynamic.rb +54 -0
  92. data/lib/leftovers/processor_builders/each_for_definition_set.rb +36 -0
  93. data/lib/leftovers/processor_builders/itself.rb +13 -0
  94. data/lib/leftovers/processor_builders/keyword.rb +24 -0
  95. data/lib/leftovers/processor_builders/keyword_argument.rb +14 -0
  96. data/lib/leftovers/processor_builders/transform.rb +55 -0
  97. data/lib/leftovers/processor_builders/transform_chain.rb +24 -0
  98. data/lib/leftovers/processor_builders/transform_set.rb +47 -0
  99. data/lib/leftovers/processor_builders/value.rb +13 -0
  100. data/lib/leftovers/rake_task.rb +4 -4
  101. data/lib/leftovers/reporter.rb +56 -4
  102. data/lib/leftovers/todo_reporter.rb +124 -0
  103. data/lib/leftovers/value_processors.rb +40 -0
  104. data/lib/leftovers/value_processors/add_dynamic_prefix.rb +31 -0
  105. data/lib/leftovers/value_processors/add_dynamic_suffix.rb +31 -0
  106. data/lib/leftovers/value_processors/add_prefix.rb +20 -0
  107. data/lib/leftovers/value_processors/add_suffix.rb +20 -0
  108. data/lib/leftovers/value_processors/camelize.rb +24 -0
  109. data/lib/leftovers/value_processors/capitalize.rb +19 -0
  110. data/lib/leftovers/value_processors/deconstantize.rb +24 -0
  111. data/lib/leftovers/value_processors/delete_after.rb +22 -0
  112. data/lib/leftovers/value_processors/delete_before.rb +22 -0
  113. data/lib/leftovers/value_processors/delete_prefix.rb +26 -0
  114. data/lib/leftovers/value_processors/delete_suffix.rb +26 -0
  115. data/lib/leftovers/value_processors/demodulize.rb +24 -0
  116. data/lib/leftovers/value_processors/downcase.rb +19 -0
  117. data/lib/leftovers/value_processors/each.rb +21 -0
  118. data/lib/leftovers/value_processors/each_for_definition_set.rb +29 -0
  119. data/lib/leftovers/value_processors/each_keyword.rb +27 -0
  120. data/lib/leftovers/value_processors/each_keyword_argument.rb +27 -0
  121. data/lib/leftovers/value_processors/each_positional_argument.rb +24 -0
  122. data/lib/leftovers/value_processors/itself.rb +17 -0
  123. data/lib/leftovers/value_processors/keyword.rb +36 -0
  124. data/lib/leftovers/value_processors/keyword_argument.rb +36 -0
  125. data/lib/leftovers/value_processors/parameterize.rb +24 -0
  126. data/lib/leftovers/value_processors/placeholder.rb +18 -0
  127. data/lib/leftovers/value_processors/pluralize.rb +24 -0
  128. data/lib/leftovers/value_processors/positional_argument.rb +26 -0
  129. data/lib/leftovers/value_processors/replace_value.rb +18 -0
  130. data/lib/leftovers/value_processors/return_definition.rb +26 -0
  131. data/lib/leftovers/value_processors/return_string.rb +14 -0
  132. data/lib/leftovers/value_processors/singularize.rb +24 -0
  133. data/lib/leftovers/value_processors/split.rb +22 -0
  134. data/lib/leftovers/value_processors/swapcase.rb +19 -0
  135. data/lib/leftovers/value_processors/titleize.rb +24 -0
  136. data/lib/leftovers/value_processors/underscore.rb +24 -0
  137. data/lib/leftovers/value_processors/upcase.rb +19 -0
  138. data/lib/leftovers/version.rb +1 -1
  139. metadata +201 -25
  140. data/lib/config/selenium.yml +0 -21
  141. data/lib/leftovers/argument_rule.rb +0 -219
  142. data/lib/leftovers/core_ext.rb +0 -13
  143. data/lib/leftovers/hash_rule.rb +0 -40
  144. data/lib/leftovers/name_rule.rb +0 -53
  145. data/lib/leftovers/rule.rb +0 -74
  146. data/lib/leftovers/transform_rule.rb +0 -171
  147. data/lib/leftovers/value_rule.rb +0 -56
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leftovers
4
- VERSION = '0.2.3'
4
+ VERSION = '0.4.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leftovers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Sherson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-22 00:00:00.000000000 Z
11
+ date: 2021-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: benchmark-ips
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,42 +114,98 @@ dependencies:
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: '0.74'
117
+ version: 0.93.1
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: '0.74'
124
+ version: 0.93.1
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rubocop-performance
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: '1.4'
131
+ version: 1.8.1
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: '1.4'
138
+ version: 1.8.1
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rubocop-rspec
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: '1.35'
145
+ version: 1.44.1
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: '1.35'
152
+ version: 1.44.1
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: 0.18.5
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 0.18.5
167
+ - !ruby/object:Gem::Dependency
168
+ name: simplecov-console
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: timecop
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: tty_string
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: 0.2.1
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: 0.2.1
139
209
  - !ruby/object:Gem::Dependency
140
210
  name: spellr
141
211
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +226,28 @@ dependencies:
156
226
  requirements:
157
227
  - - ">="
158
228
  - !ruby/object:Gem::Version
159
- version: 0.10.0
229
+ version: 0.15.1
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: 0.15.1
237
+ - !ruby/object:Gem::Dependency
238
+ name: json_schemer
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
160
244
  type: :runtime
161
245
  prerelease: false
162
246
  version_requirements: !ruby/object:Gem::Requirement
163
247
  requirements:
164
248
  - - ">="
165
249
  - !ruby/object:Gem::Version
166
- version: 0.10.0
250
+ version: '0'
167
251
  - !ruby/object:Gem::Dependency
168
252
  name: parallel
169
253
  requirement: !ruby/object:Gem::Requirement
@@ -192,7 +276,7 @@ dependencies:
192
276
  - - ">="
193
277
  - !ruby/object:Gem::Version
194
278
  version: '0'
195
- description:
279
+ description:
196
280
  email:
197
281
  - robot@dana.sh
198
282
  executables:
@@ -204,6 +288,7 @@ files:
204
288
  - Gemfile
205
289
  - LICENSE.txt
206
290
  - README.md
291
+ - docs/Configuration.md
207
292
  - exe/leftovers
208
293
  - leftovers.gemspec
209
294
  - lib/config/attr_encrypted.yml
@@ -226,35 +311,126 @@ files:
226
311
  - lib/config/rollbar.yml
227
312
  - lib/config/rspec.yml
228
313
  - lib/config/ruby.yml
229
- - lib/config/selenium.yml
314
+ - lib/config/selenium-webdriver.yml
230
315
  - lib/config/sidekiq.yml
231
316
  - lib/config/simplecov.yml
232
317
  - lib/config/will_paginate.yml
233
318
  - lib/leftovers.rb
234
- - lib/leftovers/argument_rule.rb
319
+ - lib/leftovers/ast.rb
235
320
  - lib/leftovers/ast/builder.rb
236
321
  - lib/leftovers/ast/node.rb
237
322
  - lib/leftovers/backports.rb
238
323
  - lib/leftovers/cli.rb
239
324
  - lib/leftovers/collector.rb
240
325
  - lib/leftovers/config.rb
241
- - lib/leftovers/core_ext.rb
326
+ - lib/leftovers/config_validator.rb
327
+ - lib/leftovers/config_validator/error_processor.rb
328
+ - lib/leftovers/config_validator/schema_hash.rb
242
329
  - lib/leftovers/definition.rb
330
+ - lib/leftovers/definition_node.rb
243
331
  - lib/leftovers/definition_set.rb
332
+ - lib/leftovers/dynamic_processors.rb
333
+ - lib/leftovers/dynamic_processors/call.rb
334
+ - lib/leftovers/dynamic_processors/call_definition.rb
335
+ - lib/leftovers/dynamic_processors/definition.rb
336
+ - lib/leftovers/dynamic_processors/each.rb
337
+ - lib/leftovers/dynamic_processors/null.rb
244
338
  - lib/leftovers/erb.rb
245
339
  - lib/leftovers/file.rb
246
340
  - lib/leftovers/file_collector.rb
247
341
  - lib/leftovers/file_list.rb
248
342
  - lib/leftovers/haml.rb
249
- - lib/leftovers/hash_rule.rb
343
+ - lib/leftovers/matcher_builders.rb
344
+ - lib/leftovers/matcher_builders/and.rb
345
+ - lib/leftovers/matcher_builders/and_not.rb
346
+ - lib/leftovers/matcher_builders/argument_node_value.rb
347
+ - lib/leftovers/matcher_builders/name.rb
348
+ - lib/leftovers/matcher_builders/node.rb
349
+ - lib/leftovers/matcher_builders/node_has_argument.rb
350
+ - lib/leftovers/matcher_builders/node_has_keyword_argument.rb
351
+ - lib/leftovers/matcher_builders/node_has_positional_argument.rb
352
+ - lib/leftovers/matcher_builders/node_name.rb
353
+ - lib/leftovers/matcher_builders/node_pair_name.rb
354
+ - lib/leftovers/matcher_builders/node_pair_value.rb
355
+ - lib/leftovers/matcher_builders/node_path.rb
356
+ - lib/leftovers/matcher_builders/node_type.rb
357
+ - lib/leftovers/matcher_builders/or.rb
358
+ - lib/leftovers/matcher_builders/path.rb
359
+ - lib/leftovers/matcher_builders/string.rb
360
+ - lib/leftovers/matcher_builders/string_pattern.rb
361
+ - lib/leftovers/matcher_builders/unless.rb
362
+ - lib/leftovers/matchers.rb
363
+ - lib/leftovers/matchers/all.rb
364
+ - lib/leftovers/matchers/and.rb
365
+ - lib/leftovers/matchers/any.rb
366
+ - lib/leftovers/matchers/node_has_any_keyword_argument.rb
367
+ - lib/leftovers/matchers/node_has_any_positional_argument_with_value.rb
368
+ - lib/leftovers/matchers/node_has_positional_argument.rb
369
+ - lib/leftovers/matchers/node_has_positional_argument_with_value.rb
370
+ - lib/leftovers/matchers/node_name.rb
371
+ - lib/leftovers/matchers/node_pair_value.rb
372
+ - lib/leftovers/matchers/node_path.rb
373
+ - lib/leftovers/matchers/node_scalar_value.rb
374
+ - lib/leftovers/matchers/node_type.rb
375
+ - lib/leftovers/matchers/not.rb
376
+ - lib/leftovers/matchers/or.rb
250
377
  - lib/leftovers/merged_config.rb
251
- - lib/leftovers/name_rule.rb
252
378
  - lib/leftovers/parser.rb
379
+ - lib/leftovers/processor_builders.rb
380
+ - lib/leftovers/processor_builders/action.rb
381
+ - lib/leftovers/processor_builders/add_prefix.rb
382
+ - lib/leftovers/processor_builders/add_suffix.rb
383
+ - lib/leftovers/processor_builders/argument.rb
384
+ - lib/leftovers/processor_builders/dynamic.rb
385
+ - lib/leftovers/processor_builders/each.rb
386
+ - lib/leftovers/processor_builders/each_action.rb
387
+ - lib/leftovers/processor_builders/each_dynamic.rb
388
+ - lib/leftovers/processor_builders/each_for_definition_set.rb
389
+ - lib/leftovers/processor_builders/itself.rb
390
+ - lib/leftovers/processor_builders/keyword.rb
391
+ - lib/leftovers/processor_builders/keyword_argument.rb
392
+ - lib/leftovers/processor_builders/transform.rb
393
+ - lib/leftovers/processor_builders/transform_chain.rb
394
+ - lib/leftovers/processor_builders/transform_set.rb
395
+ - lib/leftovers/processor_builders/value.rb
253
396
  - lib/leftovers/rake_task.rb
254
397
  - lib/leftovers/reporter.rb
255
- - lib/leftovers/rule.rb
256
- - lib/leftovers/transform_rule.rb
257
- - lib/leftovers/value_rule.rb
398
+ - lib/leftovers/todo_reporter.rb
399
+ - lib/leftovers/value_processors.rb
400
+ - lib/leftovers/value_processors/add_dynamic_prefix.rb
401
+ - lib/leftovers/value_processors/add_dynamic_suffix.rb
402
+ - lib/leftovers/value_processors/add_prefix.rb
403
+ - lib/leftovers/value_processors/add_suffix.rb
404
+ - lib/leftovers/value_processors/camelize.rb
405
+ - lib/leftovers/value_processors/capitalize.rb
406
+ - lib/leftovers/value_processors/deconstantize.rb
407
+ - lib/leftovers/value_processors/delete_after.rb
408
+ - lib/leftovers/value_processors/delete_before.rb
409
+ - lib/leftovers/value_processors/delete_prefix.rb
410
+ - lib/leftovers/value_processors/delete_suffix.rb
411
+ - lib/leftovers/value_processors/demodulize.rb
412
+ - lib/leftovers/value_processors/downcase.rb
413
+ - lib/leftovers/value_processors/each.rb
414
+ - lib/leftovers/value_processors/each_for_definition_set.rb
415
+ - lib/leftovers/value_processors/each_keyword.rb
416
+ - lib/leftovers/value_processors/each_keyword_argument.rb
417
+ - lib/leftovers/value_processors/each_positional_argument.rb
418
+ - lib/leftovers/value_processors/itself.rb
419
+ - lib/leftovers/value_processors/keyword.rb
420
+ - lib/leftovers/value_processors/keyword_argument.rb
421
+ - lib/leftovers/value_processors/parameterize.rb
422
+ - lib/leftovers/value_processors/placeholder.rb
423
+ - lib/leftovers/value_processors/pluralize.rb
424
+ - lib/leftovers/value_processors/positional_argument.rb
425
+ - lib/leftovers/value_processors/replace_value.rb
426
+ - lib/leftovers/value_processors/return_definition.rb
427
+ - lib/leftovers/value_processors/return_string.rb
428
+ - lib/leftovers/value_processors/singularize.rb
429
+ - lib/leftovers/value_processors/split.rb
430
+ - lib/leftovers/value_processors/swapcase.rb
431
+ - lib/leftovers/value_processors/titleize.rb
432
+ - lib/leftovers/value_processors/underscore.rb
433
+ - lib/leftovers/value_processors/upcase.rb
258
434
  - lib/leftovers/version.rb
259
435
  homepage: http://github.com/robotdana/leftovers
260
436
  licenses:
@@ -262,8 +438,8 @@ licenses:
262
438
  metadata:
263
439
  homepage_uri: http://github.com/robotdana/leftovers
264
440
  source_code_uri: http://github.com/robotdana/leftovers
265
- changelog_uri: http://github.com/robotdana/leftovers/blob/master/CHANGELOG.md
266
- post_install_message:
441
+ changelog_uri: http://github.com/robotdana/leftovers/blob/main/CHANGELOG.md
442
+ post_install_message:
267
443
  rdoc_options: []
268
444
  require_paths:
269
445
  - lib
@@ -271,15 +447,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
271
447
  requirements:
272
448
  - - ">="
273
449
  - !ruby/object:Gem::Version
274
- version: '0'
450
+ version: 2.4.0
275
451
  required_rubygems_version: !ruby/object:Gem::Requirement
276
452
  requirements:
277
453
  - - ">="
278
454
  - !ruby/object:Gem::Version
279
455
  version: '0'
280
456
  requirements: []
281
- rubygems_version: 3.1.2
282
- signing_key:
457
+ rubygems_version: 3.1.6
458
+ signing_key:
283
459
  specification_version: 4
284
460
  summary: Find unused methods and classes/modules
285
461
  test_files: []
@@ -1,21 +0,0 @@
1
- rules:
2
- skip: true
3
- name:
4
- - before_navigate_to
5
- - before_navigate_back
6
- - after_navigate_back
7
- - before_navigate_forward
8
- - after_navigate_forward
9
- - before_find
10
- - after_find
11
- - before_click
12
- - before_change_value_of
13
- - after_change_value_of
14
- - before_execute_script
15
- - after_execute_script
16
- - before_quit
17
- - before_close
18
- - after_navigate_to
19
- - after_click
20
- - after_quit
21
- - after_close
@@ -1,219 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'definition'
4
- require_relative 'definition_set'
5
- require_relative 'name_rule'
6
- require_relative 'transform_rule'
7
- require_relative 'hash_rule'
8
-
9
- module Leftovers
10
- class ArgumentRule # rubocop:disable Metrics/ClassLength
11
- def self.wrap(rules, definer: false) # rubocop:disable Metrics/MethodLength
12
- case rules
13
- when Array
14
- rules.flat_map { |r| wrap(r, definer: definer) }
15
- when Hash
16
- [new(**rules, definer: definer)]
17
- else
18
- []
19
- end
20
- end
21
-
22
- ADDITIONAL_VALID_KEYS = Leftovers::TransformRule::VALID_TRANSFORMS + %i{if unless}
23
- def initialize( # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength, Metrics/CyclomaticComplexity
24
- argument: nil,
25
- arguments: nil,
26
- key: nil,
27
- keys: nil,
28
- itself: false,
29
- linked_transforms: nil,
30
- transforms: nil,
31
- definer: false,
32
- **options
33
- )
34
- assert_valid_keys(options, ADDITIONAL_VALID_KEYS)
35
- prepare_argument(argument, arguments)
36
- @key = prepare_key(key, keys)
37
- @itself = itself
38
-
39
- unless @positions || @keywords || @all_positions || @all_keywords || @key || @itself
40
- raise ArgumentError, "require at least one of 'argument(s)', 'key(s)', itself"
41
- end
42
-
43
- @if = prepare_condition(options.delete(:if))
44
- @unless = prepare_condition(options.delete(:unless))
45
- @transforms = prepare_transform(options, transforms, linked_transforms)
46
- @definer = definer
47
- end
48
-
49
- def prepare_transform(options, transforms, linked_transforms) # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize
50
- if linked_transforms && transforms
51
- raise ArgumentError, 'Only use one of linked_transforms/transforms'
52
- end
53
- return if !linked_transforms && !transforms && options.empty?
54
-
55
- if !(linked_transforms || transforms)
56
- @transform = TransformRule.new(options)
57
- else
58
- @linked = !!linked_transforms
59
-
60
- transforms = (linked_transforms || transforms).map do |transform|
61
- transform = { transform.to_sym => true } if transform.is_a?(String)
62
- Leftovers::TransformRule.new(options.merge(transform))
63
- end
64
-
65
- if transforms.length <= 1
66
- @transform = transforms.first
67
- else
68
- @transforms = transforms
69
- end
70
- end
71
- end
72
-
73
- def prepare_condition(conditions)
74
- Leftovers.array_wrap(conditions).each do |cond|
75
- cond[:has_argument] = HashRule.new(cond[:has_argument]) if cond[:has_argument]
76
- end
77
- end
78
-
79
- def prepare_key(key, keys)
80
- raise ArgumentError, 'Only use one of key/keys' if key && keys
81
-
82
- key || keys
83
- end
84
-
85
- def prepare_argument(argument, arguments) # rubocop:disable Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/AbcSize
86
- raise ArgumentError, 'Only use one of argument/arguments' if argument && arguments
87
-
88
- positions = Set.new
89
- keywords = []
90
-
91
- Leftovers.each_or_self(argument || arguments) do |arg|
92
- case arg
93
- when '*'
94
- @all_positions = true
95
- when '**'
96
- @all_keywords = true
97
- when Integer
98
- positions << arg - 1
99
- when String, Symbol, Hash
100
- keywords << arg
101
- end
102
- end
103
-
104
- @positions = positions unless @all_positions || positions.empty? || @all_positions
105
- @keywords = NameRule.new(keywords) unless @all_keywords || keywords.empty?
106
- end
107
-
108
- def matches(method_node) # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize
109
- return [].freeze unless all_conditions_match?(method_node)
110
-
111
- result = []
112
-
113
- if @all_positions
114
- result.leftovers_append values(method_node.positional_arguments, method_node)
115
- elsif @positions
116
- result.leftovers_append(
117
- values(method_node.positional_arguments_at(@positions).compact, method_node)
118
- )
119
- end
120
-
121
- if @keywords || @all_keywords || @key
122
- result.leftovers_append hash_values(method_node.kwargs, method_node)
123
- end
124
- result << method_value(method_node) if @itself
125
-
126
- result
127
- end
128
-
129
- def values(value_nodes, method_node)
130
- value_nodes.flat_map { |value_node| value(value_node, method_node) }.compact
131
- end
132
-
133
- def all_conditions_match?(method_node)
134
- @if.all? { |c| condition_match?(c, method_node) } &&
135
- @unless.all? { |c| !condition_match?(c, method_node) }
136
- end
137
-
138
- def condition_match?(condition, method_name)
139
- return unless condition[:has_argument]
140
-
141
- hash_node = method_name.kwargs
142
- return false unless hash_node
143
-
144
- hash_node.each_pair.any? { |key, value| condition[:has_argument].match_pair?(key, value) }
145
- end
146
-
147
- def hash_values(hash_node, method_node) # rubocop:disable Metrics/MethodLength
148
- return unless hash_node
149
-
150
- value_nodes = []
151
- value_nodes.concat hash_node.keys if @key
152
-
153
- if @all_keywords
154
- value_nodes.concat(hash_node.values)
155
- elsif @keywords
156
- value_nodes.concat(hash_node.values_at_match(@keywords))
157
- end
158
-
159
- values(value_nodes, method_node)
160
- end
161
-
162
- def value(value_node, method_node) # rubocop:disable Metrics/MethodLength
163
- return unless value_node
164
-
165
- value_node = value_node.unwrap_freeze
166
-
167
- case value_node.type
168
- when :array
169
- values(value_node.values, method_node)
170
- when :hash
171
- hash_values(value_node, method_node)
172
- when :str, :sym
173
- symbol_values(value_node, method_node)
174
- end
175
- end
176
-
177
- SPLIT = /[.:]+/.freeze
178
- def symbol_values(symbol_node, method_node) # rubocop:disable Metrics/MethodLength
179
- subnodes = Array(transform(symbol_node.to_s, method_node))
180
- .flat_map { |s| s.to_s.split(SPLIT).map(&:to_sym) }
181
-
182
- return subnodes unless @definer
183
-
184
- location = symbol_node.loc.expression
185
- if @linked
186
- Leftovers::DefinitionSet.new(subnodes, location: location, method_node: method_node)
187
- else
188
- subnodes.map do |subnode|
189
- Leftovers::Definition.new(subnode, location: location, method_node: method_node)
190
- end
191
- end
192
- end
193
-
194
- def method_value(method_node)
195
- value = transform(method_node.to_s, method_node)
196
-
197
- return value unless @definer
198
-
199
- Leftovers::Definition.new(value, method_node: method_node)
200
- end
201
-
202
- def transform(string, method_node)
203
- return string unless @transform || @transforms
204
- return @transform.transform(string, method_node) if @transform
205
-
206
- @transforms.map do |transform|
207
- transform.transform(string, method_node)
208
- end
209
- end
210
-
211
- def assert_valid_keys(options, keys)
212
- invalid = options.keys - keys
213
-
214
- return if invalid.empty?
215
-
216
- raise ArgumentError, "unknown keyword#{'s' if invalid.length > 1}: #{invalid.join(', ')}"
217
- end
218
- end
219
- end