Merge PR #4881: Linting Galore

This commit is contained in:
Marko
2019-08-19 12:06:27 -04:00
committed by Alexander Bezobchuk
parent 89b1220398
commit 3a4f1fc4d4
75 changed files with 209 additions and 284 deletions
+1 -1
View File
@@ -119,7 +119,7 @@ func VerifyAddressFormat(bz []byte) error {
return verifier(bz)
}
if len(bz) != AddrLen {
return errors.New("Incorrect address length")
return errors.New("incorrect address length")
}
return nil
}
+4 -4
View File
@@ -495,12 +495,12 @@ func (coins Coins) AmountOf(denom string) Int {
default:
midIdx := len(coins) / 2 // 2:1, 3:1, 4:2
coin := coins[midIdx]
if denom < coin.Denom {
switch {
case denom < coin.Denom:
return coins[:midIdx].AmountOf(denom)
} else if denom == coin.Denom {
case denom == coin.Denom:
return coin.Amount
} else {
default:
return coins[midIdx+1:].AmountOf(denom)
}
}
+4 -3
View File
@@ -423,11 +423,12 @@ func (coins DecCoins) AmountOf(denom string) Dec {
midIdx := len(coins) / 2 // 2:1, 3:1, 4:2
coin := coins[midIdx]
if denom < coin.Denom {
switch {
case denom < coin.Denom:
return coins[:midIdx].AmountOf(denom)
} else if denom == coin.Denom {
case denom == coin.Denom:
return coin.Amount
} else {
default:
return coins[midIdx+1:].AmountOf(denom)
}
}
+2 -2
View File
@@ -149,7 +149,7 @@ func NewDecFromStr(str string) (d Dec, err Error) {
if lenDecs == 0 || len(combinedStr) == 0 {
return d, ErrUnknownRequest("bad decimal length")
}
combinedStr = combinedStr + strs[1]
combinedStr += strs[1]
} else if len(strs) > 2 {
return d, ErrUnknownRequest("too many periods to be a decimal string")
@@ -163,7 +163,7 @@ func NewDecFromStr(str string) (d Dec, err Error) {
// add some extra zero's to correct to the Precision factor
zerosToAdd := Precision - lenDecs
zeros := fmt.Sprintf(`%0`+strconv.Itoa(zerosToAdd)+`s`, "")
combinedStr = combinedStr + zeros
combinedStr += zeros
combined, ok := new(big.Int).SetString(combinedStr, 10) // base 10
if !ok {
+2 -4
View File
@@ -150,10 +150,8 @@ func TestABCIInfoStacktrace(t *testing.T) {
if !strings.Contains(log, tc.wantErrMsg) {
t.Errorf("log does not contain expected error message: %s", log)
}
} else {
if log != tc.wantErrMsg {
t.Fatalf("unexpected log message: %s", log)
}
} else if log != tc.wantErrMsg {
t.Fatalf("unexpected log message: %s", log)
}
})
}
+4 -4
View File
@@ -247,9 +247,9 @@ func PostProcessResponseBare(w http.ResponseWriter, cliCtx context.CLIContext, b
err error
)
switch body.(type) {
switch b := body.(type) {
case []byte:
resp = body.([]byte)
resp = b
default:
if cliCtx.Indent {
@@ -279,9 +279,9 @@ func PostProcessResponse(w http.ResponseWriter, cliCtx context.CLIContext, resp
return
}
switch resp.(type) {
switch res := resp.(type) {
case []byte:
result = resp.([]byte)
result = res
default:
var err error
-2
View File
@@ -18,8 +18,6 @@ import (
"github.com/cosmos/cosmos-sdk/types"
)
type mockResponseWriter struct{}
func TestBaseReqValidateBasic(t *testing.T) {
fromAddr := "cosmos1cq0sxam6x4l0sv9yz3a2vlqhdhvt2k6jtgcse0"
tenstakes, err := types.ParseCoins("10stake")