From af1b3124311ee058540aac1ba5b31ed2dcdd97f5 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Fri, 12 Jul 2024 14:22:05 -0500 Subject: [PATCH] feat(golangci): Add golangci-lint config --- .golangci.yaml | 81 +++++++++++++++++++++++++++++++++++++++++++ cmd/cmd.go | 4 +-- internal/game/game.go | 6 ++-- 3 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 .golangci.yaml diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..6783432 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,81 @@ +run: + timeout: 5m + +issues: + max-same-issues: 50 + +linters: + enable: + - asasalint + - asciicheck + - bidichk + - bodyclose + - copyloopvar + - decorder + - dupl + - durationcheck + - err113 + - errcheck + - errname + - errorlint + - exportloopref + - forbidigo + - gci + - ginkgolinter + - gocheckcompilerdirectives + - gochecknoglobals + - gochecknoinits + - gochecksumtype + - goconst + - gocritic + - godox + - gofumpt + - goheader + - goimports + - gomoddirectives + - gomodguard + - goprintffuncname + - gosec + - gosimple + - gosmopolitan + - govet + - importas + - inamedparam + - ineffassign + - interfacebloat + - intrange + - loggercheck + - makezero + - mirror + - musttag + - nakedret + - nilerr + - nilnil + - noctx + - nolintlint + - nonamedreturns + - nosprintfhostport + - perfsprint + - prealloc + - predeclared + - promlinter + - protogetter + - reassign + - revive + - rowserrcheck + - sloglint + - spancheck + - sqlclosecheck + - staticcheck + - stylecheck + - tenv + - testableexamples + - testifylint + - typecheck + - unconvert + - unparam + - unused + - usestdlibvars + - wastedassign + - whitespace + - zerologlint diff --git a/cmd/cmd.go b/cmd/cmd.go index 67ab07b..0d43d39 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -19,7 +19,7 @@ func New() *cobra.Command { cmd.Flags().StringP(config.FileFlag, "f", "", "Loads a pattern file on startup") if err := cmd.RegisterFlagCompletionFunc(config.FileFlag, - func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { return []string{".rle", ".cells"}, cobra.ShellCompDirectiveFilterFileExt }, ); err != nil { @@ -31,7 +31,7 @@ func New() *cobra.Command { return cmd } -func run(cmd *cobra.Command, args []string) error { +func run(cmd *cobra.Command, _ []string) error { if shell := cmd.Flag(config.CompletionFlag).Value.String(); shell != "" { return completion(cmd, shell) } diff --git a/internal/game/game.go b/internal/game/game.go index de298af..d58a987 100644 --- a/internal/game/game.go +++ b/internal/game/game.go @@ -72,10 +72,8 @@ func (g Game) Update(msg tea.Msg) (tea.Model, tea.Cmd) { ny = 0 } neighbors += g.tiles[ny][nx] - } else { - if ny >= 0 && ny < len(g.tiles) && nx >= 0 && nx < len(g.tiles[ny]) { - neighbors += g.tiles[ny][nx] - } + } else if ny >= 0 && ny < len(g.tiles) && nx >= 0 && nx < len(g.tiles[ny]) { + neighbors += g.tiles[ny][nx] } }