Skip to content

Commit

Permalink
ci: add exhaustive switch statement linter (#1557)
Browse files Browse the repository at this point in the history
Adds [a linter that checks for non-exhaustive `switch`
statements](https://github.com/nishanths/exhaustive).
  • Loading branch information
hf authored Apr 28, 2024
1 parent 2caa7b4 commit 6ec08b3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
run: |
set -x
go install honnef.co/go/tools/cmd/staticcheck@latest
go install github.com/nishanths/exhaustive/cmd/exhaustive@latest
make static
- name: Check gosec
run: |
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dev-deps: ## Install developer dependencies
@go install github.com/securego/gosec/v2/cmd/gosec@latest
@go install honnef.co/go/tools/cmd/staticcheck@latest
@go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest
@go install github.com/nishanths/exhaustive/cmd/exhaustive@latest

deps: ## Install dependencies.
@go mod download
Expand Down Expand Up @@ -54,6 +55,7 @@ unused: dev-deps # Look for unused code

static: dev-deps
staticcheck ./...
exhaustive ./...

generate: dev-deps
go generate ./...
Expand Down
1 change: 1 addition & 0 deletions internal/api/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (a *API) Logout(w http.ResponseWriter, r *http.Request) error {
return terr
}

//exhaustive:ignore Default case is handled below.
switch scope {
case LogoutLocal:
return models.LogoutSession(tx, s.ID)
Expand Down
2 changes: 1 addition & 1 deletion internal/observability/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func setPopLogger(sql string) {
}

switch lvl {
case logging.Debug:
case logging.SQL, logging.Debug:
l.Debug(s)
case logging.Info:
l.Info(s)
Expand Down

0 comments on commit 6ec08b3

Please sign in to comment.