From a4eaab797200ac9370310c4543387cf0f4336bb6 Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Tue, 20 Jan 2026 11:52:10 +0100 Subject: [PATCH] ci: update golangci-lint The config had to be migrated using `golangci-lint migrate`. I disabled these new linters, can re-enable them in the future if desired (probably not): - wsl_v5 - funcorder - noinlineerr - perfsprint --- .github/workflows/ci.yml | 6 +- .golangci.yml | 197 +++++++++++++------------------ api/common/common.go | 4 +- api/firmware/attestation_test.go | 4 +- api/firmware/psbt.go | 2 +- go.mod | 2 +- 6 files changed, 92 insertions(+), 123 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0250d7c..d6a6ccb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,8 +3,8 @@ name: ci on: [push, pull_request] env: - GO_VERSION: "^1.22" - GOLANGCI_LINT_VERSION: "v1.62.0" + GO_VERSION: "^1.24" + GOLANGCI_LINT_VERSION: "v2.8.0" jobs: lint: @@ -32,7 +32,7 @@ jobs: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \ sh -s -- -b $HOME $GOLANGCI_LINT_VERSION - name: Lint - run: ~/golangci-lint run --skip-dirs=cmd/playground,cmd/miniscript + run: ~/golangci-lint run test: runs-on: ubuntu-22.04 steps: diff --git a/.golangci.yml b/.golangci.yml index 41f14cb..772398b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,134 +1,103 @@ -# See reference docs for details: -# https://golangci-lint.run/usage/configuration/ - -# options for analysis running +version: "2" run: - # default concurrency is a available CPU number concurrency: 4 - - # timeout for analysis, e.g. 30s, 5m, default is 1m - deadline: 10m - - # exit code when at least one issue was found, default is 1 issues-exit-code: 1 - - # include test files or not, default is true tests: true - -# output configuration options -output: - # print lines of code with issue, default is true - print-issued-lines: true - - # print linter name in the end of issue text, default is true - print-linter-name: true - - -# all available settings of specific linters -linters-settings: - gocritic: - enabled-checks: - - builtinShadow - - nilValReturn - - rangeExprCopy - - rangeValCopy - - typeUnparen - gocyclo: - min-complexity: 29 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true - dupl: - # tokens count to trigger issue, 150 by default - threshold: 150 - goconst: - # minimal length of string constant, 3 by default - min-len: 3 - # minimal occurrences count to trigger, 3 by default - min-occurrences: 3 - misspell: - # Correct spellings using locale preferences for US or UK. - # Default is to use a neutral variety of English. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - locale: US - lll: - # max line length, lines longer will be reported. Default is 120. - # '\t' is counted as 1 character by default, and can be changed with the tab-width option - line-length: 120 - # allow long comments. - exclude: '//' - linters: - enable-all: true + default: all disable: - - gosec - bodyclose + - cyclop + - depguard - dogsled - dupl + - err113 + - errname + - errorlint + - exhaustive + - exhaustruct + - forbidigo + - forcetypeassert + - funcorder - funlen - gochecknoglobals - gochecknoinits - gocognit + - gocyclo - godox - - lll - - nestif - - prealloc - - stylecheck - - whitespace - - wsl + - gosec + - gosmopolitan + - inamedparam + - interfacebloat - ireturn - - err113 - - wrapcheck - - varnamelen - - tagliatelle - - paralleltest - - nonamedreturns - - noctx - - nlreturn - - cyclop - - exhaustive - - nilnil - - nilerr - - forcetypeassert - - exhaustruct + - lll - maintidx - - errorlint - - gofumpt - - gci - - errname - - forbidigo - makezero - - nolintlint - - gocyclo - - interfacebloat - - revive + - mnd + - modernize - musttag - - depguard + - nestif + - nilerr + - nilnil + - nlreturn + - noctx + - noinlineerr + - nolintlint + - nonamedreturns + - paralleltest + - perfsprint + - prealloc - protogetter - - gosmopolitan - - inamedparam - # could not find a way to disable float-compare: https://github.com/golangci/golangci-lint/issues/4187 + - revive + - tagliatelle - testifylint - - mnd - disable-all: false - -issues: - # List of regexps of issue texts to exclude, empty list by default. - # But independently from this option we use default exclude patterns, - # it can be disabled by `exclude-use-default: false`. To list all - # excluded by default patterns execute `golangci-lint run --help` - exclude: - # Use linters in their original configuration. golangci-linter changes the default config, for - # example skipping the docstring comment checks of golint. - exclude-use-default: false - - # Excluding configuration per-path, per-linter, per-text and per-source. - exclude-rules: - # In addition to always disalbed linters above, exclude some more in tests. - - path: _test\.go - linters: - - errcheck - - gocyclo - - godot - - gosec - - testpackage + - varnamelen + - whitespace + - wrapcheck + - wsl + - wsl_v5 + settings: + dupl: + threshold: 150 + goconst: + min-len: 3 + min-occurrences: 3 + gocritic: + enabled-checks: + - builtinShadow + - nilValReturn + - rangeExprCopy + - rangeValCopy + - typeUnparen + gocyclo: + min-complexity: 29 + lll: + line-length: 120 + misspell: + locale: US + exclusions: + generated: lax + rules: + - linters: + - errcheck + - gocyclo + - godot + - gosec + - testpackage + path: _test\.go + paths: + - third_party$ + - builtin$ + - examples$ + - cmd/playground + - cmd/miniscript +formatters: + enable: + - gofmt + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/api/common/common.go b/api/common/common.go index 507f03f..96b64a1 100644 --- a/api/common/common.go +++ b/api/common/common.go @@ -45,10 +45,10 @@ const ( // btc-only edition firmware. It appears in the HID descriptor. FirmwareDeviceProductStringBitBox02PlusBTCOnly = "BitBox02 Nova BTC-only" - // BootloaderDeviceProductStringBitBox02Multi is the product string of the "BitBox02 Plus" multi + // BootloaderDeviceProductStringBitBox02PlusMulti is the product string of the "BitBox02 Plus" multi // edition bootloader. It appears in the HID descriptor. BootloaderDeviceProductStringBitBox02PlusMulti = "BitBox02 Nova Multi bl" - // BootloaderDeviceProductStringBitBox02BTCOnly is the product string of the "BitBox02 Plus" + // BootloaderDeviceProductStringBitBox02PlusBTCOnly is the product string of the "BitBox02 Plus" // btc-only edition bootloader. It appears in the HID descriptor and the Bluetooth // characteristic. BootloaderDeviceProductStringBitBox02PlusBTCOnly = "BitBox02 Nova BTC-only bl" diff --git a/api/firmware/attestation_test.go b/api/firmware/attestation_test.go index e9c4b14..124c89e 100644 --- a/api/firmware/attestation_test.go +++ b/api/firmware/attestation_test.go @@ -48,9 +48,9 @@ func makeCertificate(rootPrivkey *btcec.PrivateKey, bootloaderHash []byte, devic func p256PrivKeyFromBytes(k []byte) *ecdsa.PrivateKey { priv := new(ecdsa.PrivateKey) c := elliptic.P256() - priv.PublicKey.Curve = c + priv.Curve = c priv.D = new(big.Int).SetBytes(k) - priv.PublicKey.X, priv.PublicKey.Y = c.ScalarBaseMult(k) + priv.X, priv.Y = c.ScalarBaseMult(k) return priv } diff --git a/api/firmware/psbt.go b/api/firmware/psbt.go index 1ab5dcb..36b63df 100644 --- a/api/firmware/psbt.go +++ b/api/firmware/psbt.go @@ -594,7 +594,7 @@ func newBTCTxFromPSBT( }, nil } -// Sign a PSBT. If `options` is nil, the default options are used. The PSBT input signatures will be +// BTCSignPSBT signs a PSBT. If `options` is nil, the default options are used. The PSBT input signatures will be // populated. func (device *Device) BTCSignPSBT( coin messages.BTCCoin, diff --git a/go.mod b/go.mod index fb1f069..60917e2 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/BitBoxSwiss/bitbox02-api-go -go 1.22 +go 1.24 require ( github.com/benma/miniscript-go v0.0.0-20240226152043-f7c34099edf9