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

Lint like ibc #293

Closed
wants to merge 10 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
- run: go build ./...

tidy:
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
- run: |
go mod tidy
CHANGES_IN_REPO=$(git status --porcelain)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/interchaintest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21

- name: checkout code
uses: actions/checkout@v3
Expand All @@ -57,7 +57,7 @@ jobs:
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21

- name: checkout code
uses: actions/checkout@v3
Expand All @@ -73,7 +73,7 @@ jobs:
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21

- name: checkout code
uses: actions/checkout@v3
Expand All @@ -89,7 +89,7 @@ jobs:
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21

- name: checkout code
uses: actions/checkout@v3
Expand All @@ -105,7 +105,7 @@ jobs:
# - name: Set up Go 1.19
# uses: actions/setup-go@v3
# with:
# go-version: 1.19
# go-version: 1.21

# - name: checkout code
# uses: actions/checkout@v3
Expand All @@ -121,7 +121,7 @@ jobs:
# - name: Set up Go 1.19
# uses: actions/setup-go@v3
# with:
# go-version: 1.19
# go-version: 1.21

# - name: checkout code
# uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
- name: Checkout code
uses: actions/checkout@v3
- name: Test
Expand Down
128 changes: 95 additions & 33 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
run:
tests: true
timeout: 10m
sort-results: true
allow-parallel-runners: true
exclude-dir: testutil/testdata

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

issues:
exclude-rules:
- text: "Use of weak random number generator"
linters:
- gosec
- text: "ST1003:"
- text: 'should not use underscores in package names'
linters:
- stylecheck
# FIXME: Disabled until golangci-lint updates stylecheck with this fix:
# https://github.com/dominikh/go-tools/issues/389
- text: "ST1016:"
- text: 'use an underscore in package name'
linters:
- revive
- stylecheck
- path: "migrations"
text: "SA1019:"
- text: 'differs only by capitalization to method'
linters:
- staticcheck
- text: "leading space"
- revive
- text: 'Use of weak random number generator'
linters:
- nolintlint
- gosec
- linters:
- staticcheck
text: "SA1019:" # silence errors on usage of deprecated funcs

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

linters-settings:
gofumpt:
# Choose whether to use the extra rules.
module-path: github.com/notional-labs/composable-centauri
# Default: false
extra-rules: true
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/notional-labs/composable)
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
- name: unused-parameter
disabled: true
- name: unhandled-error
disabled: true
arguments:
- 'buffer.WriteString'
- 'fmt.Printf'
- 'fmt.Print'
- 'fmt.Println'
- name: import-shadowing
disabled: true
- name: get-return
disabled: true
- name: redundant-import-alias
disabled: true
- name: unchecked-type-assertion
disabled: true
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1

ARG GO_VERSION="1.19"
ARG GO_VERSION="1.21"
ARG RUNNER_IMAGE="gcr.io/distroless/static-debian11"

# --------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1

ARG GO_VERSION="1.19"
ARG RUNNER_IMAGE="alpine:3.16"
ARG GO_VERSION="1.21"
ARG RUNNER_IMAGE="alpine:3.18"

# --------------------------------------------------------
# Builder
Expand Down
13 changes: 7 additions & 6 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package ante

import (
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"

"github.com/cosmos/cosmos-sdk/codec"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
ante "github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
tfmwKeeper "github.com/notional-labs/composable/v6/x/transfermiddleware/keeper"

ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"

tfmwkeeper "github.com/notional-labs/composable/v6/x/transfermiddleware/keeper"
)

// Link to default ante handler used by cosmos sdk:
Expand All @@ -24,7 +25,7 @@ func NewAnteHandler(
sigGasConsumer ante.SignatureVerificationGasConsumer,
signModeHandler signing.SignModeHandler,
channelKeeper *ibckeeper.Keeper,
tfmwKeeper tfmwKeeper.Keeper,
tfmwKeeper tfmwkeeper.Keeper,
codec codec.BinaryCodec,
) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
Expand Down
9 changes: 5 additions & 4 deletions app/ante/ibc_ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ import (
"fmt"

errorsmod "cosmossdk.io/errors"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/cosmos-sdk/x/authz"

clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"

tfmwKeeper "github.com/notional-labs/composable/v6/x/transfermiddleware/keeper"
tfmwkeeper "github.com/notional-labs/composable/v6/x/transfermiddleware/keeper"
)

type IBCPermissionDecorator struct {
cdc codec.BinaryCodec
tfmwKeeper tfmwKeeper.Keeper
tfmwKeeper tfmwkeeper.Keeper
}

func NewIBCPermissionDecorator(cdc codec.BinaryCodec, keeper tfmwKeeper.Keeper) IBCPermissionDecorator {
func NewIBCPermissionDecorator(cdc codec.BinaryCodec, keeper tfmwkeeper.Keeper) IBCPermissionDecorator {
return IBCPermissionDecorator{
cdc: cdc,
tfmwKeeper: keeper,
Expand Down
Loading
Loading