Skip to content

Commit

Permalink
🧹 Linting (#1418)
Browse files Browse the repository at this point in the history
* update linters so we don't have deprecated linters, and fix linter errors.

* Update CHANGELOG.md

* longer timeout

* Update golangci.yml

* fumpt

* NewPacketId -> NewPacketID in keys_test.go

* update changelog per feedback

* Update modules/apps/29-fee/ibc_middleware.go

Co-authored-by: Damian Nolan <damiannolan@gmail.com>

* Update modules/core/ante/ante.go

Co-authored-by: Damian Nolan <damiannolan@gmail.com>

* Revert "Update modules/apps/29-fee/ibc_middleware.go"

This reverts commit 882e9f1.

* add godoc linter

* add golint (deprecated) to check for godocs

* alphebetize and add errcheck

* fumpt

* Added gofumpt linter

* some error checks and one docs fix

* RedundancyDecorator

* added errors, resolved an issue with RedundancyDecorator

* resolve unnecessary line blank

* moved comment text inside else if

* update store

* Update CHANGELOG.md

* newpacketID in ica test

* gofumpt

* assignOp: replace  with

* merge main

* lint keeper_test.go

* fix error checking in client keeper

* "works on my pc" ;).

* use go1.18 for golangci-lint

* fumpt

* Update modules/core/ante/ante.go

Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>

* Update testing/mock/ibc_app.go

Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>

* Update modules/light-clients/07-tendermint/types/update.go

Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>

* goimports

* fumpt

* Update modules/core/02-client/abci.go

Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>

* goimports

* Update golangci.yml

* fix newCosmosRelayer

* try to fix abci codeql flagging

* make ci same as main

* make format

* make format

* fmt and proto-gen

* update linter settings

* omit unnecessary type declaration ibctmtypes.Fraction

* adjust golangci-lint timeout

* use blank for SetUpgradedConsensusState

* remove sdk_test.go

* Update modules/apps/29-fee/ibc_middleware.go

Co-authored-by: Damian Nolan <damiannolan@gmail.com>

* Update CHANGELOG.md

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>

* Update CHANGELOG.md

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>

* use declaration

* Update CHANGELOG.md

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>

* remove unneded space

* update changelog

* gofumpt

* fix spelling and trace.go

* we win

* Update mock.go

* fumpt

* fumpt

* gofumpt -w -l -modpath github.com/cosmos/ibc-go/v4

* write files

* imports?

* correct formatting of imports

* gofumpt

* fix metrics issue

* add note about blank import of statik

* added note for blank import so we don't need nolint

* e2e imports

* give e2e a full module path

* use goimports

* goimports

* Delete .gitpod.yml

* update module paths

* linting

* update proto

* *.go

Co-authored-by: Damian Nolan <damiannolan@gmail.com>
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Co-authored-by: vuong <nguyenvuong1122000@gmail.com>
  • Loading branch information
5 people authored Jul 28, 2022
1 parent 79cd69f commit 031f6a3
Show file tree
Hide file tree
Showing 88 changed files with 392 additions and 618 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- main
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3.2.0
with:
version: latest
args: --timeout 5m
21 changes: 5 additions & 16 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,42 @@
run:
tests: false
# # timeout for analysis, e.g. 30s, 5m, default is 1m
# timeout: 5m
timeout: 5m

linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
# - errcheck
- exportloopref
- errcheck
- goconst
- gocritic
- gofmt
- gofumpt
- goimports
- golint
- gosec
- gosimple
- govet
- ineffassign
- interfacer
- maligned
- misspell
- nakedret
- prealloc
- scopelint
- staticcheck
- structcheck
- stylecheck
- revive
- typecheck
- unconvert
- unused
- unparam
- misspell
# - wsl
- nolintlint

issues:
exclude-rules:
- text: "Use of weak random number generator"
linters:
- gosec
- text: "comment on exported var"
linters:
- golint
- text: "don't use an underscore in package name"
linters:
- golint
- text: "ST1003:"
linters:
- stylecheck
Expand Down
41 changes: 23 additions & 18 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ We ensure all major releases are supported by relayers ([hermes](https://github.

## Release cycle

IBC-Go follows a traditional release cycle involving an alpha, beta, and rc (release candidate) releases before finalizing a new version. As ibc-go works in a non-traditional area, we apply our own interpretation to each release type. We reserve the right to make both go API breaking changes and state machine breaking changes throughout the entire release cycle. The stable release guarentees do not go into affect until a final release is performed.
IBC-Go follows a traditional release cycle involving an alpha, beta, and rc (release candidate) releases before finalizing a new version. As ibc-go works in a non-traditional area, we apply our own interpretation to each release type. We reserve the right to make both go API breaking changes and state machine breaking changes throughout the entire release cycle. The stable release guarantees do not go into affect until a final release is performed.

It is never advisable to use a non-final release in production.

### Alpha

Alpha releases are intended to make available new features as soon as they are functional. No correctness guarentees are made and alpha releases **may** contain serious security vulnerabilities, bugs, and lack of user tooling, so long as they don't affect the core functionality.
Alpha releases are intended to make available new features as soon as they are functional. No correctness guarantees are made and alpha releases **may** contain serious security vulnerabilities, bugs, and lack of user tooling, so long as they don't affect the core functionality.

Initial users of alpha releases are expected to be advanced, patient, and capable of handling unusual errors. Very basic integration testing will be performed by the ibc-go development team before alpha releases.

Expand Down
4 changes: 4 additions & 0 deletions cmd/build_test_matrix/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func getGithubActionMatrixForTests(e2eRootDirectory string) (GithubActionTestMat
testSuiteMapping := map[string][]string{}
fset := token.NewFileSet()
err := filepath.Walk(e2eRootDirectory, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return fmt.Errorf("error walking e2e directory: %s", err)
}

// only look at test files
if !strings.HasSuffix(path, testFileNameSuffix) {
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/determine_simd_tag/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func init() {
// in the context of a GithubAction workflow, the PR is non empty if it is a pr. When
// code is merged to main, it will be empty. In this case we just use the "main" tag.
func main() {
fmt.Printf(getSimdTag(prNum))
fmt.Print(getSimdTag(prNum))
}

func getSimdTag(prNum string) string {
Expand Down
2 changes: 1 addition & 1 deletion docs/migrations/v2-to-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ The migration code required may look like:
icaGenesisState := icatypes.NewGenesisState(controllerGenesisState, hostGenesisState)

// set new ics27 genesis state
appState[icatypes.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(icaGenesisState)
appState[icatypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(icaGenesisState)
```

### Ante decorator
Expand Down
6 changes: 3 additions & 3 deletions e2e/fee_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/strangelove-ventures/ibctest/broadcast"
"github.com/strangelove-ventures/ibctest/chain/cosmos"

"github.com/strangelove-ventures/ibctest/ibc"
"github.com/strangelove-ventures/ibctest/test"
"github.com/stretchr/testify/suite"

"e2e/testsuite"
"e2e/testvalues"

"github.com/cosmos/ibc-go/e2e/testsuite"
"github.com/cosmos/ibc-go/e2e/testvalues"
feetypes "github.com/cosmos/ibc-go/v4/modules/apps/29-fee/types"
transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
Expand Down
2 changes: 1 addition & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module e2e
module github.com/cosmos/ibc-go/e2e

go 1.18

Expand Down
4 changes: 2 additions & 2 deletions e2e/testsuite/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package testsuite
import (
"testing"

"e2e/testconfig"

dockerclient "github.com/docker/docker/client"
"github.com/strangelove-ventures/ibctest"
"github.com/strangelove-ventures/ibctest/ibc"
"github.com/strangelove-ventures/ibctest/relayer"
"go.uber.org/zap"

"github.com/cosmos/ibc-go/e2e/testconfig"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"context"
"fmt"
"io/ioutil"

"strings"
"time"

"e2e/testconfig"

sdk "github.com/cosmos/cosmos-sdk/types"
dockerclient "github.com/docker/docker/client"
"github.com/strangelove-ventures/ibctest"
Expand All @@ -23,6 +22,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/cosmos/ibc-go/e2e/testconfig"
feetypes "github.com/cosmos/ibc-go/v4/modules/apps/29-fee/types"
)

Expand Down
46 changes: 23 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ require (
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/btcsuite/btcd v0.22.1 // indirect
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/klauspost/compress v1.15.1 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/common v0.34.0 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
)

require (
filippo.io/edwards25519 v1.0.0-beta.2 // indirect
github.com/99designs/keyring v1.1.6 // indirect
Expand All @@ -34,7 +53,6 @@ require (
github.com/Workiva/go-datastructures v1.0.53 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/btcsuite/btcd v0.22.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect
Expand All @@ -51,12 +69,10 @@ require (
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gin-gonic/gin v1.7.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/gateway v1.1.0 // indirect
Expand All @@ -77,53 +93,37 @@ require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/klauspost/compress v1.15.1 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.34.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/rs/zerolog v1.27.0 // indirect
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
github.com/tendermint/btcd v0.1.1 // indirect
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/zondax/hid v0.9.0 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
)

require (
github.com/gin-gonic/gin v1.7.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/rs/zerolog v1.27.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ var (
// TODO: Cosmos-SDK ADR-28: Update crypto.AddressHash() when sdk uses address.Module()
// https://github.com/cosmos/cosmos-sdk/issues/10225
//
// TestAccAddress defines a resuable bech32 address for testing purposes
// TestAccAddress defines a reusable bech32 address for testing purposes
TestAccAddress = icatypes.GenerateAddress(sdk.AccAddress(crypto.AddressHash([]byte(icatypes.ModuleName))), ibctesting.FirstConnectionID, TestPortID)

// TestOwnerAddress defines a reusable bech32 address for testing purposes
TestOwnerAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs"

// TestPortID defines a resuable port identifier for testing purposes
// TestPortID defines a reusable port identifier for testing purposes
TestPortID, _ = icatypes.NewControllerPortID(TestOwnerAddress)

// TestVersion defines a resuable interchainaccounts version string for testing purposes
// TestVersion defines a reusable interchainaccounts version string for testing purposes
TestVersion = string(icatypes.ModuleCdc.MustMarshalJSON(&icatypes.Metadata{
Version: icatypes.Version,
ControllerConnectionId: ibctesting.FirstConnectionID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ var (
// TODO: Cosmos-SDK ADR-28: Update crypto.AddressHash() when sdk uses address.Module()
// https://github.com/cosmos/cosmos-sdk/issues/10225
//
// TestAccAddress defines a resuable bech32 address for testing purposes
// TestAccAddress defines a reusable bech32 address for testing purposes
TestAccAddress = icatypes.GenerateAddress(sdk.AccAddress(crypto.AddressHash([]byte(icatypes.ModuleName))), ibctesting.FirstConnectionID, TestPortID)

// TestOwnerAddress defines a reusable bech32 address for testing purposes
TestOwnerAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs"

// TestPortID defines a resuable port identifier for testing purposes
// TestPortID defines a reusable port identifier for testing purposes
TestPortID, _ = icatypes.NewControllerPortID(TestOwnerAddress)

// TestVersion defines a resuable interchainaccounts version string for testing purposes
// TestVersion defines a reusable interchainaccounts version string for testing purposes
TestVersion = string(icatypes.ModuleCdc.MustMarshalJSON(&icatypes.Metadata{
Version: icatypes.Version,
ControllerConnectionId: ibctesting.FirstConnectionID,
Expand Down
6 changes: 3 additions & 3 deletions modules/apps/27-interchain-accounts/host/ibc_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ var (
// TODO: Cosmos-SDK ADR-28: Update crypto.AddressHash() when sdk uses address.Module()
// https://github.com/cosmos/cosmos-sdk/issues/10225
//
// TestAccAddress defines a resuable bech32 address for testing purposes
// TestAccAddress defines a reusable bech32 address for testing purposes
TestAccAddress = icatypes.GenerateAddress(sdk.AccAddress(crypto.AddressHash([]byte(icatypes.ModuleName))), ibctesting.FirstConnectionID, TestPortID)

// TestOwnerAddress defines a reusable bech32 address for testing purposes
TestOwnerAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs"

// TestPortID defines a resuable port identifier for testing purposes
// TestPortID defines a reusable port identifier for testing purposes
TestPortID, _ = icatypes.NewControllerPortID(TestOwnerAddress)

// TestVersion defines a resuable interchainaccounts version string for testing purposes
// TestVersion defines a reusable interchainaccounts version string for testing purposes
TestVersion = string(icatypes.ModuleCdc.MustMarshalJSON(&icatypes.Metadata{
Version: icatypes.Version,
ControllerConnectionId: ibctesting.FirstConnectionID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ var (
// TODO: Cosmos-SDK ADR-28: Update crypto.AddressHash() when sdk uses address.Module()
// https://github.com/cosmos/cosmos-sdk/issues/10225
//
// TestAccAddress defines a resuable bech32 address for testing purposes
// TestAccAddress defines a reusable bech32 address for testing purposes
TestAccAddress = icatypes.GenerateAddress(sdk.AccAddress(crypto.AddressHash([]byte(icatypes.ModuleName))), ibctesting.FirstConnectionID, TestPortID)

// TestOwnerAddress defines a reusable bech32 address for testing purposes
TestOwnerAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs"

// TestPortID defines a resuable port identifier for testing purposes
// TestPortID defines a reusable port identifier for testing purposes
TestPortID, _ = icatypes.NewControllerPortID(TestOwnerAddress)

// TestVersion defines a resuable interchainaccounts version string for testing purposes
// TestVersion defines a reusable interchainaccounts version string for testing purposes
TestVersion = string(icatypes.ModuleCdc.MustMarshalJSON(&icatypes.Metadata{
Version: icatypes.Version,
ControllerConnectionId: ibctesting.FirstConnectionID,
Expand Down
10 changes: 8 additions & 2 deletions modules/apps/27-interchain-accounts/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,14 @@ func (AppModuleBasic) RegisterRESTRoutes(ctx client.Context, rtr *mux.Router) {

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the interchain accounts module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
controllertypes.RegisterQueryHandlerClient(context.Background(), mux, controllertypes.NewQueryClient(clientCtx))
hosttypes.RegisterQueryHandlerClient(context.Background(), mux, hosttypes.NewQueryClient(clientCtx))
err := controllertypes.RegisterQueryHandlerClient(context.Background(), mux, controllertypes.NewQueryClient(clientCtx))
if err != nil {
panic(err)
}
err = hosttypes.RegisterQueryHandlerClient(context.Background(), mux, hosttypes.NewQueryClient(clientCtx))
if err != nil {
panic(err)
}
}

// GetTxCmd implements AppModuleBasic interface
Expand Down
Loading

0 comments on commit 031f6a3

Please sign in to comment.