From 36ad4b260ec1f227dabca7287c19334c5394a6ba Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Mon, 28 Oct 2024 20:01:03 -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 | 26 ++++++++++++++++++++++++++ cli/spin/spin.go | 7 ++++--- convids/methods.go | 7 ++----- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 77b972d..8be3d99 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -9,6 +9,32 @@ tasks: - "**/*.go" 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 + cmd-build: internal: true cmds: diff --git a/cli/spin/spin.go b/cli/spin/spin.go index 2896335..3d0a804 100644 --- a/cli/spin/spin.go +++ b/cli/spin/spin.go @@ -82,11 +82,12 @@ func (s *spin) SetMessage(msg string) { } func (s *spin) Err() error { - if errors.Is(s.err, context.Canceled) { + switch { + case errors.Is(s.err, context.Canceled): return nil - } else if errors.Is(s.err, context.DeadlineExceeded) { + case errors.Is(s.err, context.DeadlineExceeded): return nil - } else if errors.Is(s.err, tea.ErrProgramKilled) { + case errors.Is(s.err, tea.ErrProgramKilled): return nil } return s.err diff --git a/convids/methods.go b/convids/methods.go index 69ce198..8162848 100644 --- a/convids/methods.go +++ b/convids/methods.go @@ -38,10 +38,7 @@ func (s *Show) matchRegexp(path string) (f bool, err error) { if s.re == nil { p := s.Pattern if s.Anime { - if strings.HasPrefix(p, "^") { - p = strings.TrimPrefix(p, "^") - } - p = animePattern + p + p = animePattern + strings.TrimPrefix(p, "^") } else if !strings.HasPrefix(p, "^") { p = "^" + p } @@ -71,7 +68,7 @@ func (d *Data) AllShows(silent bool) iter.Seq[*Show] { continue } if !silent { - fmt.Println("Checking", show, "shows\n") + fmt.Printf("Checking %s shows\n\n", show) } for s := range sh.All() { if s == nil {