bug(lint): a named test or script path is skipped silently since 1.8.2

Open Beginner friendly
#17,992 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #18025 by @ninglinLiu — closed without merging

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
cli, documentation

Research direction

Start in crates/lint/src/sol/mod.rs around lines 130-141 where active_lints filters test/script paths. See PR #17951 for the existing note style on ignored files and mirror it when a named path is skipped. Update forge/linting.mdx and the --help text for PATH. Done means forge lint script/Deploy.s.sol prints a skip note and the book matches current behaviour.

Written by the indexing model from the issue text.

Description

Cmd-forge-lint T-bug T-to-discuss
Component

Forge (lint)

Describe the bug

Since v1.8.2 (#16663), forge lint runs only unsafe-cheatcode and environment-read-across-mutation on files under the configured test and script directories. That is intended, but it also applies when the user names the path, and nothing says so:

$ forge lint script/Deploy.s.sol --deny warnings     # the file has an incorrect-shift
$ echo $?
0
Command 1.8.1 1.8.7
forge lint script --deny warnings 3 diagnostics, exit 1 no output, exit 0
forge lint script/Deploy.s.sol --deny warnings 3 diagnostics, exit 1 no output, exit 0
forge lint script/Deploy.s.sol --only-lint incorrect-shift --deny warnings not run no output, exit 0

A CI step that linted scripts before 1.8.2 now passes without checking them.

Related:

  • forge lint --help says PATH "Overrides the ignore project config", which reads as "a named path is linted".
  • The book (forge/linting.mdx:50) still says "Gas and code-size lints skip test and script files", the behaviour before 1.8.2. Lines 182-183 list block-number-across-roll and block-timestamp-across-warp, which #16755 merged into environment-read-across-mutation.
  • There is no [lint] option to lint scripts again. The only workaround is pointing script elsewhere (FOUNDRY_SCRIPT=__none__ forge lint script).

Cause: active_lints (crates/lint/src/sol/mod.rs:130-141 at d291e9722).

Proposal, smallest first:

  1. Print a note when a named path, or every file, is skipped because it is a test or script (like the note for ignored files in #17951).
  2. Update the PATH help and the book.
  3. Optionally, a [lint] option to lint scripts (scripts send real transactions, so some lints matter there).

I can open PRs for 1 and 2 (book).

Operating System

macOS

🤖 Generated with Claude Code

Dominant language
Rust
Stars
10.8k
Forks
2.7k
Avg merge
1d 12m
Merged PRs (30d)
591

Getting set up

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.

More from foundry-rs/foundry

All issues in foundry-rs/foundry

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.