You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(lint): unused-import via agda-unused shell-out (#7)
## Summary
Implements the last spec'd v0 Agda lint (`docs/arghda-spec.adoc` §Linter
rules, line 106): shell out to `agda-unused` and re-emit findings as
`unused-import` **warn** diagnostics. **Validated end-to-end against a
live `agda-unused` binary** (built locally for this work).
## Design (matches real `agda-unused` behaviour)
- **`src/unused.rs`** — an `agda.rs`-style shell-out. Runs `agda-unused
<file> --json -i <root>` **per file, in local mode**.
- *Why local, not `--global`:* live testing showed `--global` treats the
given root's imports as project roots and reports nothing for them;
**local mode flags imports unused within a file** — the rule's namesake.
- *`LC_ALL=C.UTF-8`:* `agda-unused` reads source in the process locale
and aborts on the first multi-byte character otherwise — and real Agda
is all UTF-8. (Same fix echo-types' docs use for `agda` itself.)
- Parses the real `{ "type": "none"|"unused"|"error", "message": … }`
wrapper and the findings text (`/path/File.agda:line,col-col` + ` unused
import ‘Name’`). A run that yields no JSON (tool crash) is surfaced as
an `error` kind, so one bad file never aborts the scan.
- **Opt-in** behind `scan --unused` (it needs the external tool and
re-checks each file). **Graceful degradation** with a `note:` when the
binary is absent — mirroring how `check` tolerates a missing `agda`.
- `lib.rs` keeps `unused` module-qualified (no flat re-export, to avoid
clashing with `agda::check_file`).
- `dist-newstyle/` gitignored; fixture
`tests/fixtures/unused/{Main,Helper}.agda` (a genuine unused import,
pragma-clean).
## Verification
- `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`,
`cargo build`, `cargo test` all green (lib suite 35 → 41).
- **Live dogfood:** `scan --unused` on the fixture emits exactly
`unused-import: unused import ‘Helper’`; with `agda-unused` off `PATH`
it degrades with a note and 0 warns.
- Parser unit tests pinned to the **real** captured JSON + findings
format.
Note: CI runners don't have `agda-unused`, so the shell-out path isn't
exercised in CI (the parser is unit-tested; the binary glue degrades
gracefully) — exactly the pattern `agda.rs` uses for `agda`.
First of three sequenced engine-polish PRs (3 → 2 → 1):
**`unused-import`** (this), then `.arghda/config.toml` persistence, then
the DAG `headlines` field.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_019GiSiEfgZCte35dyykgBHs
0 commit comments