From f2ad9b7fcc4a09a40e2c71738fcc2a60ef116bb1 Mon Sep 17 00:00:00 2001 From: Nahshon Unna-Tsameret Date: Wed, 14 Jun 2023 09:04:51 +0300 Subject: [PATCH] add the revive linter and fix findings --- .github/workflows/sanity.yml | 11 +++++------ .golangci.yml | 1 + controller/controller.go | 2 +- hat/hat.go | 3 +-- main.go | 3 +-- notifier/notifier.go | 4 ++-- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/sanity.yml b/.github/workflows/sanity.yml index 030b246..60b13d2 100644 --- a/.github/workflows/sanity.yml +++ b/.github/workflows/sanity.yml @@ -27,15 +27,14 @@ jobs: - name: Setup Go uses: actions/setup-go@v4 with: - go-version: 1.20 + go-version: "1.20" - name: lint uses: golangci/golangci-lint-action@v3 - - - name: ginkgo-lint - run: |- - go install github.com/nunnatsa/ginkgolinter/cmd/ginkgolinter@latest - ginkgolinter ./... + with: + version: v1.53.2 + skip-pkg-cache: true + args: --timeout=5m --out-${NO_FUTURE}format line-number - name: test run: make test diff --git a/.golangci.yml b/.golangci.yml index 531c5db..18a0ee9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,3 +1,4 @@ linters: enable: - ginkgolinter + - revive diff --git a/controller/controller.go b/controller/controller.go index c0a8c2e..f90b181 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -57,7 +57,7 @@ func (c *Controller) do() { c.screenEvents <- msg for { - var change *state.Change = nil + var change *state.Change select { case <-signals: diff --git a/hat/hat.go b/hat/hat.go index 52e3f4a..d5306ab 100644 --- a/hat/hat.go +++ b/hat/hat.go @@ -217,7 +217,6 @@ func findJoystickDeviceFile() (string, error) { if foundDevice && len(deviceName) > 0 { return eventFilePrefix + deviceName, nil // found - } else { - return "", fmt.Errorf("can't find the joystick device") } + return "", fmt.Errorf("can't find the joystick device") } diff --git a/main.go b/main.go index 6577887..c87f549 100644 --- a/main.go +++ b/main.go @@ -80,7 +80,6 @@ func main() { if err := server.ListenAndServe(); err != http.ErrServerClosed { log.Panic(err) - } else { - fmt.Println("\nGood Bye!") } + fmt.Println("\nGood Bye!") } diff --git a/notifier/notifier.go b/notifier/notifier.go index 37b6310..a815d58 100644 --- a/notifier/notifier.go +++ b/notifier/notifier.go @@ -10,7 +10,7 @@ type idProvider struct { counter uint64 } -func newIdProvider() *idProvider { +func newIDProvider() *idProvider { return &idProvider{ counter: 0, } @@ -29,7 +29,7 @@ type Notifier struct { func NewNotifier() *Notifier { return &Notifier{ clientMap: make(map[uint64]chan []byte), - idp: newIdProvider(), + idp: newIDProvider(), lock: &sync.Mutex{}, } }