Merge PR #4608: More linters - Gosec, staticcheck
This commit is contained in:
parent
c898dac6a9
commit
b2f8c58ec4
|
@ -50,22 +50,6 @@ jobs:
|
|||
- bin
|
||||
- profiles
|
||||
|
||||
lint:
|
||||
<<: *linux_defaults
|
||||
parallelism: 1
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: /tmp/workspace
|
||||
- checkout
|
||||
- restore_cache:
|
||||
keys:
|
||||
- go-mod-v1-{{ checksum "go.sum" }}
|
||||
- run:
|
||||
name: Lint source
|
||||
command: |
|
||||
export PATH=/tmp/workspace/bin:$PATH
|
||||
make ci-lint
|
||||
|
||||
test_sim_app_nondeterminism:
|
||||
<<: *linux_defaults
|
||||
parallelism: 1
|
||||
|
@ -284,9 +268,6 @@ workflows:
|
|||
tags:
|
||||
only:
|
||||
- /^v.*/
|
||||
- lint:
|
||||
requires:
|
||||
- setup_dependencies
|
||||
- test_sim_app_nondeterminism:
|
||||
requires:
|
||||
- setup_dependencies
|
||||
|
|
|
@ -10,6 +10,8 @@ linters:
|
|||
- unused
|
||||
- deadcode
|
||||
- goconst
|
||||
- gosec
|
||||
- staticcheck
|
||||
linters-settings:
|
||||
gocyclo:
|
||||
min-complexity: 11
|
||||
|
|
|
@ -65,7 +65,6 @@ func GetCheckPassword(prompt, prompt2 string, buf *bufio.Reader) (string, error)
|
|||
// "y", "Y", "yes", "YES", and "Yes" all count as confirmations.
|
||||
// If the input is not recognized, it returns false and a nil error.
|
||||
func GetConfirmation(prompt string, buf *bufio.Reader) (bool, error) {
|
||||
for {
|
||||
if inputIsTty() {
|
||||
fmt.Print(fmt.Sprintf("%s [y/N]: ", prompt))
|
||||
}
|
||||
|
@ -82,7 +81,6 @@ func GetConfirmation(prompt string, buf *bufio.Reader) (bool, error) {
|
|||
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
// GetString simply returns the trimmed string output of a given reader.
|
||||
func GetString(prompt string, buf *bufio.Reader) (string, error) {
|
||||
|
|
|
@ -117,13 +117,16 @@ func BlockRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
|||
height, err := strconv.ParseInt(vars["height"], 10, 64)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest,
|
||||
"ERROR: Couldn't parse block height. Assumed format is '/block/{height}'.")
|
||||
"couldn't parse block height. Assumed format is '/block/{height}'.")
|
||||
return
|
||||
}
|
||||
chainHeight, err := GetChainHeight(cliCtx)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, "failed to parse chain height")
|
||||
return
|
||||
}
|
||||
if height > chainHeight {
|
||||
rest.WriteErrorResponse(w, http.StatusNotFound,
|
||||
"ERROR: Requested block height is bigger then the chain length.")
|
||||
rest.WriteErrorResponse(w, http.StatusNotFound, "requested block height is bigger then the chain length")
|
||||
return
|
||||
}
|
||||
output, err := getBlock(cliCtx, &height)
|
||||
|
|
|
@ -161,13 +161,17 @@ func ValidatorSetRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
|||
|
||||
height, err := strconv.ParseInt(vars["height"], 10, 64)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, "ERROR: Couldn't parse block height. Assumed format is '/validatorsets/{height}'.")
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, "failed to parse block height; assumed format is '/validatorsets/{height}'")
|
||||
return
|
||||
}
|
||||
|
||||
chainHeight, err := GetChainHeight(cliCtx)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, "failed to parse chain height")
|
||||
return
|
||||
}
|
||||
if height > chainHeight {
|
||||
rest.WriteErrorResponse(w, http.StatusNotFound, "ERROR: Requested block height is bigger then the chain length.")
|
||||
rest.WriteErrorResponse(w, http.StatusNotFound, "requested block height is bigger then the chain length")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
// Get a free address for a test tendermint server
|
||||
// protocol is either tcp, http, etc
|
||||
func FreeTCPAddr() (addr, port string, err error) {
|
||||
l, err := net.Listen("tcp", "0.0.0.0:0")
|
||||
l, err := net.Listen("tcp", "localhost:0")
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
|
|
@ -99,6 +99,9 @@ func interceptLoadConfig() (conf *cfg.Config, err error) {
|
|||
|
||||
if conf == nil {
|
||||
conf, err = tcmd.ParseConfig() // NOTE: ParseConfig() creates dir/files as necessary.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
appConfigFilePath := filepath.Join(rootDir, "config/app.toml")
|
||||
|
|
|
@ -133,7 +133,6 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []str
|
|||
iter := sdk.KVStoreReversePrefixIterator(store, staking.ValidatorsKey)
|
||||
counter := int16(0)
|
||||
|
||||
var valConsAddrs []sdk.ConsAddress
|
||||
for ; iter.Valid(); iter.Next() {
|
||||
addr := sdk.ValAddress(iter.Key()[1:])
|
||||
validator, found := app.stakingKeeper.GetValidator(ctx, addr)
|
||||
|
@ -142,7 +141,6 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []str
|
|||
}
|
||||
|
||||
validator.UnbondingHeight = 0
|
||||
valConsAddrs = append(valConsAddrs, validator.ConsAddress())
|
||||
if applyWhiteList && !whiteListMap[addr.String()] {
|
||||
validator.Jailed = true
|
||||
}
|
||||
|
|
|
@ -97,7 +97,8 @@ func waitForHeight(height int64, url string) {
|
|||
var res *http.Response
|
||||
var err error
|
||||
for {
|
||||
res, err = http.Get(url)
|
||||
// Since this is in a testing file we are accepting nolint to be passed
|
||||
res, err = http.Get(url) //nolint:gosec
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -150,7 +151,7 @@ func WaitForStart(url string) {
|
|||
time.Sleep(time.Millisecond * 100)
|
||||
|
||||
var res *http.Response
|
||||
res, err = http.Get(url)
|
||||
res, err = http.Get(url) //nolint:gosec Error is arising in testing files, accepting nolint
|
||||
if err != nil || res == nil {
|
||||
continue
|
||||
}
|
||||
|
@ -214,3 +215,5 @@ var cdc = codec.New()
|
|||
func init() {
|
||||
ctypes.RegisterAmino(cdc)
|
||||
}
|
||||
|
||||
//DONTCOVER
|
||||
|
|
|
@ -214,10 +214,10 @@ func readUnsignedGenTxFile(cdc *codec.Codec, r io.Reader) (auth.StdTx, error) {
|
|||
|
||||
func writeSignedGenTx(cdc *codec.Codec, outputDocument string, tx auth.StdTx) error {
|
||||
outputFile, err := os.OpenFile(outputDocument, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0644)
|
||||
defer outputFile.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer outputFile.Close()
|
||||
json, err := cdc.MarshalJSON(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -163,7 +163,7 @@ func operationSimulateMsgVote(k gov.Keeper, acc simulation.Account, proposalID u
|
|||
acc = simulation.RandomAcc(r, accs)
|
||||
}
|
||||
|
||||
if proposalID < 0 {
|
||||
if proposalID < uint64(0) {
|
||||
var ok bool
|
||||
proposalID, ok = randomProposalID(r, k, ctx)
|
||||
if !ok {
|
||||
|
|
|
@ -42,6 +42,11 @@ func queryBonds(cliCtx context.CLIContext, endpoint string) http.HandlerFunc {
|
|||
bech32validator := vars["validatorAddr"]
|
||||
|
||||
delegatorAddr, err := sdk.AccAddressFromBech32(bech32delegator)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
validatorAddr, err := sdk.ValAddressFromBech32(bech32validator)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
|
||||
|
|
Loading…
Reference in New Issue