Skip to content

Replace test set-style map[string]bool usage with map[string]struct{}#37257

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/lint-monster-fix-set-type-fixes
Draft

Replace test set-style map[string]bool usage with map[string]struct{}#37257
Copilot wants to merge 4 commits into
mainfrom
copilot/lint-monster-fix-set-type-fixes

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 6, 2026

Daily linting flagged widespread test-only set patterns implemented as map[string]bool, which are non-idiomatic and allocate unnecessary values. This change converts the flagged set usages to map[string]struct{} and updates related write/read patterns without changing test intent.

  • Scope: test set patterns

    • Converted flagged set-style declarations in tests from map[string]bool to map[string]struct{}.
    • Updated set writes from m[k] = true to m[k] = struct{}{}.
  • Membership checks and assertions

    • Reworked membership checks to existence semantics (_, ok := m[k]) where direct boolean reads were used.
    • Updated assertion patterns accordingly (for example, to assert.Contains / assert.NotContains for set membership checks).
  • Compatibility where APIs still require map[string]bool

    • Added a small converter helper in pkg/cli/engine_secrets.go (stringSetToBoolMap) and used it in affected tests that pass set data into bool-map APIs, keeping production behavior unchanged while allowing idiomatic set representation in test setup.
// before
values := make(map[string]bool)
values[o.Value] = true
assert.True(t, values["daily"])

// after
values := make(map[string]struct{})
values[o.Value] = struct{}{}
assert.Contains(t, values, "daily")

Copilot AI and others added 2 commits June 6, 2026 05:45
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix set type usages from map[string]bool to map[string]struct{} Replace test set-style map[string]bool usage with map[string]struct{} Jun 6, 2026
Copilot AI requested a review from gh-aw-bot June 6, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[lint-monster] [Lint] Test Set-Type Fixes: map[string]bool → map[string]struct{} - 243 findings

3 participants