Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Oct 31, 2024
1 parent 798b1a2 commit 9f465b2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 31 deletions.
37 changes: 23 additions & 14 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,36 @@ concurrency:

jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
timeout-minutes: 6
name: Run golangci-lint
runs-on: macos-latest
timeout-minutes: 120
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.22
- uses: actions/checkout@v4
go-version: '1.22.7'
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v23
with:
submodules: true
nix_path: nixpkgs=channel:nixos-22.11
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- id: changed-files
uses: tj-actions/changed-files@v41
with:
files: |
**/*.go
go.mod
go.sum
- uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.55
args: --timeout 10m
github-token: ${{ secrets.github_token }}
*.mod
*.sum
- name: run golangci-lint
run: |
nix profile install -f ./nix golangci-lint
nix profile install -f ./nix rocksdb
export PKG_CONFIG_PATH=$HOME/.nix-profile/lib/pkgconfig
export CGO_CFLAGS="$(pkg-config --cflags rocksdb)" CGO_LDFLAGS="$(pkg-config --libs rocksdb)"
golangci-lint version
BUILD_TAGS=rocksdb,grocksdb_clean_link
go build -tags $BUILD_TAGS ./cmd/chain-maind
golangci-lint run --out-format=github-actions --path-prefix=./ --timeout 30m --build-tags $BUILD_TAGS
# Check only if there are differences in the source code
if: steps.changed-files.outputs.any_changed == 'true'
7 changes: 0 additions & 7 deletions x/chainmain/client/cli/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"math"
"strconv"
"time"

Expand Down Expand Up @@ -92,9 +91,6 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
return fmt.Errorf("failed to parse vesting start: %w", errstart)
}
} else {
if vestingStartUint > math.MaxInt64 {
return fmt.Errorf("vestingStartUint: %d exceeds int64 maximum value", vestingStartUint)
}
vestingStart = int64(vestingStartUint)
}

Expand All @@ -110,9 +106,6 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
return fmt.Errorf("failed to parse vesting end: %w", errend)
}
} else {
if vestingEndUint > math.MaxInt64 {
return fmt.Errorf("vestingEndUint: %d exceeds int64 maximum value", vestingEndUint)
}
vestingEnd = int64(vestingEndUint)
}

Expand Down
4 changes: 0 additions & 4 deletions x/chainmain/client/cli/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/json"
"errors"
"fmt"
"math"
"net"
"os"
"path/filepath"
Expand Down Expand Up @@ -106,9 +105,6 @@ Example:
if numValidatorsErr != nil {
return fmt.Errorf("failed to parse %v: %w", flagNumValidators, numValidatorsErr)
}
if numValidators > uint(math.MaxInt64) {
return fmt.Errorf("numValidators %v cannot exceed %v", numValidators, math.MaxInt64)
}
algo, algoErr := cmd.Flags().GetString(flags.FlagKeyType)
if algoErr != nil {
return fmt.Errorf("failed to parse %v: %w", flags.FlagKeyType, algoErr)
Expand Down
2 changes: 1 addition & 1 deletion x/nft/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (suite *KeeperSuite) TestSupply() {
})

suite.NoError(err)
suite.Equal(1, int(response.Amount)) //nolint:gosec // test only
suite.Equal(1, int(response.Amount))
}

func (suite *KeeperSuite) TestOwner() {
Expand Down
6 changes: 1 addition & 5 deletions x/nft/keeper/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ func SupplyInvariant(k Keeper) sdk.Invariant {

for _, owner := range owners {
for _, idCollection := range owner.IDCollections {
supply := idCollection.Supply()
if supply < 0 {
return sdk.FormatInvariant(types.ModuleName, "supply", fmt.Sprintf("invalid supply: %d", supply)), true
}
ownersCollectionsSupply[idCollection.DenomId] += uint64(supply)
ownersCollectionsSupply[idCollection.DenomId] += uint64(idCollection.Supply())
}
}

Expand Down

0 comments on commit 9f465b2

Please sign in to comment.