jackfirth / jackfirth/resyntax
New rule: `unnecessary-analysis-test-within-option`
Nobody has claimed this yet.
- Dominant language
- Racket
- Stars
- 70
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied test case and no-change test case, and account for the dependency on #587's test-case code block syntax. Done means the rule removes only unnecessary @within options while preserving necessary ones, as demonstrated by both examples.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100