Skip to content

[linter-miner] Add filepath.WalkDir preference linter #75936

Done

Description

@github-actions

Tip

Your pull request is ready to create! 🎉 ✅

Everything is OK—the changes have been pushed to a branch. Please review the protected files, then create the pull request when you are ready.

Create the pull request

The original pull request description is below.


Overview

Adds filepathwalkpreferwalkdir, a custom analyzer that reports standard-library filepath.Walk calls and recommends filepath.WalkDir.

Evidence

  • The code-pattern scan found 48 non-test filepath.Walk call sites under pkg/ and cmd/.
  • Existing walk linters cover discarded traversal errors and callback error shadowing, but not the less efficient API choice.

Changes

  • Resolves the standard-library function through type information, including aliases, dot imports, and parenthesized calls.
  • Skips generated files, honors nolint, and includes analysistest fixtures for bad and good cases.
  • Registers and documents the analyzer; leaves it advisory until existing call sites are remediated.

Validation

  • go test ./pkg/linters/...
  • go build ./cmd/linters
  • make fmt-go
  • Full make fmt completed Go formatting but stopped in the JavaScript formatter stage; no unrelated files changed.

Next actions

Review the diagnostics and enable enforcement after the existing filepath.Walk call sites are migrated.


Note

Protected files

This patch modifies protected files, which may affect project dependencies, CI/CD pipelines, or agent behaviour.

Protected files
  • README.md

To route changes like this to a review issue instead of blocking, configure protected-files: fallback-to-issue in your workflow configuration.

Allow intentional protected-file changes

If this workflow is intended to modify these files, add specific filenames or folder prefixes to safe-outputs.create-pull-request.protected-files.exclude in the workflow Markdown frontmatter. For example, to allow .changeset/*, exclude the folder using .changeset/:

safe-outputs:
  create-pull-request:
    protected-files:
      policy: fallback-to-issue
      exclude:
        - .changeset/

Keep your existing policy and exclusions. Folder exclusions use path prefixes, not glob patterns, and allow all files beneath that folder, including subfolders. Other protected files still follow the configured policy. If allowed-files is configured, these paths must also match it. Run gh aw compile after updating the workflow.

  • expires on Nov 15, 2026, 9:37 AM UTC-08:00

Generated by Linter Miner · copilot · routed: gpt56 max · ~36 AIC · ⌖ ~2 AIC · ⊞ 3.7K · ◷

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions