yukigo 0.2.0 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/analyzer/index.d.ts +7 -0
  3. package/dist/analyzer/inspections/generic/generic.d.ts +1 -2
  4. package/dist/analyzer/inspections/generic/generic.js +2 -5
  5. package/dist/src/analyzer/GraphBuilder.d.ts +30 -0
  6. package/dist/src/analyzer/GraphBuilder.js +100 -0
  7. package/dist/src/analyzer/index.d.ts +59 -0
  8. package/dist/src/analyzer/index.js +152 -0
  9. package/dist/src/analyzer/inspections/functional/functional.d.ts +44 -0
  10. package/dist/src/analyzer/inspections/functional/functional.js +149 -0
  11. package/dist/src/analyzer/inspections/functional/smells.d.ts +16 -0
  12. package/dist/src/analyzer/inspections/functional/smells.js +98 -0
  13. package/dist/src/analyzer/inspections/generic/generic.d.ts +178 -0
  14. package/dist/src/analyzer/inspections/generic/generic.js +604 -0
  15. package/dist/src/analyzer/inspections/generic/smells.d.ts +61 -0
  16. package/dist/src/analyzer/inspections/generic/smells.js +349 -0
  17. package/dist/src/analyzer/inspections/imperative/imperative.d.ts +35 -0
  18. package/dist/src/analyzer/inspections/imperative/imperative.js +109 -0
  19. package/dist/src/analyzer/inspections/imperative/smells.d.ts +16 -0
  20. package/dist/src/analyzer/inspections/imperative/smells.js +58 -0
  21. package/dist/src/analyzer/inspections/logic/logic.d.ts +32 -0
  22. package/dist/src/analyzer/inspections/logic/logic.js +96 -0
  23. package/dist/src/analyzer/inspections/logic/smells.d.ts +15 -0
  24. package/dist/src/analyzer/inspections/logic/smells.js +60 -0
  25. package/dist/src/analyzer/inspections/object/object.d.ts +90 -0
  26. package/dist/src/analyzer/inspections/object/object.js +321 -0
  27. package/dist/src/analyzer/inspections/object/smells.d.ts +30 -0
  28. package/dist/src/analyzer/inspections/object/smells.js +135 -0
  29. package/dist/src/analyzer/utils.d.ts +30 -0
  30. package/dist/src/analyzer/utils.js +78 -0
  31. package/dist/src/index.d.ts +4 -0
  32. package/dist/src/index.js +4 -0
  33. package/dist/src/interpreter/components/EnvBuilder.d.ts +21 -0
  34. package/dist/src/interpreter/components/EnvBuilder.js +155 -0
  35. package/dist/src/interpreter/components/Operations.d.ts +14 -0
  36. package/dist/src/interpreter/components/Operations.js +84 -0
  37. package/dist/src/interpreter/components/PatternMatcher.d.ts +73 -0
  38. package/dist/src/interpreter/components/PatternMatcher.js +358 -0
  39. package/dist/src/interpreter/components/RuntimeContext.d.ts +35 -0
  40. package/dist/src/interpreter/components/RuntimeContext.js +93 -0
  41. package/dist/src/interpreter/components/TestRunner.d.ts +19 -0
  42. package/dist/src/interpreter/components/TestRunner.js +110 -0
  43. package/dist/src/interpreter/components/Visitor.d.ts +71 -0
  44. package/dist/src/interpreter/components/Visitor.js +638 -0
  45. package/dist/src/interpreter/components/logic/LogicEngine.d.ts +29 -0
  46. package/dist/src/interpreter/components/logic/LogicEngine.js +259 -0
  47. package/dist/src/interpreter/components/logic/LogicResolver.d.ts +53 -0
  48. package/dist/src/interpreter/components/logic/LogicResolver.js +484 -0
  49. package/dist/src/interpreter/components/logic/LogicTranslator.d.ts +14 -0
  50. package/dist/src/interpreter/components/logic/LogicTranslator.js +99 -0
  51. package/dist/src/interpreter/components/runtimes/FunctionRuntime.d.ts +12 -0
  52. package/dist/src/interpreter/components/runtimes/FunctionRuntime.js +149 -0
  53. package/dist/src/interpreter/components/runtimes/LazyRuntime.d.ts +19 -0
  54. package/dist/src/interpreter/components/runtimes/LazyRuntime.js +269 -0
  55. package/dist/src/interpreter/components/runtimes/ObjectRuntime.d.ts +35 -0
  56. package/dist/src/interpreter/components/runtimes/ObjectRuntime.js +126 -0
  57. package/dist/src/interpreter/errors.d.ts +19 -0
  58. package/dist/src/interpreter/errors.js +36 -0
  59. package/dist/src/interpreter/index.d.ts +24 -0
  60. package/dist/src/interpreter/index.js +41 -0
  61. package/dist/src/interpreter/trampoline.d.ts +17 -0
  62. package/dist/src/interpreter/trampoline.js +38 -0
  63. package/dist/src/interpreter/utils.d.ts +11 -0
  64. package/dist/src/interpreter/utils.js +65 -0
  65. package/dist/src/tester/index.d.ts +25 -0
  66. package/dist/src/tester/index.js +113 -0
  67. package/dist/src/utils/helpers.d.ts +13 -0
  68. package/dist/src/utils/helpers.js +52 -0
  69. package/dist/utils/helpers.d.ts +5 -1
  70. package/dist/utils/helpers.js +82 -6
  71. package/package.json +4 -2
  72. package/src/analyzer/index.ts +9 -0
  73. package/src/analyzer/inspections/generic/generic.ts +2 -6
  74. package/src/utils/helpers.ts +112 -10
  75. package/tests/analyzer/helpers.spec.ts +16 -10
  76. package/tests/tester/Tester.spec.ts +0 -1
@@ -0,0 +1,604 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { isUnguardedBody, ParameterizedType, StopTraversalException, SymbolPrimitive, VariablePattern, } from "yukigo-ast";
8
+ import { ScopedVisitor, InspectionVisitor, AutoScoped, } from "../../utils.js";
9
+ let Assigns = class Assigns extends ScopedVisitor {
10
+ targetIdentifier;
11
+ constructor(targetIdentifier, scope) {
12
+ super(scope);
13
+ this.targetIdentifier = targetIdentifier;
14
+ }
15
+ visitVariable(node) {
16
+ if (node.identifier.value === this.targetIdentifier)
17
+ throw new StopTraversalException();
18
+ }
19
+ visitAttribute(node) {
20
+ if (node.identifier.value === this.targetIdentifier)
21
+ throw new StopTraversalException();
22
+ }
23
+ visitAssignment(node) {
24
+ if (node.identifier.value === this.targetIdentifier)
25
+ throw new StopTraversalException();
26
+ }
27
+ };
28
+ Assigns = __decorate([
29
+ AutoScoped
30
+ ], Assigns);
31
+ export { Assigns };
32
+ let Calls = class Calls extends ScopedVisitor {
33
+ targetCallee;
34
+ constructor(targetCallee, scope) {
35
+ super(scope);
36
+ this.targetCallee = targetCallee;
37
+ }
38
+ visitCall(node) {
39
+ if (node.callee.value === this.targetCallee)
40
+ throw new StopTraversalException();
41
+ }
42
+ };
43
+ Calls = __decorate([
44
+ AutoScoped
45
+ ], Calls);
46
+ export { Calls };
47
+ let Declares = class Declares extends ScopedVisitor {
48
+ targetIdentifier;
49
+ constructor(targetIdentifier, scopeName) {
50
+ super(scopeName);
51
+ this.targetIdentifier = targetIdentifier;
52
+ }
53
+ check(node) {
54
+ if (node.identifier.value === this.targetIdentifier)
55
+ throw new StopTraversalException();
56
+ }
57
+ visitFunction(node) {
58
+ if (this.inScope)
59
+ this.check(node);
60
+ super.visitFunction(node);
61
+ }
62
+ visitMethod(node) {
63
+ if (this.inScope)
64
+ this.check(node);
65
+ super.visitMethod(node);
66
+ }
67
+ visitProcedure(node) {
68
+ if (this.inScope)
69
+ this.check(node);
70
+ super.visitProcedure(node);
71
+ }
72
+ visitRule(node) {
73
+ if (this.inScope)
74
+ this.check(node);
75
+ super.visitRule(node);
76
+ }
77
+ visitFact(node) {
78
+ if (this.inScope)
79
+ this.check(node);
80
+ super.visitFact(node);
81
+ }
82
+ visitVariable(node) {
83
+ this.check(node);
84
+ }
85
+ visitAttribute(node) {
86
+ this.check(node);
87
+ }
88
+ visitTypeAlias(node) {
89
+ this.check(node);
90
+ }
91
+ visitTypeSignature(node) {
92
+ this.check(node);
93
+ }
94
+ };
95
+ Declares = __decorate([
96
+ AutoScoped
97
+ ], Declares);
98
+ export { Declares };
99
+ let DeclaresComputation = class DeclaresComputation extends ScopedVisitor {
100
+ callName;
101
+ constructor(callName, scope) {
102
+ super(scope);
103
+ this.callName = callName;
104
+ }
105
+ visitFunction(node) {
106
+ if (node.identifier.value === this.callName)
107
+ throw new StopTraversalException();
108
+ }
109
+ visitMethod(node) {
110
+ if (node.identifier.value === this.callName)
111
+ throw new StopTraversalException();
112
+ }
113
+ visitProcedure(node) {
114
+ if (node.identifier.value === this.callName)
115
+ throw new StopTraversalException();
116
+ }
117
+ visitFact(node) {
118
+ if (node.identifier.value === this.callName)
119
+ throw new StopTraversalException();
120
+ }
121
+ visitRule(node) {
122
+ if (node.identifier.value === this.callName)
123
+ throw new StopTraversalException();
124
+ }
125
+ };
126
+ DeclaresComputation = __decorate([
127
+ AutoScoped
128
+ ], DeclaresComputation);
129
+ export { DeclaresComputation };
130
+ let DeclaresComputationWithArity = class DeclaresComputationWithArity extends ScopedVisitor {
131
+ targetArity;
132
+ constructor(targetArity, scope) {
133
+ super(scope);
134
+ this.targetArity = Number(targetArity);
135
+ }
136
+ visitFunction(node) {
137
+ if (node.equations.some((eq) => eq.patterns.length === this.targetArity))
138
+ throw new StopTraversalException();
139
+ }
140
+ visitMethod(node) {
141
+ if (node.equations.some((eq) => eq.patterns.length === this.targetArity))
142
+ throw new StopTraversalException();
143
+ }
144
+ visitProcedure(node) {
145
+ if (node.equations.some((eq) => eq.patterns.length === this.targetArity))
146
+ throw new StopTraversalException();
147
+ }
148
+ visitFact(node) {
149
+ if (node.patterns.length === this.targetArity)
150
+ throw new StopTraversalException();
151
+ }
152
+ visitRule(node) {
153
+ if (node.equations.some((eq) => eq.patterns.length === this.targetArity))
154
+ throw new StopTraversalException();
155
+ }
156
+ };
157
+ DeclaresComputationWithArity = __decorate([
158
+ AutoScoped
159
+ ], DeclaresComputationWithArity);
160
+ export { DeclaresComputationWithArity };
161
+ export class DeclaresEntryPoint extends InspectionVisitor {
162
+ visitEntryPoint(node) {
163
+ throw new StopTraversalException();
164
+ }
165
+ }
166
+ let DeclaresFunction = class DeclaresFunction extends ScopedVisitor {
167
+ targetBinding;
168
+ constructor(targetBinding, scope) {
169
+ super(scope);
170
+ this.targetBinding = targetBinding;
171
+ }
172
+ visitFunction(node) {
173
+ if (node.identifier.value === this.targetBinding)
174
+ throw new StopTraversalException();
175
+ }
176
+ };
177
+ DeclaresFunction = __decorate([
178
+ AutoScoped
179
+ ], DeclaresFunction);
180
+ export { DeclaresFunction };
181
+ let DeclaresRecursively = class DeclaresRecursively extends ScopedVisitor {
182
+ targetBinding;
183
+ constructor(targetBinding, scope) {
184
+ super(scope);
185
+ this.targetBinding = targetBinding;
186
+ }
187
+ visitFunction(node) {
188
+ super.visitFunction(node);
189
+ this.visitNested(node);
190
+ }
191
+ visitMethod(node) {
192
+ super.visitMethod(node);
193
+ this.visitNested(node);
194
+ }
195
+ visitProcedure(node) {
196
+ super.visitProcedure(node);
197
+ this.visitNested(node);
198
+ }
199
+ visitFact(node) {
200
+ super.visitFact(node);
201
+ this.visitNested(node);
202
+ }
203
+ visitRule(node) {
204
+ super.visitRule(node);
205
+ this.visitNested(node);
206
+ }
207
+ visitNested(node) {
208
+ if ("identifier" in node &&
209
+ node.identifier instanceof SymbolPrimitive &&
210
+ node.identifier.value === this.targetBinding)
211
+ throw new StopTraversalException();
212
+ }
213
+ };
214
+ DeclaresRecursively = __decorate([
215
+ AutoScoped
216
+ ], DeclaresRecursively);
217
+ export { DeclaresRecursively };
218
+ export class HasDirectRecursion extends InspectionVisitor {
219
+ binding;
220
+ isInsideBody = false;
221
+ constructor(binding) {
222
+ super();
223
+ this.binding = binding;
224
+ }
225
+ visitFunction(node) {
226
+ if (node.identifier.value !== this.binding)
227
+ return;
228
+ this.traverseCollection(node.equations);
229
+ }
230
+ visitRule(node) {
231
+ if (node.identifier.value !== this.binding)
232
+ return;
233
+ this.traverseCollection(node.equations);
234
+ }
235
+ visitProcedure(node) {
236
+ if (node.identifier.value !== this.binding)
237
+ return;
238
+ this.traverseCollection(node.equations);
239
+ }
240
+ visitMethod(node) {
241
+ if (node.identifier.value !== this.binding)
242
+ return;
243
+ this.traverseCollection(node.equations);
244
+ }
245
+ visitEquation(node) {
246
+ this.isInsideBody = true;
247
+ try {
248
+ if (isUnguardedBody(node.body)) {
249
+ node.body.accept(this);
250
+ }
251
+ else {
252
+ this.traverseCollection(node.body);
253
+ }
254
+ }
255
+ finally {
256
+ this.isInsideBody = false;
257
+ }
258
+ }
259
+ visitSymbolPrimitive(node) {
260
+ if (this.isInsideBody && node.value === this.binding)
261
+ throw new StopTraversalException();
262
+ }
263
+ }
264
+ export class DeclaresTypeAlias extends InspectionVisitor {
265
+ typeAliasName;
266
+ constructor(typeAliasName) {
267
+ super();
268
+ this.typeAliasName = typeAliasName;
269
+ }
270
+ visitTypeAlias(node) {
271
+ if (node.identifier.value === this.typeAliasName)
272
+ throw new StopTraversalException();
273
+ }
274
+ }
275
+ export class DeclaresTypeSignature extends InspectionVisitor {
276
+ targetBinding;
277
+ constructor(targetBinding) {
278
+ super();
279
+ this.targetBinding = targetBinding;
280
+ }
281
+ visitTypeSignature(node) {
282
+ if (node.identifier.value === this.targetBinding)
283
+ throw new StopTraversalException();
284
+ }
285
+ }
286
+ let DeclaresVariable = class DeclaresVariable extends ScopedVisitor {
287
+ targetBinding;
288
+ constructor(targetBinding, scope) {
289
+ super(scope);
290
+ this.targetBinding = targetBinding;
291
+ }
292
+ visitVariable(node) {
293
+ if (node.identifier.value === this.targetBinding)
294
+ throw new StopTraversalException();
295
+ }
296
+ };
297
+ DeclaresVariable = __decorate([
298
+ AutoScoped
299
+ ], DeclaresVariable);
300
+ export { DeclaresVariable };
301
+ let Raises = class Raises extends ScopedVisitor {
302
+ constructor(scope) {
303
+ super(scope);
304
+ }
305
+ visitRaise(node) {
306
+ throw new StopTraversalException();
307
+ }
308
+ };
309
+ Raises = __decorate([
310
+ AutoScoped
311
+ ], Raises);
312
+ export { Raises };
313
+ let Uses = class Uses extends ScopedVisitor {
314
+ targetBinding;
315
+ constructor(targetBinding, scope) {
316
+ super(scope);
317
+ this.targetBinding = targetBinding;
318
+ }
319
+ visitSymbolPrimitive(node) {
320
+ if (node.value === this.targetBinding)
321
+ throw new StopTraversalException();
322
+ }
323
+ };
324
+ Uses = __decorate([
325
+ AutoScoped
326
+ ], Uses);
327
+ export { Uses };
328
+ let UsesArithmetic = class UsesArithmetic extends ScopedVisitor {
329
+ constructor(scope) {
330
+ super(scope);
331
+ }
332
+ visitArithmeticBinaryOperation(node) {
333
+ throw new StopTraversalException();
334
+ }
335
+ visitArithmeticUnaryOperation(node) {
336
+ throw new StopTraversalException();
337
+ }
338
+ };
339
+ UsesArithmetic = __decorate([
340
+ AutoScoped
341
+ ], UsesArithmetic);
342
+ export { UsesArithmetic };
343
+ let UsesConditional = class UsesConditional extends ScopedVisitor {
344
+ visitIf(node) {
345
+ throw new StopTraversalException();
346
+ }
347
+ };
348
+ UsesConditional = __decorate([
349
+ AutoScoped
350
+ ], UsesConditional);
351
+ export { UsesConditional };
352
+ let UsesLogic = class UsesLogic extends ScopedVisitor {
353
+ constructor(scope) {
354
+ super(scope);
355
+ }
356
+ visitLogicalBinaryOperation(node) {
357
+ throw new StopTraversalException();
358
+ }
359
+ visitLogicalUnaryOperation(node) {
360
+ throw new StopTraversalException();
361
+ }
362
+ };
363
+ UsesLogic = __decorate([
364
+ AutoScoped
365
+ ], UsesLogic);
366
+ export { UsesLogic };
367
+ let UsesPrint = class UsesPrint extends ScopedVisitor {
368
+ constructor(scope) {
369
+ super(scope);
370
+ }
371
+ visitPrint(node) {
372
+ throw new StopTraversalException();
373
+ }
374
+ };
375
+ UsesPrint = __decorate([
376
+ AutoScoped
377
+ ], UsesPrint);
378
+ export { UsesPrint };
379
+ let UsesType = class UsesType extends ScopedVisitor {
380
+ targetBinding;
381
+ constructor(targetBinding, scope) {
382
+ super(scope);
383
+ this.targetBinding = targetBinding;
384
+ }
385
+ visitTypeSignature(node) {
386
+ node.body.accept(this);
387
+ }
388
+ visitSimpleType(node) {
389
+ if (node.value === this.targetBinding)
390
+ throw new StopTraversalException();
391
+ }
392
+ visitTypeVar(node) {
393
+ if (node.value === this.targetBinding)
394
+ throw new StopTraversalException();
395
+ }
396
+ };
397
+ UsesType = __decorate([
398
+ AutoScoped
399
+ ], UsesType);
400
+ export { UsesType };
401
+ let HasBinding = class HasBinding extends ScopedVisitor {
402
+ visitFunction(node) {
403
+ throw new StopTraversalException();
404
+ }
405
+ visitObject(node) {
406
+ throw new StopTraversalException();
407
+ }
408
+ visitClass(node) {
409
+ throw new StopTraversalException();
410
+ }
411
+ visitRule(node) {
412
+ throw new StopTraversalException();
413
+ }
414
+ visitFact(node) {
415
+ throw new StopTraversalException();
416
+ }
417
+ visitTypeAlias(node) {
418
+ throw new StopTraversalException();
419
+ }
420
+ visitTypeSignature(node) {
421
+ throw new StopTraversalException();
422
+ }
423
+ visitRecord(node) {
424
+ throw new StopTraversalException();
425
+ }
426
+ };
427
+ HasBinding = __decorate([
428
+ AutoScoped
429
+ ], HasBinding);
430
+ export { HasBinding };
431
+ export class SubordinatesDeclarationsTo extends InspectionVisitor {
432
+ childName;
433
+ parentName;
434
+ constructor(childName, parentName) {
435
+ super();
436
+ this.childName = childName;
437
+ this.parentName = parentName;
438
+ }
439
+ visitFunction(node) {
440
+ if (node.identifier.value === this.parentName) {
441
+ const childFinder = new Declares(this.childName);
442
+ node.equations.forEach((eq) => eq.accept(childFinder)); // we expect that this will throw if find the subordinated decl
443
+ }
444
+ else {
445
+ super.visitFunction(node);
446
+ }
447
+ }
448
+ }
449
+ export class SubordinatesDeclarationsToEntryPoint extends InspectionVisitor {
450
+ childName;
451
+ constructor(childName) {
452
+ super();
453
+ this.childName = childName;
454
+ }
455
+ visitEntryPoint(node) {
456
+ const childFinder = new Declares(this.childName);
457
+ node.expression.statements.forEach((stmt) => stmt.accept(childFinder));
458
+ }
459
+ }
460
+ export class TypesAs extends InspectionVisitor {
461
+ typeName;
462
+ bindingName;
463
+ constructor(typeName, bindingName) {
464
+ super();
465
+ this.typeName = typeName;
466
+ this.bindingName = bindingName;
467
+ }
468
+ visitTypeSignature(node) {
469
+ if (node.identifier.value === this.bindingName) {
470
+ const actualType = node.body.toString();
471
+ if (actualType.replace(/\s+/g, " ").trim() ===
472
+ this.typeName.replace(/\s+/g, " ").trim()) {
473
+ throw new StopTraversalException();
474
+ }
475
+ }
476
+ }
477
+ }
478
+ export class TypesParameterAs extends InspectionVisitor {
479
+ paramIndex;
480
+ typeName;
481
+ bindingName;
482
+ constructor(paramIndex, typeName, bindingName) {
483
+ super();
484
+ this.paramIndex = paramIndex;
485
+ this.typeName = typeName;
486
+ this.bindingName = bindingName;
487
+ }
488
+ visitTypeSignature(node) {
489
+ if (node.identifier.value === this.bindingName) {
490
+ if (node.body instanceof ParameterizedType) {
491
+ const paramType = node.body.inputs[this.paramIndex];
492
+ if (paramType) {
493
+ const actualType = paramType.toString();
494
+ if (actualType.replace(/\s+/g, " ").trim() ===
495
+ this.typeName.replace(/\s+/g, " ").trim()) {
496
+ throw new StopTraversalException();
497
+ }
498
+ }
499
+ }
500
+ }
501
+ }
502
+ }
503
+ export class TypesReturnAs extends InspectionVisitor {
504
+ typeName;
505
+ bindingName;
506
+ constructor(typeName, bindingName) {
507
+ super();
508
+ this.typeName = typeName;
509
+ this.bindingName = bindingName;
510
+ }
511
+ visitTypeSignature(node) {
512
+ if (node.identifier.value === this.bindingName) {
513
+ if (node.body instanceof ParameterizedType) {
514
+ const actualType = node.body.returnType.toString();
515
+ if (actualType.replace(/\s+/g, " ").trim() ===
516
+ this.typeName.replace(/\s+/g, " ").trim()) {
517
+ throw new StopTraversalException();
518
+ }
519
+ }
520
+ }
521
+ }
522
+ }
523
+ let Rescues = class Rescues extends ScopedVisitor {
524
+ exceptionName;
525
+ constructor(exceptionName, scope) {
526
+ super(scope);
527
+ this.exceptionName = exceptionName;
528
+ }
529
+ visitCatch(node) {
530
+ for (const pattern of node.patterns) {
531
+ if (pattern instanceof VariablePattern &&
532
+ pattern.name.value === this.exceptionName) {
533
+ throw new StopTraversalException();
534
+ }
535
+ }
536
+ }
537
+ };
538
+ Rescues = __decorate([
539
+ AutoScoped
540
+ ], Rescues);
541
+ export { Rescues };
542
+ let UsesExceptionHandling = class UsesExceptionHandling extends ScopedVisitor {
543
+ constructor(scope) {
544
+ super(scope);
545
+ }
546
+ visitTry(node) {
547
+ throw new StopTraversalException();
548
+ }
549
+ };
550
+ UsesExceptionHandling = __decorate([
551
+ AutoScoped
552
+ ], UsesExceptionHandling);
553
+ export { UsesExceptionHandling };
554
+ let UsesExceptions = class UsesExceptions extends ScopedVisitor {
555
+ constructor(scope) {
556
+ super(scope);
557
+ }
558
+ visitTry(node) {
559
+ return new UsesExceptionHandling(this.binding).visitTry(node);
560
+ }
561
+ visitRaise(node) {
562
+ throw new StopTraversalException();
563
+ }
564
+ };
565
+ UsesExceptions = __decorate([
566
+ AutoScoped
567
+ ], UsesExceptions);
568
+ export { UsesExceptions };
569
+ export const genericInspections = {
570
+ Assigns: Assigns,
571
+ Calls: Calls,
572
+ Declares: Declares,
573
+ DeclaresComputation: DeclaresComputation,
574
+ DeclaresComputationWithArity: DeclaresComputationWithArity,
575
+ HasArity: DeclaresComputationWithArity,
576
+ DeclaresEntryPoint: DeclaresEntryPoint,
577
+ DeclaresFunction: DeclaresFunction,
578
+ DeclaresRecursively: DeclaresRecursively,
579
+ HasDirectRecursion: HasDirectRecursion,
580
+ DeclaresTypeAlias: DeclaresTypeAlias,
581
+ DeclaresTypeSignature: DeclaresTypeSignature,
582
+ HasTypeSignature: DeclaresTypeSignature,
583
+ DeclaresVariable: DeclaresVariable,
584
+ Raises: Raises,
585
+ Uses: Uses,
586
+ HasUsage: Uses,
587
+ UsesArithmetic: UsesArithmetic,
588
+ SubordinatesDeclarationsTo: SubordinatesDeclarationsTo,
589
+ SubordinatesDeclarationsToEntryPoint: SubordinatesDeclarationsToEntryPoint,
590
+ TypesAs: TypesAs,
591
+ TypesParameterAs: TypesParameterAs,
592
+ TypesReturnAs: TypesReturnAs,
593
+ UsesConditional: UsesConditional,
594
+ HasConditional: UsesConditional,
595
+ Rescues: Rescues,
596
+ UsesExceptionHandling: UsesExceptionHandling,
597
+ UsesExceptions: UsesExceptions,
598
+ UsesIf: UsesConditional,
599
+ UsesLogic: UsesLogic,
600
+ UsesMath: UsesArithmetic,
601
+ UsesPrint: UsesPrint,
602
+ UsesType: UsesType,
603
+ HasBinding: HasBinding,
604
+ };
@@ -0,0 +1,61 @@
1
+ import { Application, Call, Catch, Equation, Function, If, LogicalBinaryOperation, Print, Sequence, SymbolPrimitive, Variable } from "yukigo-ast";
2
+ import { ScopedVisitor, VisitorConstructor } from "../../utils.js";
3
+ export declare class DiscardsExceptions extends ScopedVisitor {
4
+ visitCatch(node: Catch): void;
5
+ }
6
+ export declare class DoesConsolePrint extends ScopedVisitor {
7
+ visitPrint(node: Print): void;
8
+ visitCall(node: Call): void;
9
+ visitApplication(node: Application): void;
10
+ private isPrintFunc;
11
+ }
12
+ export declare class HasDeclarationTypos extends ScopedVisitor {
13
+ visitSequence(node: Sequence): void;
14
+ }
15
+ export declare class HasEmptyIfBranches extends ScopedVisitor {
16
+ visitIf(node: If): void;
17
+ }
18
+ export declare class HasLongParameterList extends ScopedVisitor {
19
+ private readonly maxParams;
20
+ constructor(maxParams?: number, scope?: string);
21
+ visitEquation(node: Equation): void;
22
+ }
23
+ export declare class HasMisspelledIdentifiers extends ScopedVisitor {
24
+ private readonly dictionary;
25
+ constructor(dictionaryWords?: string[], scope?: string);
26
+ visitVariable(node: Variable): void;
27
+ visitFunction(node: Function): void;
28
+ private checkSpelling;
29
+ }
30
+ export declare class HasRedundantBooleanComparison extends ScopedVisitor {
31
+ visitLogicalBinaryOperation(node: LogicalBinaryOperation): void;
32
+ }
33
+ export declare class HasRedundantIf extends ScopedVisitor {
34
+ visitIf(node: If): void;
35
+ }
36
+ export declare class HasRedundantLocalVariableReturn extends ScopedVisitor {
37
+ visitSequence(node: Sequence): void;
38
+ }
39
+ export declare class HasTooShortIdentifiers extends ScopedVisitor {
40
+ private readonly minLength;
41
+ constructor(minLength?: number, scope?: string);
42
+ visitVariable(node: Variable): void;
43
+ }
44
+ export declare class HasUsageTypos extends ScopedVisitor {
45
+ visitSequence(node: Sequence): void;
46
+ }
47
+ export declare class UsesWrongCaseBindings extends ScopedVisitor {
48
+ private readonly caseType;
49
+ constructor(caseType?: string, scopeName?: string);
50
+ visitSymbolPrimitive(node: SymbolPrimitive): void;
51
+ private checkCase;
52
+ }
53
+ export declare class IsLongCode extends ScopedVisitor {
54
+ private readonly maxStatements;
55
+ constructor(maxStatements?: number, scopeName?: string);
56
+ visitSequence(node: Sequence): void;
57
+ }
58
+ export declare class ShouldInvertIfCondition extends ScopedVisitor {
59
+ visitIf(node: If): void;
60
+ }
61
+ export declare const genericSmells: Record<string, VisitorConstructor>;