resyntax icon indicating copy to clipboard operation
resyntax copied to clipboard

New rule: `unnecessary-analysis-test-within-option`

Open jackfirth opened this issue 6 months ago • 0 comments

Rule summary

In #lang resyntax/test, the @within option for analysis-test: is used to narrow the scope of a following @inspect option. However, it's only necessary if the @inspect option is ambiguous if its scope isn't narrowed. There should be a refactoring rule that removes unnecessary @within options.

Test case

#lang resyntax/test

test: "unnecessary @within option can be removed"
|--------------------
| #lang resyntax/test
| analysis-test: "unused positional argument in module-level function"
| - (define (f x y) x)
| @within - (f x y)
| @inspect - y
| @property usage-count
| @assert 0
|====================
| #lang resyntax/test
| analysis-test: "unused positional argument in module-level function"
| --------------------
| (define (f x y) x)
| (f 1 2)
| --------------------
| @inspect - y
| @property usage-count
| @assert 0
|--------------------

No-change test case

#lang resyntax/test

no-change-test: "necessary @within not removable"
|--------------------
| #lang resyntax/test
| analysis-test: "unused positional argument in module-level function"
| - (define (f x y) x)
| @within - (f x y)
| @inspect - x
| @property usage-count
| @assert 1
|--------------------

Additional context

This came up while I was reviewing #556, in which copilot used @within unnecessarily a few times. Also, this depends on #587 for the test case code block syntax.

jackfirth avatar Aug 21 '25 22:08 jackfirth