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

Konradstaniec/fix linter config #329

Merged
merged 2 commits into from
Dec 9, 2024
Merged
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
142 changes: 58 additions & 84 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,103 +1,77 @@
run:
timeout: 5m
# TODO: enable all linters
linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- cyclop
- decorder
- depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
- exhaustivestruct
- exhaustruct
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
# - bodyclose
# - containedctx
# - contextcheck
# - decorder
# - dogsled
# - durationcheck
# - errcheck
# - errchkjson
# - errname
# - errorlint
# - exhaustive
# - forbidigo
# - forcetypeassert
- goconst
- gocritic
- gocyclo
- godot
- godox
- goerr113
- gofumpt
- goheader
- golint
- gomnd
- gomoddirectives
- gomodguard
# - gocritic
# - gocyclo
# - goheader
# - gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- ifshort
- importas
- ineffassign
- interfacebloat
- interfacer
- ireturn
- lll
- loggercheck
- maintidx
- makezero
- maligned
# - grouper
# - importas
# - ineffassign
# - loggercheck
# - maintidx
# - makezero
- misspell
- nakedret
- nestif
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
- nonamedreturns
- nosnakecase
- nosprintfhostport
- paralleltest
- prealloc
- predeclared
- promlinter
- reassign
- revive
- rowserrcheck
- scopelint
- sqlclosecheck
# - nakedret
# - nilerr
# - nlreturn
# - noctx
# - nosprintfhostport
# - paralleltest
# - reassign
# - revive
# - rowserrcheck
# - sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- tagliatelle
- tenv
- testableexamples
- testpackage
- thelper
- tparallel
# - stylecheck
# - tenv
# - testableexamples
# - tparallel
- typecheck
- unconvert
- unparam
# - unconvert
# - unparam
# - usestdlibvars
- unused
- usestdlibvars
- varcheck
- varnamelen
- wastedassign
# - wastedassign
- whitespace
- wrapcheck
- wsl
# - wrapcheck

issues:
max-same-issues: 0
# Default: https://golangci-lint.run/usage/false-positives/#default-exclusions
exclude-dirs:
- e2etest
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec
- path-except: _test\.go
linters:
- forbidigo
1 change: 0 additions & 1 deletion app/ante/ante_btc_validation_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func NewBtcValidationDecorator(
}

func (bvd BtcValidationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {

// only do this validation when handling mempool addition. During DeliverTx they
// should be performed by btclightclient and btccheckpoint modules
if ctx.IsCheckTx() || ctx.IsReCheckTx() {
Expand Down
2 changes: 0 additions & 2 deletions btcstaking/btcstaking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ func GenerateSignatures(
stakingOutput *wire.TxOut,
leaf txscript.TapLeaf,
) []*schnorr.Signature {

var si []*SignatureInfo

for _, key := range keys {
Expand Down Expand Up @@ -293,7 +292,6 @@ func TestSpendingUnbondingPathCovenant35MultiSig(t *testing.T) {
)
}
btctest.AssertEngineExecution(t, 0, true, newEngine)

}

func TestSpendingUnbondingPathSingleKeyCovenant(t *testing.T) {
Expand Down
5 changes: 0 additions & 5 deletions btcstaking/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ func validateSlashingTx(
slashingChangeLockTime uint16,
net *chaincfg.Params,
) error {

if err := CheckPreSignedSlashingTxSanity(slashingTx); err != nil {
return fmt.Errorf("invalid slashing tx: %w", err)
}
Expand Down Expand Up @@ -470,7 +469,6 @@ func signTxWithOneScriptSpendInputFromTapLeafInternal(
fundingOutput *wire.TxOut,
privKey *btcec.PrivateKey,
tapLeaf txscript.TapLeaf) (*schnorr.Signature, error) {

inputFetcher := txscript.NewCannedPrevOutputFetcher(
fundingOutput.PkScript,
fundingOutput.Value,
Expand Down Expand Up @@ -558,7 +556,6 @@ func SignTxWithOneScriptSpendInputStrict(
signedScriptPath []byte,
privKey *btcec.PrivateKey,
) (*schnorr.Signature, error) {

if err := checkTxBeforeSigning(txToSign, fundingTx, fundingOutputIdx); err != nil {
return nil, fmt.Errorf("invalid tx: %w", err)
}
Expand All @@ -579,7 +576,6 @@ func EncSignTxWithOneScriptSpendInputStrict(
privKey *btcec.PrivateKey,
encKey *asig.EncryptionKey,
) (*asig.AdaptorSignature, error) {

if err := checkTxBeforeSigning(txToSign, fundingTx, fundingOutputIdx); err != nil {
return nil, fmt.Errorf("invalid tx: %w", err)
}
Expand Down Expand Up @@ -650,7 +646,6 @@ func VerifyTransactionSigWithOutput(
script []byte,
pubKey *btcec.PublicKey,
signature []byte) error {

if fundingOutput == nil {
return fmt.Errorf("funding output must not be nil")
}
Expand Down
1 change: 0 additions & 1 deletion btcstaking/staking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func NewStakingScriptData(
fpKey,
covenantKey *btcec.PublicKey,
stakingTime uint16) (*StakingScriptData, error) {

if stakerKey == nil || fpKey == nil || covenantKey == nil {
return nil, fmt.Errorf("staker, finality provider and covenant keys cannot be nil")
}
Expand Down
4 changes: 1 addition & 3 deletions btcstaking/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func DeriveTaprootAddress(
tapScriptTree *txscript.IndexedTapScriptTree,
internalPubKey *btcec.PublicKey,
net *chaincfg.Params) (*btcutil.AddressTaproot, error) {

tapScriptRootHash := tapScriptTree.RootNode.TapHash()

outputKey := txscript.ComputeTaprootOutputKey(
Expand Down Expand Up @@ -181,7 +180,7 @@ func (t *taprootScriptHolder) taprootPkScript(net *chaincfg.Params) ([]byte, err
// Package responsible for different kinds of btc scripts used by babylon
// Staking script has 3 spending paths:
// 1. Staker can spend after relative time lock - staking
// 2. Staker can spend with covenat cooperation any time
// 2. Staker can spend with covenant cooperation any time
// 3. Staker can spend with finality provider and covenant cooperation any time.
type StakingInfo struct {
StakingOutput *wire.TxOut
Expand Down Expand Up @@ -222,7 +221,6 @@ func SpendInfoFromRevealedScript(
revealedScript []byte,
internalKey *btcec.PublicKey,
tree *txscript.IndexedTapScriptTree) (*SpendInfo, error) {

revealedLeaf := txscript.NewBaseTapLeaf(revealedScript)
leafHash := revealedLeaf.TapHash()

Expand Down
4 changes: 0 additions & 4 deletions btctxformatter/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func encodeFirstOpRetrun(
bitMap []byte,
submitterAddress []byte,
) []byte {

var serializedBytes = []byte{}

serializedBytes = append(serializedBytes, encodeHeader(tag, version, firstPartIndex)...)
Expand Down Expand Up @@ -148,7 +147,6 @@ func EncodeCheckpointData(
version FormatVersion,
rawBTCCheckpoint *RawBtcCheckpoint,
) ([]byte, []byte, error) {

if len(tag) != TagLength {
return nil, nil, errors.New("tag should have 4 bytes")
}
Expand Down Expand Up @@ -247,7 +245,6 @@ func GetCheckpointData(
partIndex uint8,
data []byte,
) ([]byte, error) {

if partIndex > 1 {
return nil, errors.New("invalid part index")
}
Expand Down Expand Up @@ -290,7 +287,6 @@ func IsBabylonCheckpointData(
version FormatVersion,
data []byte,
) (*BabylonData, error) {

var idx uint8 = 0

for idx < NumberOfParts {
Expand Down
1 change: 0 additions & 1 deletion btctxformatter/formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func FuzzEncodingDecoding(f *testing.F) {
f.Add(uint64(2000), randNBytes(TagLength), randNBytes(BlockHashLength), randNBytes(BitMapLength), randNBytes(BlsSigLength), randNBytes(AddressLength))

f.Fuzz(func(t *testing.T, epoch uint64, tag []byte, appHash []byte, bitMap []byte, blsSig []byte, address []byte) {

if len(tag) < TagLength {
t.Skip("Tag should have 4 bytes")
}
Expand Down
2 changes: 0 additions & 2 deletions cmd/babylond/cmd/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ func PrepareGenesis(

if genesis.Consensus == nil {
genesis.Consensus = genutiltypes.NewConsensusGenesis(comettypes.DefaultConsensusParams().ToProto(), nil)

}

// Set gas limit
Expand Down Expand Up @@ -305,7 +304,6 @@ func TestnetGenesisParams(
jailDuration time.Duration,
finalityActivationBlockHeight uint64,
) GenesisParams {

genParams := GenesisParams{}

genParams.GenesisTime = genesisTime
Expand Down
1 change: 0 additions & 1 deletion cmd/babylond/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ func appExport(
appOpts servertypes.AppOptions,
modulesToExport []string,
) (servertypes.ExportedApp, error) {

var babylonApp *app.BabylonApp
homePath, ok := appOpts.Get(flags.FlagHome).(string)
if !ok || homePath == "" {
Expand Down
4 changes: 0 additions & 4 deletions cmd/babylond/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ func InitTestnet(
valAddrCodec runtime.ValidatorAddressCodec,
genesisParams GenesisParams,
) error {

nodeIDs := make([]string, numValidators)
valKeys := make([]*privval.ValidatorKeys, numValidators)

Expand Down Expand Up @@ -398,7 +397,6 @@ func InitTestnet(

genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()})
genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0))

}
}

Expand All @@ -424,7 +422,6 @@ func initGenFiles(
genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance,
genFiles []string, genKeys []*checkpointingtypes.GenesisKey, numValidators int, genesisParams GenesisParams,
) error {

appGenState := mbm.DefaultGenesis(clientCtx.Codec)

// set the accounts in the genesis state
Expand Down Expand Up @@ -465,7 +462,6 @@ func collectGenFiles(
nodeIDs []string, genKeys []*checkpointingtypes.GenesisKey, numValidators int,
outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator,
) error {

var appState json.RawMessage
genTime := cmttime.Now()

Expand Down
1 change: 0 additions & 1 deletion crypto/bip322/bip322.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ func Verify(
witness wire.TxWitness,
address btcutil.Address,
net *chaincfg.Params) error {

toSpend, err := GetToSpendTx(msg, address)
if err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion test/e2e/initialization/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ func initGenesis(
if err = genutil.ExportGenesisFile(genDoc, path); err != nil {
return fmt.Errorf("failed to export app genesis state: %w", err)
}

}
return nil
}
Expand Down
1 change: 0 additions & 1 deletion testutil/bitcoin/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
// https://github.com/lightningnetwork/lnd/blob/master/input/script_utils_test.go#L24
func AssertEngineExecution(t *testing.T, testNum int, valid bool,
newEngine func() (*txscript.Engine, error)) {

t.Helper()

// Get a new VM to execute.
Expand Down
1 change: 0 additions & 1 deletion testutil/datagen/btc_header_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func calculateAdjustedDifficulty(
lastRetargetHeader *wire.BlockHeader,
currentHeaderTimestamp time.Time,
params *chaincfg.Params) uint32 {

targetTimespan := int64(params.TargetTimespan / time.Second)
adjustmentFactor := params.RetargetAdjustmentFactor
minRetargetTimespan := targetTimespan / adjustmentFactor
Expand Down
Loading
Loading