Skip to content

Commit 0817968

Browse files
committed
Merge branch 'golangci-upgrade'
2 parents 41ce864 + a49b4d5 commit 0817968

File tree

24 files changed

+52
-53
lines changed

24 files changed

+52
-53
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ env:
2121
# https://docs.github.com/en/packages/guides/pushing-and-pulling-docker-images
2222
#
2323
# Keep this in sync with default in scripts/travis-ci.sh.
24-
CI_IMAGE: ghcr.io/digitalbitbox/bitbox-wallet-app-ci:15
24+
CI_IMAGE: ghcr.io/digitalbitbox/bitbox-wallet-app-ci:16
2525
TRAVIS_BUILD_DIR: ${{github.workspace}}
2626

2727
jobs:

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ linters:
131131
- makezero
132132
- nolintlint
133133
- gocyclo
134+
- nosnakecase
135+
- interfacebloat
136+
- revive
134137
disable-all: false
135138

136139
issues:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ catch:
2121
@echo "Choose a make target."
2222
envinit:
2323
# Keep golangci-lint version in sync with what's in .github/workflows/ci.yml.
24-
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(GOPATH)/bin v1.46.1
24+
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(GOPATH)/bin v1.50.1
2525
go install github.com/vektra/mockery/v2@latest
2626
go install github.com/matryer/moq@latest
2727
go install golang.org/x/tools/cmd/goimports@latest

backend/accounts/account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ type Interface interface {
8383
VerifyAddress(addressID string) (bool, error)
8484

8585
TxNote(txID string) string
86-
// ProposeTxnote stores a note. The note is is persisted in the notes database upon calling
86+
// ProposeTxnote stores a note. The note is persisted in the notes database upon calling
8787
// SendTx(). This function must be called before `SendTx()`.
8888
ProposeTxNote(string)
8989
// SetTxNote sets a tx note and refreshes the account.

backend/accounts/notifier.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package accounts
1616

1717
// Notifier juggles transaction IDs for the purpose of notifications and unread counts.
18+
//
1819
//go:generate mockery -name Notifier
1920
type Notifier interface {
2021
// Put adds the id to the 'unnotified' set, unless it is already in the 'seen' set.

backend/accounts/transaction.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const (
3838
TxTypeSendSelf TxType = "sendSelf"
3939
)
4040

41-
// TxStatus is the the status of the tx and helps the frontend show the appropriate information.
41+
// TxStatus is the status of the tx and helps the frontend show the appropriate information.
4242
type TxStatus string
4343

4444
const (
@@ -123,7 +123,7 @@ type TransactionData struct {
123123
Nonce *uint64
124124
}
125125

126-
// isConfirmed returns true if the transaction has has at least one confirmation.
126+
// isConfirmed returns true if the transaction has at least one confirmation.
127127
func (tx *TransactionData) isConfirmed() bool {
128128
return tx.Height > 0
129129
}

backend/aopp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const (
6161
// Nothing is happening, we are waiting for an AOPP request.
6262
aoppStateInactive aoppState = "inactive"
6363
// The user is prompted to continue or cancel a new AOPP request. This is always the first state
64-
// when a new AOPP request is is handled.
64+
// when a new AOPP request is handled.
6565
aoppStateUserApproval aoppState = "user-approval"
6666
// No keystore is connected, so we are waiting for the user to insert and unlock their
6767
// device. This state is skipped if a keystore already exists.

backend/coins/btc/account.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ func (account *Account) ensureAddresses() {
621621

622622
defer account.Synchronizer.IncRequestsCounter()()
623623

624-
syncSequence := func(addressChain *addresses.AddressChain) error {
624+
syncSequence := func(addressChain *addresses.AddressChain) {
625625
for {
626626
newAddresses, err := addressChain.EnsureAddresses()
627627
if err != nil {
@@ -632,36 +632,24 @@ func (account *Account) ensureAddresses() {
632632
break
633633
}
634634
for _, address := range newAddresses {
635-
if err := account.subscribeAddress(address); err != nil {
636-
return errp.Wrap(err, "Failed to subscribe to address")
637-
}
635+
account.subscribeAddress(address)
638636
}
639637
}
640-
return nil
641638
}
642639
for _, subacc := range account.subaccounts {
643-
if err := syncSequence(subacc.receiveAddresses); err != nil {
644-
account.log.WithError(err).Panic(err)
645-
// TODO
646-
panic(err)
647-
}
648-
if err := syncSequence(subacc.changeAddresses); err != nil {
649-
account.log.WithError(err).Panic(err)
650-
// TODO
651-
panic(err)
652-
}
640+
syncSequence(subacc.receiveAddresses)
641+
syncSequence(subacc.changeAddresses)
653642
}
654643
}
655644

656-
func (account *Account) subscribeAddress(address *addresses.AccountAddress) error {
645+
func (account *Account) subscribeAddress(address *addresses.AccountAddress) {
657646
account.coin.Blockchain().ScriptHashSubscribe(
658647
account.Synchronizer.IncRequestsCounter,
659648
address.PubkeyScriptHashHex(),
660649
func(status string) {
661650
go account.onAddressStatus(address, status)
662651
},
663652
)
664-
return nil
665653
}
666654

667655
// Transactions implements accounts.Interface.

backend/coins/btc/addresses/addresschain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (addresses *AddressChain) LookupByScriptHashHex(hashHex blockchain.ScriptHa
112112
return addresses.addressesLookup[hashHex]
113113
}
114114

115-
// EnsureAddresses appends addresses to the address chain until there are `gapLimit` unused unused
115+
// EnsureAddresses appends addresses to the address chain until there are `gapLimit` unused
116116
// ones, and returns the new addresses.
117117
func (addresses *AddressChain) EnsureAddresses() ([]*AccountAddress, error) {
118118
defer addresses.addressesLock.Lock()()

backend/coins/btc/coin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func (coin *Coin) SmallestUnit() string {
243243
}
244244
}
245245

246-
// DecodeAddress decodes a btc/ltc address, checking that that the format matches the account coin
246+
// DecodeAddress decodes a btc/ltc address, checking that the format matches the account coin
247247
// type.
248248
func (coin *Coin) DecodeAddress(address string) (btcutil.Address, error) {
249249
btcAddress, err := btcutil.DecodeAddress(address, coin.Net())

backend/coins/coin/amount.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func NewAmountFromInt64(amount int64) Amount {
3838
}
3939

4040
// NewAmountFromString parses a user given coin amount, converting it from the default coin unit to
41-
// the the smallest unit.
41+
// the smallest unit.
4242
func NewAmountFromString(s string, unit *big.Int) (Amount, error) {
4343
// big.Rat parsing accepts rationals like "2/3". Exclude those, we only want decimals.
4444
if strings.ContainsRune(s, '/') {

backend/coins/coin/coin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
)
2323

2424
// Coin models the currency of a blockchain.
25+
//
2526
//go:generate moq -pkg mocks -out mocks/coin.go . Coin
2627
type Coin interface {
2728
observable.Interface

backend/coins/eth/account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ func (account *Account) newTx(args *accounts.TxProposalArgs) (*TxProposal, error
499499
From: account.address.Address,
500500
To: &contractAddress,
501501
Gas: 0,
502-
// Gas price has to be 0 for the the Etherscan EstimateGas call to succeed.
502+
// Gas price has to be 0 for the Etherscan EstimateGas call to succeed.
503503
GasPrice: big.NewInt(0),
504504
Value: big.NewInt(0),
505505
Data: erc20ContractData,

backend/coins/eth/coin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type Coin struct {
5959
}
6060

6161
// NewCoin creates a new coin with the given parameters.
62-
// transactionsSource: can be nil, in which case transactions will not be be processed (in other
62+
// transactionsSource: can be nil, in which case transactions will not be processed (in other
6363
// words, account.Transactions() will always be empty apart from the outgoing transactions which //
6464
// are stored in the local database).
6565
// For erc20 tokens, provide erc20Token using NewERC20Token() (otherwise keep nil).

backend/coins/eth/rpcclient/rpcclient.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
)
2626

2727
// Interface can be implemented to provide an Ethereum rpc client.
28+
//
2829
//go:generate moq -pkg mocks -out mocks/rpcclient.go . Interface
2930
type Interface interface {
3031
TransactionReceiptWithBlockNumber(

backend/devices/bitbox/device.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const (
8686
)
8787

8888
// CommunicationInterface contains functions needed to communicate with the device.
89+
//
8990
//go:generate mockery -name CommunicationInterface
9091
type CommunicationInterface interface {
9192
SendPlain(string) (map[string]interface{}, error)
@@ -588,7 +589,7 @@ func (dbb *Device) seed(pin, backupPassword, source, filename string) error {
588589
}
589590

590591
// CheckBackup uses the provided backup file and recovery password to check if they correspond to
591-
//the current wallet. Returns true if it matches, false if not.
592+
// the current wallet. Returns true if it matches, false if not.
592593
func (dbb *Device) CheckBackup(backupPassword, filename string) (bool, error) {
593594
if backupPassword == "" {
594595
return false, errp.New("invalid password")

backend/handlers/handlers_test.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,20 @@ import (
3232
// backendEnv is a backend environment implementation for testing.
3333
//
3434
// TODO: Move this to the test pkg. Unfortunately, there's imports cycle:
35-
// $ go vet ./backend/...
36-
// import cycle not allowed in test
37-
// package github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc/db/transactionsdb (test)
38-
// imports github.com/digitalbitbox/bitbox-wallet-app/util/test
39-
// imports github.com/digitalbitbox/bitbox-wallet-app/backend/devices/usb
40-
// imports github.com/digitalbitbox/bitbox-wallet-app/backend/devices/bitbox
41-
// imports github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc
42-
// imports github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc/db/transactionsdb
43-
// import cycle not allowed in test
44-
// package github.com/digitalbitbox/bitbox-wallet-app/backend/devices/bitbox (test)
45-
// imports github.com/digitalbitbox/bitbox-wallet-app/util/test
46-
// imports github.com/digitalbitbox/bitbox-wallet-app/backend/devices/usb
47-
// imports github.com/digitalbitbox/bitbox-wallet-app/backend/devices/bitbox
35+
//
36+
// $ go vet ./backend/...
37+
// import cycle not allowed in test
38+
// package github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc/db/transactionsdb (test)
39+
// imports github.com/digitalbitbox/bitbox-wallet-app/util/test
40+
// imports github.com/digitalbitbox/bitbox-wallet-app/backend/devices/usb
41+
// imports github.com/digitalbitbox/bitbox-wallet-app/backend/devices/bitbox
42+
// imports github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc
43+
// imports github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc/db/transactionsdb
44+
// import cycle not allowed in test
45+
// package github.com/digitalbitbox/bitbox-wallet-app/backend/devices/bitbox (test)
46+
// imports github.com/digitalbitbox/bitbox-wallet-app/util/test
47+
// imports github.com/digitalbitbox/bitbox-wallet-app/backend/devices/usb
48+
// imports github.com/digitalbitbox/bitbox-wallet-app/backend/devices/bitbox
4849
type backendEnv struct {
4950
Locale string // returned by NativeLocale
5051
}
@@ -74,7 +75,7 @@ func TestGetNativeLocale(t *testing.T) {
7475
defer back.Close()
7576

7677
h := handlers.NewHandlers(back, handlers.NewConnectionData(0, ""))
77-
r := httptest.NewRequest("GET", "/api/native-locale", nil)
78+
r := httptest.NewRequest(http.MethodGet, "/api/native-locale", nil)
7879
w := httptest.NewRecorder()
7980
h.Router.ServeHTTP(w, r)
8081
res := w.Result()

backend/keystore/keystore.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const (
3838
var ErrSigningAborted = errors.New("signing aborted by user")
3939

4040
// Keystore supports hardened key derivation according to BIP32 and signing of transactions.
41+
//
4142
//go:generate moq -pkg mocks -out mocks/keystore.go . Keystore
4243
type Keystore interface {
4344
// Type denotes the type of the keystore.

backend/rates/history.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func (updater *RateUpdater) fetchGeckoMarketRange(ctx context.Context, coin, fia
264264
"vs_currency": {gfiat},
265265
}
266266
endpoint := fmt.Sprintf("%s/coins/%s/market_chart/range?%s", updater.coingeckoURL, gcoin, param.Encode())
267-
req, err := http.NewRequest("GET", endpoint, nil)
267+
req, err := http.NewRequest(http.MethodGet, endpoint, nil)
268268
if err != nil {
269269
return err
270270
}

backend/rates/rates.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (updater *RateUpdater) LatestPriceForPair(coinUnit, fiat string) (float64,
177177
// The returned value may be imprecise if at arg matches no timestamp exactly.
178178
// In this case, linear interpolation is used as an approximation.
179179
// If no data is available with the given args, HistoricalPriceAt returns 0.
180-
// The latest rates can lag behind by many minutes (5-30min). Use `LatestPrice` get get the latest
180+
// The latest rates can lag behind by many minutes (5-30min). Use `LatestPrice` get the latest
181181
// rates.
182182
func (updater *RateUpdater) HistoricalPriceAt(coin, fiat string, at time.Time) float64 {
183183
updater.historyMu.RLock()
@@ -257,7 +257,7 @@ func (updater *RateUpdater) updateLast(ctx context.Context) {
257257
"vs_currencies": {simplePriceAllCurrencies},
258258
}
259259
endpoint := fmt.Sprintf("%s/simple/price?%s", updater.coingeckoURL, param.Encode())
260-
req, err := http.NewRequest("GET", endpoint, nil)
260+
req, err := http.NewRequest(http.MethodGet, endpoint, nil)
261261
if err != nil {
262262
updater.log.WithError(err).Error("could not create request")
263263
updater.last = nil

backend/signing/configuration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func (configs Configurations) ContainsRootFingerprint(rootFingerprint []byte) bo
241241
return false
242242
}
243243

244-
// FindScriptType returns the index of the the first configuration that is a Bitcoin configuration
244+
// FindScriptType returns the index of the first configuration that is a Bitcoin configuration
245245
// and uses the provided script type. Returns -1 if none is found.
246246
func (configs Configurations) FindScriptType(scriptType ScriptType) int {
247247
for idx, config := range configs {

scripts/travis-ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if [ "$TRAVIS_OS_NAME" == "linux" ]; then
1414
# Which docker image to use to run the CI. Defaults to Docker Hub.
1515
# Overwrite with CI_IMAGE=docker/image/path environment variable.
1616
# Keep this in sync with .github/workflows/ci.yml.
17-
: "${CI_IMAGE:=shiftcrypto/bitbox-wallet-app:15}"
17+
: "${CI_IMAGE:=shiftcrypto/bitbox-wallet-app:16}"
1818
# Time image pull to compare in the future.
1919
time docker pull "$CI_IMAGE"
2020

util/jsonp/jsonp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func MustMarshal(value interface{}) []byte {
2525
return jsonBytes
2626
}
2727

28-
// MustUnmarshal decodes json that that cannot fail. Panics on a decoding error.
28+
// MustUnmarshal decodes json that cannot fail. Panics on a decoding error.
2929
func MustUnmarshal(jsonBytes []byte, value interface{}) {
3030
if err := json.Unmarshal(jsonBytes, value); err != nil {
3131
panic(err)

util/test/tcp.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import (
2525

2626
// TCPServerCertKey is the private key of TCPServerCert in PEM encoding.
2727
// It was generated with:
28-
// openssl ecparam -out key.pem -name secp256r1 -genkey; cat key.pem
28+
//
29+
// openssl ecparam -out key.pem -name secp256r1 -genkey; cat key.pem
2930
const TCPServerCertKey = `
3031
-----BEGIN EC PRIVATE KEY-----
3132
MHcCAQEEIFlVUmHt+140ZsJz0i2QlFd9m3zLNKQ0FmadLADGWKJvoAoGCCqGSM49
@@ -36,9 +37,10 @@ jXbEaVL0nhsoi2DbNJbGzMaIBhyYrtaFAw==
3637

3738
// TCPServerCertPub is the TCPServerCert in PEM encoding.
3839
// It was generated with:
39-
// openssl req -new -key key.pem -x509 -nodes -days 10000 \
40-
// -subj '/CN=node.example.org' \
41-
// -addext 'subjectAltName=DNS:node.example.org'
40+
//
41+
// openssl req -new -key key.pem -x509 -nodes -days 10000 \
42+
// -subj '/CN=node.example.org' \
43+
// -addext 'subjectAltName=DNS:node.example.org'
4244
const TCPServerCertPub = `
4345
-----BEGIN CERTIFICATE-----
4446
MIIBTDCB8qADAgECAgkAqux29iMFU0UwCgYIKoZIzj0EAwIwGzEZMBcGA1UEAwwQ

0 commit comments

Comments
 (0)