🛠 Add static analysis
This commit is contained in:
parent
931f75500f
commit
d6546e5ff9
3 changed files with 31 additions and 8 deletions
35
Taskfile.yml
35
Taskfile.yml
|
|
@ -7,12 +7,6 @@ tasks:
|
||||||
- task: test
|
- task: test
|
||||||
- task: build
|
- task: build
|
||||||
|
|
||||||
ft:
|
|
||||||
desc: Format and test
|
|
||||||
cmds:
|
|
||||||
- task: fmt
|
|
||||||
- task: test
|
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
desc: Format go code
|
desc: Format go code
|
||||||
sources:
|
sources:
|
||||||
|
|
@ -20,8 +14,37 @@ tasks:
|
||||||
cmds:
|
cmds:
|
||||||
- go fmt ./...
|
- 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:
|
test:
|
||||||
desc: Run unit tests
|
desc: Run unit tests
|
||||||
|
deps: [fmt, vet]
|
||||||
sources:
|
sources:
|
||||||
- '**/*.go'
|
- '**/*.go'
|
||||||
generates:
|
generates:
|
||||||
|
|
|
||||||
2
app.go
2
app.go
|
|
@ -27,7 +27,7 @@ type App struct {
|
||||||
|
|
||||||
func NewApp(ver string, conf config.Config, db store.Store) (*App, error) {
|
func NewApp(ver string, conf config.Config, db store.Store) (*App, error) {
|
||||||
if conf.BaseURL == "" {
|
if conf.BaseURL == "" {
|
||||||
return nil, errors.New("Missing BaseURL")
|
return nil, errors.New("missing BaseURL")
|
||||||
}
|
}
|
||||||
app := App{
|
app := App{
|
||||||
version: ver,
|
version: ver,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ func TestEmptyBaseURL(t *testing.T) {
|
||||||
c := config.Config{}
|
c := config.Config{}
|
||||||
a, er := NewApp("0.0.0", c, testmocks.GetStore())
|
a, er := NewApp("0.0.0", c, testmocks.GetStore())
|
||||||
assert.Nil(t, a)
|
assert.Nil(t, a)
|
||||||
assert.EqualError(t, er, "Missing BaseURL")
|
assert.EqualError(t, er, "missing BaseURL")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDefaultEnvironment(t *testing.T) {
|
func TestDefaultEnvironment(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue