mattermost/tools/mattermost-govet
Jesse Hallam 4d20645a5b
Inline mattermost-govet into the monorepo (#35869)
* inline mattermost-govet

* fix style issues

* simplify the openApiSync spec test

* README.md tweaks

* fix missing licenses

* simplify README.md

* trigger server-ci on tools/mattermost-govet/**

* Apply 470cf78253

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2026-04-01 13:24:22 +00:00
..
apiAuditLogs Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
appErrorWhere Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
concurrentIndex Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
configtelemetry Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
emptyInterface Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
emptyStrCmp Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
equalLenAsserts Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
errorAssertions Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
errorVars Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
errorVarsName Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
facts Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
immut Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
inconsistentReceiverName Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
license Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
mutexLock Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
noSelectStar Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
openApiSync Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
pointerToSlice Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
rawSql Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
requestCtxNaming Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
structuredLogging Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
tFatal Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
util Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
wraperrors Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
.golangci.yml Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
go.mod Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
go.sum Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
main.go Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
Makefile Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00
README.md Inline mattermost-govet into the monorepo (#35869) 2026-04-01 13:24:22 +00:00

Mattermost Go Vet

This package contains mattermost-specific go-vet rules that are used to maintain code consistency in mattermost.

Included analyzers

  1. equalLenAsserts - check for (require/assert).Equal(t, X, len(Y))
  2. inconsistentReceiverName - check for inconsistent receiver names in the methods of a struct
  3. license - check the license header
  4. openApiSync - check for inconsistencies between OpenAPI spec and the source code
  5. structuredLogging - check invalid usage of logging (must use structured logging)
  6. tFatal - check invalid usage of t.Fatal assertions (instead of testify methods)
  7. apiAuditLogs - check that audit records are properly created in the API layer
  8. rawSql - check invalid usage of raw SQL queries instead of using the squirrel lib
  9. emptyStrCmp - check for idiomatic empty string comparisons
  10. pointerToSlice - check for usage of pointer to slice in function definitions
  11. mutexLock - check for cases where a mutex is left locked before returning
  12. wrapError - check for original errors being passed as details rather than wrapped
  13. noSelectStar - check for SQL queries using SELECT * which breaks forwards compatibility
  14. requestCtxNaming - check that request.CTX parameters are consistently named 'rctx'

Running Locally

Mattermost Go Vet lives in the tools/mattermost-govet/ directory of the mattermost/mattermost repo. It can also be imported and installed independently for use by plugins or other projects:

go install github.com/mattermost/mattermost/tools/mattermost-govet@latest

To build and run locally from the repo:

cd tools/mattermost-govet && go install .
go vet -vettool=$(go env GOPATH)/bin/mattermost-govet ./...