diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 202ae23..c0b195d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,3 +4,7 @@ updates: directory: "/" schedule: interval: "monthly" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 0392a5d..593beef 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -2,11 +2,16 @@ name: Static Analysis on: push: - branches: - - "*" + paths: + - "go.sum" + - "go.mod" + - "**.go" + - ".github/workflows/static-analysis.yml" + - ".golangci.yml" pull_request: - branches: - - "*" + +permissions: + contents: read jobs: build: @@ -19,22 +24,16 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 with: go-version: ${{ matrix.go-version }} id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3 - - - name: Install staticcheck - run: go install honnef.co/go/tools/cmd/staticcheck@v0.5.1 - - - name: Print staticcheck version - run: staticcheck -version + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: Run staticcheck - run: staticcheck ./... - - - name: Run go vet - run: go vet ./... + - name: Lint + uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1 + with: + args: --verbose + version: v1.63.4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6b6f16b..de105bb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,13 +21,13 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 with: go-version: ${{ matrix.go-version }} id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 # Run basic tests, we just want to make sure there is parity on Linux and # macOS, and back to the oldest version of Go this library supports. diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..7eff7e0 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,8 @@ +--- +output: + sort-results: true + +linters: + # Keep this list sorted alphabetically + enable: + - revive diff --git a/client_linux_integration_test.go b/client_linux_integration_test.go index a2a7dec..0d80dc5 100644 --- a/client_linux_integration_test.go +++ b/client_linux_integration_test.go @@ -52,14 +52,14 @@ func TestIntegrationLinuxConcurrent(t *testing.T) { } } -func execN(t *testing.T, n int, expect []string, worker_id int) { +func execN(t *testing.T, n int, expect []string, workerID int) { c := testClient(t) names := make(map[string]int) for i := 0; i < n; i++ { ifis, err := c.Interfaces() if err != nil { - panicf("[worker_id %d; iteration %d] failed to retrieve interfaces: %v", worker_id, i, err) + panicf("[worker_id %d; iteration %d] failed to retrieve interfaces: %v", workerID, i, err) } for _, ifi := range ifis { @@ -69,13 +69,13 @@ func execN(t *testing.T, n int, expect []string, worker_id int) { if _, err := c.StationInfo(ifi); err != nil { if !errors.Is(err, os.ErrNotExist) { - panicf("[worker_id %d; iteration %d] failed to retrieve station info for device %s: %v", worker_id, i, ifi.Name, err) + panicf("[worker_id %d; iteration %d] failed to retrieve station info for device %s: %v", workerID, i, ifi.Name, err) } } if _, err := c.SurveyInfo(ifi); err != nil { if !errors.Is(err, os.ErrNotExist) { - panicf("[worker_id %d; iteration %d] failed to retrieve survey info for device %s: %v", worker_id, i, ifi.Name, err) + panicf("[worker_id %d; iteration %d] failed to retrieve survey info for device %s: %v", workerID, i, ifi.Name, err) } } names[ifi.Name]++ @@ -85,10 +85,10 @@ func execN(t *testing.T, n int, expect []string, worker_id int) { for _, e := range expect { nn, ok := names[e] if !ok { - panicf("[worker_id %d] did not find interface %q during test", worker_id, e) + panicf("[worker_id %d] did not find interface %q during test", workerID, e) } if nn != n { - panicf("[worker_id %d] wanted to find %q %d times, found %d", worker_id, e, n, nn) + panicf("[worker_id %d] wanted to find %q %d times, found %d", workerID, e, n, nn) } } } diff --git a/wifi.go b/wifi.go index 39a814f..4e21893 100644 --- a/wifi.go +++ b/wifi.go @@ -197,9 +197,8 @@ func (l BSSLoad) String() string { return fmt.Sprintf("BSSLoad Version: %d stationCount: %d channelUtilization: %d/255 availableAdmissionCapacity: %d [*32us/s]\n", l.Version, l.StationCount, l.ChannelUtilization, l.AvailableAdmissionCapacity, ) - } else { - return fmt.Sprintf("invalid BSSLoad Version: %d", l.Version) } + return fmt.Sprintf("invalid BSSLoad Version: %d", l.Version) } // A BSS is an 802.11 basic service set. It contains information about a wireless