diff --git a/.golangci.yaml b/.golangci.yaml index 12fe1c24c..08b8433ac 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,40 +1,63 @@ --- version: "2" +issues: + max-issues-per-linter: 1000 + max-same-issues: 1000 linters: default: none enable: + - bodyclose - copyloopvar + - cyclop - errcheck - errchkjson + - errorlint - goconst - gocritic - gosec - govet - ineffassign - misspell + - nilerr + - nilnil + - noctx + # - nolintlint # very good linter, but there are 109 issues to solve - prealloc + - revive - staticcheck + - unconvert - unparam - unused -settings: - gocritic: - disabled-checks: - - ifElseChain - - singleCaseSwitch -exclusions: - generated: lax - presets: - - comments - - common-false-positives - - legacy - - std-error-handling - rules: - - path: (.+)\.go$ - text: comment on exported (method|function|type|const|var) - paths: - - third_party$ - - builtin$ - - examples$ + - wastedassign + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - path: (.+)\.go$ + text: comment on exported (method|function|type|const|var) + paths: + - third_party$ + - builtin$ + - examples$ + settings: + errorlint: + errorf: false + cyclop: + max-complexity: 40 + gocritic: + disabled-checks: + - ifElseChain + - singleCaseSwitch + - commentFormatting + revive: + rules: + - name: context-as-argument + - name: error-return + - name: error-naming formatters: enable: - gofmt diff --git a/make/lint.mk b/make/lint.mk index f2d46c3ea..bbd7a8003 100644 --- a/make/lint.mk +++ b/make/lint.mk @@ -1,20 +1,6 @@ -SUBLINTERS = unused \ - misspell \ - gofmt \ - gocritic \ - goconst \ - ineffassign \ - unparam \ - staticcheck \ - revive \ - gosec \ - exportloopref \ - prealloc -# TODO: ^ gochecknoglobals - .PHONY: lint-go lint-go: $(GOLANGCI_LINT) - $(GOLANGCI_LINT_RUN) ./... --issues-exit-code=0 --timeout=10m + $(GOLANGCI_LINT) run ./... --timeout=10m .PHONY: lint-go-% lint-go-%: $(GOLANGCI_LINT) diff --git a/tests/upgrade/sdktypes.go b/tests/upgrade/sdktypes.go deleted file mode 100644 index 990506122..000000000 --- a/tests/upgrade/sdktypes.go +++ /dev/null @@ -1,56 +0,0 @@ -package upgrade - -import ( - "encoding/json" - - upgradetypes "cosmossdk.io/x/upgrade/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// These files defines sdk specific types necessary to perform upgrade simulation. -// we're not using SDK generated types to prevent import of different types of cosmos sdk - -type nodeStatus struct { - SyncInfo struct { - LatestBlockHeight string `json:"latest_block_height"` - CatchingUp bool `json:"catching_up"` - } `json:"sync_info"` -} - -type votingParams struct { - VotingPeriod string `json:"voting_period"` -} - -type depositParams struct { - MinDeposit sdk.Coins `json:"min_deposit"` -} - -type govParams struct { - VotingParams votingParams `json:"voting_params"` - DepositParams depositParams `json:"deposit_params"` -} - -type proposalResp struct { - ID string `json:"id"` - Title string `json:"title"` -} - -type proposalsResp struct { - Proposals []proposalResp `json:"proposals"` -} - -type SoftwareUpgradeProposal struct { - Type string `json:"@type"` - Authority string `json:"authority"` - Plan upgradetypes.Plan `json:"plan"` -} - -type ProposalMsg struct { - // Msgs defines an array of sdk.Msgs proto-JSON-encoded as Anys. - Messages []json.RawMessage `json:"messages,omitempty"` - Metadata string `json:"metadata"` - Deposit string `json:"deposit"` - Title string `json:"title"` - Summary string `json:"summary"` - Expedited bool `json:"expedited"` -} diff --git a/upgrades/software/v1.1.0/upgrade.go b/upgrades/software/v1.1.0/upgrade.go index 8e244037a..922ae9c81 100644 --- a/upgrades/software/v1.1.0/upgrade.go +++ b/upgrades/software/v1.1.0/upgrade.go @@ -360,6 +360,9 @@ func (up *upgrade) OnGroupClosed(ctx sdk.Context, id dv1.GroupID) error { func (up *upgrade) OnEscrowPaymentClosed(ctx sdk.Context, obj etypes.Payment) error { id, err := mv1.LeaseIDFromPaymentID(obj.ID) if err != nil { + // Escrow payments can belong to different scopes (e.g., bid-scoped, deployment-scoped). + // This upgrade hook only processes lease payments (deployment-scoped). + // Silently ignore non-lease payment closures. return nil } diff --git a/x/escrow/keeper/keeper_test.go b/x/escrow/keeper/keeper_test.go index b7c14d1d3..65acf367a 100644 --- a/x/escrow/keeper/keeper_test.go +++ b/x/escrow/keeper/keeper_test.go @@ -17,10 +17,6 @@ import ( "pkg.akt.dev/node/testutil/state" ) -type kTestSuite struct { - *state.TestSuite -} - func Test_AccountSettlement(t *testing.T) { ssuite := state.SetupTestSuite(t) ctx := ssuite.Context() diff --git a/x/market/handler/handler_test.go b/x/market/handler/handler_test.go index cc7641ee9..0f5181e59 100644 --- a/x/market/handler/handler_test.go +++ b/x/market/handler/handler_test.go @@ -1427,26 +1427,3 @@ func (st *testSuite) createProvider(attr attr.Attributes) ptypes.Provider { return prov } - -func (st *testSuite) createDeployment() (dv1.Deployment, dtypes.Groups) { - st.t.Helper() - - deployment := testutil.Deployment(st.t) - group := testutil.DeploymentGroup(st.t, deployment.ID, 0) - group.GroupSpec.Resources = dtypes.ResourceUnits{ - { - Resources: testutil.ResourceUnits(st.t), - Count: 1, - Price: testutil.AkashDecCoinRandom(st.t), - }, - } - groups := dtypes.Groups{ - group, - } - - for i := range groups { - groups[i].State = dtypes.GroupOpen - } - - return deployment, groups -} diff --git a/x/market/hooks/hooks.go b/x/market/hooks/hooks.go index 846252e69..cf834f291 100644 --- a/x/market/hooks/hooks.go +++ b/x/market/hooks/hooks.go @@ -70,7 +70,10 @@ func (h *hooks) OnEscrowAccountClosed(ctx sdk.Context, obj etypes.Account) error func (h *hooks) OnEscrowPaymentClosed(ctx sdk.Context, obj etypes.Payment) error { id, err := mv1.LeaseIDFromPaymentID(obj.ID) if err != nil { - return nil + // Escrow payments can belong to different scopes (e.g., bid-scoped, deployment-scoped). + // Market module only handles lease payments (deployment-scoped). + // Silently ignore non-lease payment closures. + return nil //nolint:nilerr // non-lease payment, not an error for this hook } bid, ok := h.mkeeper.GetBid(ctx, id.BidID())