🛠 Add static analysis

This commit is contained in:
Dan Jones 2024-09-14 17:34:47 -05:00
commit d6546e5ff9
3 changed files with 31 additions and 8 deletions

View file

@ -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:

2
app.go
View file

@ -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,

View file

@ -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) {