Skip to content

New rule: unnecessary-analysis-test-within-option #589

Description

@jackfirth

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.

Activity

  1. added
    new lintIssues suggesting new lints or pull requests implementing new lints
    testingTests and testing tools
    on Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    new lintIssues suggesting new lints or pull requests implementing new lintstestingTests and testing tools

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions