🛠 Add static analysis

This commit is contained in:
Dan Jones 2024-10-28 20:01:03 -05:00
commit 36ad4b260e
3 changed files with 32 additions and 8 deletions

View file

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

View file

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

View file

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