Skip to content

Commit

Permalink
(feat) Added golangci configuration to include more validations in th…
Browse files Browse the repository at this point in the history
…e pre-commit run
  • Loading branch information
aarmoa committed Jun 4, 2024
1 parent cb865ec commit 9a3740b
Show file tree
Hide file tree
Showing 101 changed files with 398 additions and 350 deletions.
53 changes: 53 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"run": {
"tests": false,
},
"linters": {
"fast": false,
"enable": [
"errcheck",
"errorlint",
"gas",
"gocritic",
"gosimple",
"govet",
"ineffassign",
"megacheck",
"misspell",
"nakedret",
"prealloc",
"revive",
"staticcheck",
"unconvert",
"unparam",
],
"disable": [
"unused",
]
},
"linters-settings": {
"revive": {
"enableAllRules": true,
"rules": [
{
"name": "var-naming",
"arguments": [
["ID"]
]
}
]
},
"gocritic": {
"enabled-tags": [
"diagnostic",
"experimental",
"opinionated",
"performance",
"style",
],
"disabled-checks": [
"hugeParam",
]
}
},
}
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: end-of-file-fixer
- id: check-yaml
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.0
rev: master
hooks:
- id: go-fmt
- id: go-imports
Expand Down
4 changes: 2 additions & 2 deletions auth_vote/authz_vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func main() {
validators := []string{"inj156t3yxd4udv0h9gwagfcmwnmm3quy0npqc7pks", "inj16nd8yqxe9p6ggnrz58qr7dxn5y2834yendward"}
grantee := senderAddress.String()
proposalId := uint64(375)
var msgs []sdk.Msg
var msgs = make([]sdk.Msg, 0)

for _, validator := range validators {
msgVote := v1beta1.MsgVote{
Expand All @@ -92,7 +92,7 @@ func main() {
msgs = append(msgs, sdkMsg)
}

//AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg
// AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg
response, err := chainClient.AsyncBroadcastMsg(msgs...)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion chain/exchange/types/derivative_orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (o *DerivativeLimitOrder) GetCancelRefundAmount(feeRate math.LegacyDec) mat
if o.IsVanilla() {
// negative fees are only accounted for upon matching
positiveFeePart := math.LegacyMaxDec(math.LegacyZeroDec(), feeRate)
//nolint:all
// nolint:all
// Refund = (FillableQuantity / Quantity) * (Margin + Price * Quantity * feeRate)
notional := o.OrderInfo.Price.Mul(o.OrderInfo.Quantity)
marginHoldRefund = o.Fillable.Mul(o.Margin.Add(notional.Mul(positiveFeePart))).Quo(o.OrderInfo.Quantity)
Expand Down
6 changes: 2 additions & 4 deletions chain/exchange/types/spot_orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ func (m *SpotLimitOrder) GetUnfilledFeeAmount(fee math.LegacyDec) math.LegacyDec
return m.GetUnfilledNotional().Mul(fee)
}

func (m *SpotOrder) GetBalanceHoldAndMarginDenom(market *SpotMarket) (math.LegacyDec, string) {
var denom string
var balanceHold math.LegacyDec
func (m *SpotOrder) GetBalanceHoldAndMarginDenom(market *SpotMarket) (balanceHold math.LegacyDec, denom string) {
if m.IsBuy() {
denom = market.QuoteDenom
if m.OrderType.IsPostOnly() {
Expand All @@ -167,7 +165,7 @@ func (m *SpotOrder) GetBalanceHoldAndMarginDenom(market *SpotMarket) (math.Legac
return balanceHold, denom
}

func (m *SpotLimitOrder) GetUnfilledMarginHoldAndMarginDenom(market *SpotMarket, isTransient bool) (math.LegacyDec, string) {
func (m *SpotLimitOrder) GetUnfilledMarginHoldAndMarginDenom(market *SpotMarket, isTransient bool) (marginHold math.LegacyDec, marginDenom string) {
var denom string
var balanceHold math.LegacyDec
if m.IsBuy() {
Expand Down
2 changes: 1 addition & 1 deletion chain/peggy/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,6 @@ func validateSlashFractionBadEthSignature(i interface{}) error {
return nil
}

func validateValsetReward(i interface{}) error {
func validateValsetReward(_ interface{}) error {
return nil
}
8 changes: 4 additions & 4 deletions chain/permissions/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (m MsgCreateNamespace) Route() string { return routerKey }

func (m MsgCreateNamespace) Type() string { return "create_namespace" }

func (msg MsgCreateNamespace) ValidateBasic() error { return nil }
func (m MsgCreateNamespace) ValidateBasic() error { return nil }

func (m *MsgCreateNamespace) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshal(m))
Expand Down Expand Up @@ -84,7 +84,7 @@ func (m MsgUpdateNamespaceRoles) Route() string { return routerKey }

func (m MsgUpdateNamespaceRoles) Type() string { return "update_namespace_roles" }

func (msg MsgUpdateNamespaceRoles) ValidateBasic() error { return nil }
func (m MsgUpdateNamespaceRoles) ValidateBasic() error { return nil }

func (m *MsgUpdateNamespaceRoles) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshal(m))
Expand All @@ -101,7 +101,7 @@ func (m MsgRevokeNamespaceRoles) Route() string { return routerKey }

func (m MsgRevokeNamespaceRoles) Type() string { return "revoke_namespace_roles" }

func (msg MsgRevokeNamespaceRoles) ValidateBasic() error { return nil }
func (m MsgRevokeNamespaceRoles) ValidateBasic() error { return nil }

func (m *MsgRevokeNamespaceRoles) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshal(m))
Expand All @@ -118,7 +118,7 @@ func (m MsgClaimVoucher) Route() string { return routerKey }

func (m MsgClaimVoucher) Type() string { return "claim_voucher" }

func (msg MsgClaimVoucher) ValidateBasic() error { return nil }
func (m MsgClaimVoucher) ValidateBasic() error { return nil }

func (m *MsgClaimVoucher) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshal(m))
Expand Down
2 changes: 1 addition & 1 deletion chain/wasmx/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
var (
DefaultIsExecutionEnabled = false
DefaultMaxBeginBlockTotalGas uint64 = 42_000_000 // 42M
DefaultMaxContractGasLimit uint64 = DefaultMaxBeginBlockTotalGas / 12 // 3.5M
DefaultMaxContractGasLimit = DefaultMaxBeginBlockTotalGas / 12 // 3.5M
DefaultMinGasPrice uint64 = 1_000_000_000 // 1B
)

Expand Down
3 changes: 1 addition & 2 deletions chain/wasmx/types/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
)

func IsAllowed(accessConfig types.AccessConfig, actor types2.AccAddress) bool {
switch accessConfig.Permission {
case types.AccessTypeAnyOfAddresses:
if accessConfig.Permission == types.AccessTypeAnyOfAddresses {
for _, v := range accessConfig.Addresses {
if v == actor.String() {
return true
Expand Down
Loading

0 comments on commit 9a3740b

Please sign in to comment.