From bc385104ba2ae11e8a2f1aa2aa85320d488ae745 Mon Sep 17 00:00:00 2001 From: harry <53987565+h5law@users.noreply.github.com> Date: Mon, 23 Oct 2023 22:52:33 +0100 Subject: [PATCH] chore: enforce go standard interface implementation registration (#87) --- .github/workflows/reviewdog.yml | 16 +++++++++++++++- e2e/tests/node.go | 2 +- pkg/observable/channel/observable.go | 2 +- pkg/observable/channel/observer.go | 2 +- pkg/relayer/proxy/proxy.go | 2 +- .../types/message_delegate_to_gateway.go | 2 +- x/application/types/message_stake_application.go | 2 +- .../types/message_undelegate_from_gateway.go | 2 +- .../types/message_unstake_application.go | 2 +- x/gateway/types/message_stake_gateway.go | 2 +- x/gateway/types/message_unstake_gateway.go | 2 +- x/supplier/types/message_create_claim.go | 2 +- x/supplier/types/message_stake_supplier.go | 2 +- x/supplier/types/message_submit_proof.go | 2 +- x/supplier/types/message_unstake_supplier.go | 2 +- 15 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 5a79d3709..62afe323e 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -20,6 +20,20 @@ jobs: fail_on_error: true pattern: TODO_IN_THIS_ + check_non_standard_interface_implementations: + name: Check for non-standard interface implementation statements + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pokt-network/action-fail-on-found@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + level: error + fail_on_error: true + pattern: var _ .* = &.*{} + ignore: .github,.git + # More info: https://github.com/reviewdog/action-misspell check_misspell: name: Check misspelling @@ -31,4 +45,4 @@ jobs: github_token: ${{ secrets.github_token }} reporter: github-check level: warning - locale: "US" \ No newline at end of file + locale: "US" diff --git a/e2e/tests/node.go b/e2e/tests/node.go index ba0e3b46b..4e34fa827 100644 --- a/e2e/tests/node.go +++ b/e2e/tests/node.go @@ -42,7 +42,7 @@ type PocketClient interface { } // Ensure that pocketdBin struct fulfills PocketClient -var _ PocketClient = &pocketdBin{} +var _ PocketClient = (*pocketdBin)(nil) // pocketdBin holds the reults of the last command that was run type pocketdBin struct { diff --git a/pkg/observable/channel/observable.go b/pkg/observable/channel/observable.go index 8e17ad9fb..26958a75b 100644 --- a/pkg/observable/channel/observable.go +++ b/pkg/observable/channel/observable.go @@ -13,7 +13,7 @@ import ( // defaultSubscribeBufferSize is the buffer size of a observable's publish channel. const defaultPublishBufferSize = 50 -var _ observable.Observable[any] = &channelObservable[any]{} +var _ observable.Observable[any] = (*channelObservable[any])(nil) // option is a function which receives and can modify the channelObservable state. type option[V any] func(obs *channelObservable[V]) diff --git a/pkg/observable/channel/observer.go b/pkg/observable/channel/observer.go index f90bec563..394a6bdbb 100644 --- a/pkg/observable/channel/observer.go +++ b/pkg/observable/channel/observer.go @@ -24,7 +24,7 @@ const ( sendRetryInterval = 100 * time.Millisecond ) -var _ observable.Observer[any] = &channelObserver[any]{} +var _ observable.Observer[any] = (*channelObserver[any])(nil) // channelObserver implements the observable.Observer interface. type channelObserver[V any] struct { diff --git a/pkg/relayer/proxy/proxy.go b/pkg/relayer/proxy/proxy.go index f3d53f5e0..f626f184f 100644 --- a/pkg/relayer/proxy/proxy.go +++ b/pkg/relayer/proxy/proxy.go @@ -16,7 +16,7 @@ import ( suppliertypes "pocket/x/supplier/types" ) -var _ RelayerProxy = &relayerProxy{} +var _ RelayerProxy = (*relayerProxy)(nil) type relayerProxy struct { // keyName is the supplier's key name in the Cosmos's keybase. It is used along with the keyring to diff --git a/x/application/types/message_delegate_to_gateway.go b/x/application/types/message_delegate_to_gateway.go index d162c61bf..232564310 100644 --- a/x/application/types/message_delegate_to_gateway.go +++ b/x/application/types/message_delegate_to_gateway.go @@ -7,7 +7,7 @@ import ( const TypeMsgDelegateToGateway = "delegate_to_gateway" -var _ sdk.Msg = &MsgDelegateToGateway{} +var _ sdk.Msg = (*MsgDelegateToGateway)(nil) func NewMsgDelegateToGateway(address string) *MsgDelegateToGateway { return &MsgDelegateToGateway{ diff --git a/x/application/types/message_stake_application.go b/x/application/types/message_stake_application.go index 93532f2bd..219a65701 100644 --- a/x/application/types/message_stake_application.go +++ b/x/application/types/message_stake_application.go @@ -8,7 +8,7 @@ import ( const TypeMsgStakeApplication = "stake_application" -var _ sdk.Msg = &MsgStakeApplication{} +var _ sdk.Msg = (*MsgStakeApplication)(nil) func NewMsgStakeApplication( address string, diff --git a/x/application/types/message_undelegate_from_gateway.go b/x/application/types/message_undelegate_from_gateway.go index 2cca7962c..240605383 100644 --- a/x/application/types/message_undelegate_from_gateway.go +++ b/x/application/types/message_undelegate_from_gateway.go @@ -7,7 +7,7 @@ import ( const TypeMsgUndelegateFromGateway = "undelegate_from_gateway" -var _ sdk.Msg = &MsgUndelegateFromGateway{} +var _ sdk.Msg = (*MsgUndelegateFromGateway)(nil) func NewMsgUndelegateFromGateway(address string) *MsgUndelegateFromGateway { return &MsgUndelegateFromGateway{ diff --git a/x/application/types/message_unstake_application.go b/x/application/types/message_unstake_application.go index 1f4051f52..010bae551 100644 --- a/x/application/types/message_unstake_application.go +++ b/x/application/types/message_unstake_application.go @@ -7,7 +7,7 @@ import ( const TypeMsgUnstakeApplication = "unstake_application" -var _ sdk.Msg = &MsgUnstakeApplication{} +var _ sdk.Msg = (*MsgUnstakeApplication)(nil) func NewMsgUnstakeApplication(address string) *MsgUnstakeApplication { return &MsgUnstakeApplication{ diff --git a/x/gateway/types/message_stake_gateway.go b/x/gateway/types/message_stake_gateway.go index c86375288..70811076c 100644 --- a/x/gateway/types/message_stake_gateway.go +++ b/x/gateway/types/message_stake_gateway.go @@ -8,7 +8,7 @@ import ( const TypeMsgStakeGateway = "stake_gateway" -var _ sdk.Msg = &MsgStakeGateway{} +var _ sdk.Msg = (*MsgStakeGateway)(nil) func NewMsgStakeGateway(address string, stake types.Coin) *MsgStakeGateway { return &MsgStakeGateway{ diff --git a/x/gateway/types/message_unstake_gateway.go b/x/gateway/types/message_unstake_gateway.go index cb60f2009..23bf5f97a 100644 --- a/x/gateway/types/message_unstake_gateway.go +++ b/x/gateway/types/message_unstake_gateway.go @@ -7,7 +7,7 @@ import ( const TypeMsgUnstakeGateway = "unstake_gateway" -var _ sdk.Msg = &MsgUnstakeGateway{} +var _ sdk.Msg = (*MsgUnstakeGateway)(nil) func NewMsgUnstakeGateway(address string) *MsgUnstakeGateway { return &MsgUnstakeGateway{ diff --git a/x/supplier/types/message_create_claim.go b/x/supplier/types/message_create_claim.go index 98acf0c72..4bcfada3b 100644 --- a/x/supplier/types/message_create_claim.go +++ b/x/supplier/types/message_create_claim.go @@ -9,7 +9,7 @@ import ( const TypeMsgCreateClaim = "create_claim" -var _ sdk.Msg = &MsgCreateClaim{} +var _ sdk.Msg = (*MsgCreateClaim)(nil) func NewMsgCreateClaim(supplierAddress string, sessionHeader *sessiontypes.SessionHeader, rootHash []byte) *MsgCreateClaim { return &MsgCreateClaim{ diff --git a/x/supplier/types/message_stake_supplier.go b/x/supplier/types/message_stake_supplier.go index a441ce6bc..9d4ce5cdc 100644 --- a/x/supplier/types/message_stake_supplier.go +++ b/x/supplier/types/message_stake_supplier.go @@ -8,7 +8,7 @@ import ( const TypeMsgStakeSupplier = "stake_supplier" -var _ sdk.Msg = &MsgStakeSupplier{} +var _ sdk.Msg = (*MsgStakeSupplier)(nil) func NewMsgStakeSupplier( address string, diff --git a/x/supplier/types/message_submit_proof.go b/x/supplier/types/message_submit_proof.go index ee2dec47a..32faa796b 100644 --- a/x/supplier/types/message_submit_proof.go +++ b/x/supplier/types/message_submit_proof.go @@ -9,7 +9,7 @@ import ( const TypeMsgSubmitProof = "submit_proof" -var _ sdk.Msg = &MsgSubmitProof{} +var _ sdk.Msg = (*MsgSubmitProof)(nil) func NewMsgSubmitProof(supplierAddress string, sessionHeader *sessiontypes.SessionHeader, proof []byte) *MsgSubmitProof { return &MsgSubmitProof{ diff --git a/x/supplier/types/message_unstake_supplier.go b/x/supplier/types/message_unstake_supplier.go index eec8ede80..884c21c36 100644 --- a/x/supplier/types/message_unstake_supplier.go +++ b/x/supplier/types/message_unstake_supplier.go @@ -7,7 +7,7 @@ import ( const TypeMsgUnstakeSupplier = "unstake_supplier" -var _ sdk.Msg = &MsgUnstakeSupplier{} +var _ sdk.Msg = (*MsgUnstakeSupplier)(nil) func NewMsgUnstakeSupplier(address string) *MsgUnstakeSupplier { return &MsgUnstakeSupplier{