From d6546e5ff979c56de3af36e8b55f0015528ccf82 Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Sat, 14 Sep 2024 17:34:47 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=20Add=20static=20analysis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Taskfile.yml | 35 +++++++++++++++++++++++++++++------ app.go | 2 +- app_test.go | 2 +- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index eb52f83..4a5c4ce 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -7,12 +7,6 @@ tasks: - task: test - task: build - ft: - desc: Format and test - cmds: - - task: fmt - - task: test - fmt: desc: Format go code sources: @@ -20,8 +14,37 @@ tasks: cmds: - go fmt ./... + vet: + desc: Vet go code + sources: + - '**/*.go' + cmds: + - go vet ./... + + critic: + desc: Critique go code + sources: + - '**/*.go' + cmds: + - gocritic check ./... + + staticcheck: + desc: Static check go code + sources: + - '**/*.go' + cmds: + - staticcheck ./... + + analyze: + desc: Do static analysis + deps: + - vet + - critic + - staticcheck + test: desc: Run unit tests + deps: [fmt, vet] sources: - '**/*.go' generates: diff --git a/app.go b/app.go index 8cb5604..6b33a8c 100644 --- a/app.go +++ b/app.go @@ -27,7 +27,7 @@ type App struct { func NewApp(ver string, conf config.Config, db store.Store) (*App, error) { if conf.BaseURL == "" { - return nil, errors.New("Missing BaseURL") + return nil, errors.New("missing BaseURL") } app := App{ version: ver, diff --git a/app_test.go b/app_test.go index 7bc0cac..426985e 100644 --- a/app_test.go +++ b/app_test.go @@ -14,7 +14,7 @@ func TestEmptyBaseURL(t *testing.T) { c := config.Config{} a, er := NewApp("0.0.0", c, testmocks.GetStore()) assert.Nil(t, a) - assert.EqualError(t, er, "Missing BaseURL") + assert.EqualError(t, er, "missing BaseURL") } func TestDefaultEnvironment(t *testing.T) {