-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gometalinter -> golangci-lint migration #3933
Changes from 14 commits
8df582c
ca376bd
9c4a074
877c91a
367c5a3
bd033d0
1a510b5
b226049
70da636
4970e6a
471f8c0
bb80138
add88ab
b09c76c
0712cde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
linters: | ||
disable-all: true | ||
enable: | ||
- errcheck | ||
- golint | ||
- ineffassign | ||
- unconvert | ||
- misspell | ||
linters-settings: | ||
gocyclo: | ||
min-complexity: 11 | ||
errcheck: | ||
ignore: fmt:.*,io/ioutil:^Read.*,github.com/spf13/cobra:MarkFlagRequired,github.com/spf13/viper:BindPFlag | ||
golint: | ||
min-confidence: 1.1 | ||
run: | ||
tests: false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixed various linters warnings in the context of the gometalinter -> golangci-lint migration #3896. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,17 @@ type AddNewKey struct { | |
Index int `json:"index,string,omitempty"` | ||
} | ||
|
||
// NewAddNewKey constructs a new AddNewKey request structure. | ||
func NewAddNewKey(name, password, mnemonic string, account, index int) AddNewKey { | ||
alessio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return AddNewKey{ | ||
Name: name, | ||
Password: password, | ||
Mnemonic: mnemonic, | ||
Account: account, | ||
Index: index, | ||
} | ||
} | ||
|
||
// RecoverKeyBody recovers a key | ||
type RecoverKey struct { | ||
Password string `json:"password"` | ||
|
@@ -19,13 +30,26 @@ type RecoverKey struct { | |
Index int `json:"index,string,omitempty"` | ||
} | ||
|
||
// NewRecoverKey constructs a new RecoverKey request structure. | ||
func NewRecoverKey(password, mnemonic string, account, index int) RecoverKey { | ||
return RecoverKey{Password: password, Mnemonic: mnemonic, Account: account, Index: index} | ||
} | ||
|
||
// UpdateKeyReq requests updating a key | ||
type UpdateKeyReq struct { | ||
OldPassword string `json:"old_password"` | ||
NewPassword string `json:"new_password"` | ||
} | ||
|
||
// NewUpdateKeyReq constructs a new UpdateKeyReq structure. | ||
func NewUpdateKeyReq(old, new string) UpdateKeyReq { | ||
return UpdateKeyReq{OldPassword: old, NewPassword: new} | ||
} | ||
|
||
// DeleteKeyReq requests deleting a key | ||
type DeleteKeyReq struct { | ||
Password string `json:"password"` | ||
} | ||
|
||
// NewDeleteKeyReq constructs a new DeleteKeyReq structure. | ||
func NewDeleteKeyReq(password string) DeleteKeyReq { return DeleteKeyReq{Password: password} } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In go usually anything There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I used to believe so. Apparently the use of the |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,9 @@ func fingerprintForCertificate(certBytes []byte) (string, error) { | |
return "", err | ||
} | ||
h := sha256.New() | ||
h.Write(cert.Raw) | ||
if _, err := h.Write(cert.Raw); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: sha256's write actually doesn't err. This is perfect for a See: https://golang.org/src/crypto/sha256/sha256.go?s=4118:4138#L203 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah! Nice catch, didn't know about that, thanks! Nonetheless, certificates.go will be gone shortly - we intend to remove the |
||
return "", err | ||
} | ||
fingerprintBytes := h.Sum(nil) | ||
var buf bytes.Buffer | ||
for i, b := range fingerprintBytes { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,7 +227,7 @@ func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.AccAddress | |
genDoc, err := tmtypes.GenesisDocFromFile(genesisFile) | ||
require.Nil(t, err) | ||
genDoc.Validators = nil | ||
genDoc.SaveAs(genesisFile) | ||
require.NoError(t, genDoc.SaveAs(genesisFile)) | ||
genTxs := []json.RawMessage{} | ||
|
||
// append any additional (non-proposing) validators | ||
|
@@ -337,7 +337,7 @@ func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.AccAddress | |
|
||
cleanup = func() { | ||
logger.Debug("cleaning up LCD initialization") | ||
node.Stop() | ||
node.Stop() //nolint:errcheck | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we still have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
node.Wait() | ||
lcd.Close() | ||
} | ||
|
@@ -394,7 +394,7 @@ func startLCD(logger log.Logger, listenAddr string, cdc *codec.Codec, t *testing | |
if err != nil { | ||
return nil, err | ||
} | ||
go tmrpc.StartHTTPServer(listener, rs.Mux, logger) | ||
go tmrpc.StartHTTPServer(listener, rs.Mux, logger) //nolint:errcheck | ||
return listener, nil | ||
} | ||
|
||
|
@@ -559,7 +559,7 @@ func getKeys(t *testing.T, port string) []keys.KeyOutput { | |
|
||
// POST /keys Create a new account locally | ||
func doKeysPost(t *testing.T, port, name, password, mnemonic string, account int, index int) keys.KeyOutput { | ||
pk := clientkeys.AddNewKey{name, password, mnemonic, account, index} | ||
pk := clientkeys.NewAddNewKey(name, password, mnemonic, account, index) | ||
req, err := cdc.MarshalJSON(pk) | ||
require.NoError(t, err) | ||
|
||
|
@@ -585,7 +585,7 @@ func getKeysSeed(t *testing.T, port string) string { | |
|
||
// POST /keys/{name}/recove Recover a account from a seed | ||
func doRecoverKey(t *testing.T, port, recoverName, recoverPassword, mnemonic string, account uint32, index uint32) { | ||
pk := clientkeys.RecoverKey{recoverPassword, mnemonic, int(account), int(index)} | ||
pk := clientkeys.NewRecoverKey(recoverPassword, mnemonic, int(account), int(index)) | ||
req, err := cdc.MarshalJSON(pk) | ||
require.NoError(t, err) | ||
|
||
|
@@ -613,7 +613,7 @@ func getKey(t *testing.T, port, name string) keys.KeyOutput { | |
|
||
// PUT /keys/{name} Update the password for this account in the KMS | ||
func updateKey(t *testing.T, port, name, oldPassword, newPassword string, fail bool) { | ||
kr := clientkeys.UpdateKeyReq{oldPassword, newPassword} | ||
kr := clientkeys.NewUpdateKeyReq(oldPassword, newPassword) | ||
req, err := cdc.MarshalJSON(kr) | ||
require.NoError(t, err) | ||
keyEndpoint := fmt.Sprintf("/keys/%s", name) | ||
|
@@ -627,7 +627,7 @@ func updateKey(t *testing.T, port, name, oldPassword, newPassword string, fail b | |
|
||
// DELETE /keys/{name} Remove an account | ||
func deleteKey(t *testing.T, port, name, password string) { | ||
dk := clientkeys.DeleteKeyReq{password} | ||
dk := clientkeys.NewDeleteKeyReq(password) | ||
req, err := cdc.MarshalJSON(dk) | ||
require.NoError(t, err) | ||
keyEndpoint := fmt.Sprintf("/keys/%s", name) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit too much of restore_cache, should happen only in the required job, in this case setup_dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and when installing/downloading occurs.
I'll double check now to be sure which of those should keep it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setup_dependencies
is a job that runs only once. Other jobs need to restore the cache indipendently.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but are all of them using it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes