jackfirth / jackfirth/resyntax

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

Open
#589 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

new lint testing
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.