Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ MYSQL_TEST=1 go test -run TestFunctionName ./server/datastore/mysql/...

# Generate boilerplate for a new frontend component, including associated stylesheet, tests, and storybook
./frontend/components/generate -n RequiredPascalCaseNameOfTheComponent -p optional/path/to/desired/parent/directory
```

## Go code style

- Prefer `map[T]struct{}` over `map[T]bool` when the map represents a set.
- Convert a map's keys to a slice with `slices.Collect(maps.Keys(m))` instead of manually appending in a loop.
- Avoid `time.Sleep` in tests. Prefer `testing/synctest` to run code in a fake-clock bubble, or use polling helpers, channels, or `require.Eventually`.
- Use `require` and `assert` from `github.com/stretchr/testify` in tests.
- Use `t.Context()` in tests instead of `context.Background()`.
Comment thread
getvictor marked this conversation as resolved.
- Use `any` instead of `interface{}`
3 changes: 3 additions & 0 deletions .custom-gcl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ plugins:
- module: "go.uber.org/nilaway"
import: "go.uber.org/nilaway/cmd/gclplugin"
version: v0.0.0-20260126174828-99d94caaf043 # fixed version for reproducible builds - latest as of 2026-01-29
- module: "github.com/fleetdm/fleet/v4/tools/ci/setboolcheck"
import: "github.com/fleetdm/fleet/v4/tools/ci/setboolcheck/cmd/gclplugin"
path: "tools/ci/setboolcheck"
4 changes: 4 additions & 0 deletions .golangci-incremental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ linters:
- gosec
- modernize
- nilaway
- setboolcheck
settings:
gosec:
# Only enable rules that are too noisy on existing code but valuable for new code.
Expand All @@ -37,6 +38,9 @@ linters:
# Settings must be a "map from string to string" to mimic command line flags: the keys are
# flag names and the values are the values to the particular flags.
include-pkgs: "github.com/fleetdm/fleet/v4"
setboolcheck:
type: module
description: Flags map[T]bool used as sets; suggests map[T]struct{} instead.
exclusions:
generated: strict
rules:
Expand Down
27 changes: 27 additions & 0 deletions tools/ci/setboolcheck/cmd/gclplugin/plugin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Package gclplugin provides the golangci-lint module plugin entry point.
package gclplugin

import (
"github.com/fleetdm/fleet/v4/tools/ci/setboolcheck"
"github.com/golangci/plugin-module-register/register"
"golang.org/x/tools/go/analysis"
)

func init() {
register.Plugin("setboolcheck", New)
}

// New returns the golangci-lint plugin for the setboolcheck analyzer.
func New(_ any) (register.LinterPlugin, error) {
return &plugin{}, nil
}

type plugin struct{}

func (p *plugin) BuildAnalyzers() ([]*analysis.Analyzer, error) {
return []*analysis.Analyzer{setboolcheck.Analyzer}, nil
}

func (p *plugin) GetLoadMode() string {
return register.LoadModeTypesInfo
}
13 changes: 13 additions & 0 deletions tools/ci/setboolcheck/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module github.com/fleetdm/fleet/v4/tools/ci/setboolcheck

go 1.26.1

require (
github.com/golangci/plugin-module-register v0.1.2
golang.org/x/tools v0.42.0
)

require (
golang.org/x/mod v0.33.0 // indirect
golang.org/x/sync v0.19.0 // indirect
)
10 changes: 10 additions & 0 deletions tools/ci/setboolcheck/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/golangci/plugin-module-register v0.1.2 h1:e5WM6PO6NIAEcij3B053CohVp3HIYbzSuP53UAYgOpg=
github.com/golangci/plugin-module-register v0.1.2/go.mod h1:1+QGTsKBvAIvPvoY/os+G5eoqxWn70HYDm2uvUyGuVw=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
Loading
Loading