Skip to content

[lint-monster] Replace map[string]bool with map[string]struct{} (85 findings) #39176

@github-actions

Description

@github-actions

Daily Lint Remediation

Custom linter identified 85 instances where map[string]bool is used as a set but should use map[string]struct{} to reduce memory overhead.

Distribution

  • pkg/workflow/ (45+ instances)

    • safe_update_manifest.go: 3 instances
    • shell.go: 1 instance
    • tools_parser.go: 2 instances
    • Other workflow files: 39+ instances
  • pkg/cli/ (35+ instances)

    • engine_secrets.go: 1 instance
    • codemod_*.go: Multiple instances
    • Various command and workflow processing files
  • pkg/linters/ (5 instances)

    • ssljson.go: 2 instances

Performance Impact

  • Each bool entry allocates memory unnecessarily (1 byte minimum)
  • map[string]struct{} uses 0 bytes per value, only key memory
  • Recommended change is low-risk, high-signal fix
  • No behavior changes, only memory layout optimization

Affected Patterns

Search pattern: map[string]bool "<name>" used as a set

Common variable names:

  • Tracking: seen, visited, processed, handledPaths
  • Allowlists/denylists: allowed, enabled, valid, existing
  • Registries: knownTools, knownFields, enabledSet

Remediation Strategy

  1. Identify all map[string]bool variable declarations used exclusively with:

    • m[key] = true assignments
    • delete(m, key) deletions
    • if m[key] checks
  2. Replace with map[string]struct{}

    • Update declarations: map[string]struct{}{}
    • Update assignments: m[key] = struct{}{}
    • Keep checks unchanged: if m[key]
  3. Validate linting passes: make golint-custom

Codemod Candidate

This refactoring is ideal for automated codemods. Consider implementing if this becomes a recurring pattern.

Current finding count: 85 instances

Generated by 🧌 LintMonster · 151.7 AIC · ⌖ 4.43 AIC · ⊞ 20.3K ·

  • expires on Jun 20, 2026, 7:51 PM UTC-08:00

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions