Skip to content
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

update golangci configuration #131

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 83 additions & 35 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
run:
tests: true
timeout: 5m
allow-parallel-runners: true
timeout: 10m

linters:
disable-all: true
enable:
- bodyclose
- dogsled
- errcheck
- exportloopref
- errcheck # this is more reasonable than revive's version
- gci
- goconst
- gocritic
- gofumpt
Expand All @@ -19,50 +17,100 @@ linters:
- ineffassign
- misspell
- nakedret
- nolintlint
- revive
- staticcheck
- thelper
- typecheck
- stylecheck
- revive
- typecheck
- tenv
- unconvert
- unparam
- unparam # Prefer unparam over revive's unused param. It is more thorough in its checking.
- unused

# TODO: fix the errorsmod.Wrap deprecation warning and re-enable staticcheck
# TODO: fix the use of deprecated gov style
- misspell

issues:
exclude-rules:
- text: "simtypes"
- text: 'differs only by capitalization to method'
linters:
- staticcheck
- text: "Use of weak random number generator"
- revive
- text: 'Use of weak random number generator'
linters:
- gosec
- text: "ST1003:"
linters:
- stylecheck
# FIXME: Disabled until golangci-lint updates stylecheck with this fix:
# https://github.com/dominikh/go-tools/issues/389
- text: "ST1016:"
linters:
- stylecheck
- path: "migrations"
text: "SA1019:"
linters:
- linters:
- staticcheck
text: "SA1019:" # silence errors on usage of deprecated funcs

max-issues-per-linter: 10000
max-same-issues: 10000

linters-settings:
dogsled:
max-blank-identifiers: 3
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
nolintlint:
allow-unused: false
allow-leading-space: true
require-explanation: false
require-specific: false
gci:
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- blank # blank imports
- dot # dot imports
- prefix(cosmossdk.io)
- prefix(github.com/cosmos/cosmos-sdk)
- prefix(github.com/cometbft/cometbft)
- prefix(github.com/cosmos/ibc-go)
- prefix(github.com/iqlusioninc/liquidity-staking-module)
custom-order: true
revive:
enable-all-rules: true
# Do NOT whine about the following, full explanation found in:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#description-of-available-rules
rules:
- name: use-any
disabled: true
- name: if-return
disabled: true
- name: max-public-structs
disabled: true
- name: cognitive-complexity
disabled: true
- name: argument-limit
disabled: true
- name: cyclomatic
disabled: true
- name: file-header
disabled: true
- name: function-length
disabled: true
- name: function-result-limit
disabled: true
- name: line-length-limit
disabled: true
- name: flag-parameter
disabled: true
- name: add-constant
disabled: true
- name: empty-lines
disabled: true
- name: banned-characters
disabled: true
- name: deep-exit
disabled: true
- name: confusing-results
disabled: true
- name: unused-parameter
disabled: true
- name: modifies-value-receiver
disabled: true
- name: early-return
disabled: true
- name: confusing-naming
disabled: true
- name: defer
disabled: true
# Disabled in favour of unparam.
- name: unused-parameter
disabled: true
- name: unhandled-error
disabled: true
arguments:
- 'fmt.Printf'
- 'fmt.Print'
- 'fmt.Println'
- 'myFunction'
25 changes: 12 additions & 13 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import (
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
Expand Down Expand Up @@ -59,17 +62,21 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
distrclient "github.com/iqlusioninc/liquidity-staking-module/x/distribution/client"

"github.com/cosmos/cosmos-sdk/x/mint"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

distr "github.com/iqlusioninc/liquidity-staking-module/x/distribution"
distrclient "github.com/iqlusioninc/liquidity-staking-module/x/distribution/client"
distrkeeper "github.com/iqlusioninc/liquidity-staking-module/x/distribution/keeper"
distrtypes "github.com/iqlusioninc/liquidity-staking-module/x/distribution/types"
"github.com/iqlusioninc/liquidity-staking-module/x/genutil"
Expand All @@ -80,14 +87,6 @@ import (
"github.com/iqlusioninc/liquidity-staking-module/x/staking"
stakingkeeper "github.com/iqlusioninc/liquidity-staking-module/x/staking/keeper"
stakingtypes "github.com/iqlusioninc/liquidity-staking-module/x/staking/types"

"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
)

const appName = "SimApp"
Expand Down Expand Up @@ -477,7 +476,7 @@ func (app *SimApp) LoadHeight(height int64) error {
}

// ModuleAccountAddrs returns all the app's module account addresses.
func (app *SimApp) ModuleAccountAddrs() map[string]bool {
func (*SimApp) ModuleAccountAddrs() map[string]bool {
modAccAddrs := make(map[string]bool)
for acc := range maccPerms {
modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
Expand Down Expand Up @@ -543,7 +542,7 @@ func (app *SimApp) SimulationManager() *module.SimulationManager {

// RegisterAPIRoutes registers all application module routes with the provided
// API server.
func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
func (*SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
clientCtx := apiSvr.ClientCtx
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
Expand Down
7 changes: 4 additions & 3 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/iqlusioninc/liquidity-staking-module/x/distribution"
"github.com/iqlusioninc/liquidity-staking-module/x/slashing"
"github.com/iqlusioninc/liquidity-staking-module/x/staking"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
Expand All @@ -32,7 +29,11 @@ import (
"github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/upgrade"

"github.com/iqlusioninc/liquidity-staking-module/x/distribution"
"github.com/iqlusioninc/liquidity-staking-module/x/genutil"
"github.com/iqlusioninc/liquidity-staking-module/x/slashing"
"github.com/iqlusioninc/liquidity-staking-module/x/staking"
)

func TestSimAppExportAndBlockedAddrs(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkstaking "github.com/cosmos/cosmos-sdk/x/staking/types"

slashingtypes "github.com/iqlusioninc/liquidity-staking-module/x/slashing/types"
"github.com/iqlusioninc/liquidity-staking-module/x/staking"
stakingtypes "github.com/iqlusioninc/liquidity-staking-module/x/staking/types"
Expand Down
7 changes: 4 additions & 3 deletions app/genesis_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto"

"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
simapp "github.com/iqlusioninc/liquidity-staking-module/app"

"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto"
simapp "github.com/iqlusioninc/liquidity-staking-module/app"
)

func TestSimGenesisAccountValidate(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strings"
"testing"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
Expand All @@ -19,6 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/simapp/helpers"
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand All @@ -30,6 +30,7 @@ import (
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/simulation"

distrtypes "github.com/iqlusioninc/liquidity-staking-module/x/distribution/types"
slashingtypes "github.com/iqlusioninc/liquidity-staking-module/x/slashing/types"
stakingtypes "github.com/iqlusioninc/liquidity-staking-module/x/staking/types"
Expand Down
1 change: 1 addition & 0 deletions app/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
sdkstaking "github.com/cosmos/cosmos-sdk/x/staking/types"

stakingtypes "github.com/iqlusioninc/liquidity-staking-module/x/staking/types"
)

Expand Down
6 changes: 5 additions & 1 deletion app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stdstaking "github.com/cosmos/cosmos-sdk/x/staking/types"

stakingtypes "github.com/iqlusioninc/liquidity-staking-module/x/staking/types"
)

Expand Down Expand Up @@ -148,6 +149,7 @@ func genesisStateWithValSet(t *testing.T,
valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount,
balances ...banktypes.Balance,
) GenesisState {
t.Helper()
// set genesis accounts
authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs)
genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis)
Expand Down Expand Up @@ -398,6 +400,7 @@ func TestAddr(addr string, bech string) (sdk.AccAddress, error) {

// CheckBalance checks the balance of an account.
func CheckBalance(t *testing.T, app *SimApp, addr sdk.AccAddress, balances sdk.Coins) {
t.Helper()
ctxCheck := app.BaseApp.NewContext(true, tmproto.Header{})
require.True(t, balances.IsEqual(app.BankKeeper.GetAllBalances(ctxCheck, addr)))
}
Expand All @@ -410,6 +413,7 @@ func SignCheckDeliver(
t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg,
chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey,
) (sdk.GasInfo, *sdk.Result, error) {
t.Helper()
tx, err := helpers.GenSignedMockTx(
rand.New(rand.NewSource(time.Now().UnixNano())),
txCfg,
Expand Down Expand Up @@ -520,6 +524,6 @@ func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey) {
type EmptyAppOptions struct{}

// Get implements AppOptions
func (ao EmptyAppOptions) Get(_ string) interface{} {
func (EmptyAppOptions) Get(_ string) interface{} {
return nil
}
1 change: 1 addition & 0 deletions cmd/liquidstakingd/cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/require"

svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"

simapp "github.com/iqlusioninc/liquidity-staking-module/app"
"github.com/iqlusioninc/liquidity-staking-module/cmd/liquidstakingd/cmd"
"github.com/iqlusioninc/liquidity-staking-module/x/genutil/client/cli"
Expand Down
1 change: 1 addition & 0 deletions cmd/liquidstakingd/cmd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

"github.com/iqlusioninc/liquidity-staking-module/x/genutil"
genutiltypes "github.com/iqlusioninc/liquidity-staking-module/x/genutil/types"
)
Expand Down
8 changes: 4 additions & 4 deletions cmd/liquidstakingd/cmd/genaccounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import (
"fmt"
"testing"

"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/spf13/viper"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

simapp "github.com/iqlusioninc/liquidity-staking-module/app"
simcmd "github.com/iqlusioninc/liquidity-staking-module/cmd/liquidstakingd/cmd"
"github.com/iqlusioninc/liquidity-staking-module/x/genutil"
Expand Down
1 change: 1 addition & 0 deletions cmd/liquidstakingd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/crisis"

simapp "github.com/iqlusioninc/liquidity-staking-module/app"
genutilcli "github.com/iqlusioninc/liquidity-staking-module/x/genutil/client/cli"
)
Expand Down
Loading
Loading