Skip to content

[linter-miner] linters: add mapcopyloop analyzer for range-copy loops #78801

Not planned

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.


Summary

Adds a new go/analysis linter, mapcopyloop, which reports range-over-map loops whose only body statement is dst[k] = v and suggests maps.Copy(dst, src).

Evidence

A scan of pkg/ and cmd/ found about 15 copy loops. Running the new linter on ./pkg/... reports 10 of them, for example:

  • pkg/workflow/taint/javascript_workflow.go (maps.Copy(input.Env, s.vars))
  • pkg/workflow/lint/source_policy.go (maps.Copy(fields, value))
  • pkg/workflow/frontmatter_serialization.go (maps.Copy(permissions, app.Permissions))

Behaviour

  • Flags only for k, v := range src { dst[k] = v } with non-blank key and value and a single body statement.
  • Skips dst identical to src, compound assignments, extra statements, and (nolint/redacted):mapcopyloop lines.
  • Adds a suggested fix only when maps is imported and not shadowed.
  • Not coverage-gated, because it is a readability linter.

Registration and CI

  • Registered in pkg/linters/registry.go, documented in doc.go and README.md, and added to spec_test.go.
  • Not yet enforced in cgo.yml: the existing findings need remediation first. It is listed in notYetEnforced in doc_sync_test.go with that reason.
  • The doc.go header count is updated from 98 to 99.

Validation

  • go test ./pkg/linters/... passes.
  • go build ./cmd/linters succeeds.
  • make fmt run.

Notes

  • The unchecked-slice-index linter reports three guarded slice accesses in the new analyzer, as it does in mapclearloop. These are existing false positives of that linter and were left as is.
  • The discussion-miner sub-agent was rate-limited, so the idea came from the code-pattern scan only.

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.

Proposed in this workflow run.

  • expires on Nov 24, 2026, 10:15 AM UTC-08:00

Generated by Linter Miner · copilot · routed: haiku55 high · ~59 AIC · ⌖ ~2 AIC · ⊞ 4.6K · ◷

Activity

  1. github-actions commented on Nov 18, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, Copilot will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt50 · ~1 AIC · ⌖ ~1 AIC · ⊞ 11.3K · ◷

  2. github-actions commented on Nov 18, 2026

    @github-actions
    ContributorAuthor

    🍪 Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, Copilot will analyze the issue and create a pull request with the fix.

    Om nom nom! 🍪

    🍪 Om nom nom by Issue Monster · pi · gpt50 · ~1 AIC · ⌖ ~2 AIC · ⊞ 11.3K · ◷

  3. linked a pull request that will close this issue[linter-miner] Add mapcopyloop analyzer #78958on Nov 18, 2026
  4. github-actions commented on Nov 21, 2026

    @github-actions
    ContributorAuthor

    Closing as no repro.

    If this is still reproducible, please open a new issue with clear reproduction steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions