Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Oct 31, 2024
1 parent 83f0560 commit fdd5ae9
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 9 deletions.
1 change: 1 addition & 0 deletions nix/build_overlay.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# some basic overlays necessary for the build
final: super: {
rocksdb = final.callPackage ./rocksdb.nix { };
golangci-lint = final.callPackage ./golangci-lint.nix { };
}
43 changes: 43 additions & 0 deletions nix/golangci-lint.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{ buildGo123Module, fetchFromGitHub, lib, installShellFiles }:

buildGo123Module rec {
pname = "golangci-lint";
version = "1.60.1";

src = fetchFromGitHub {
owner = "golangci";
repo = "golangci-lint";
rev = "v${version}";
hash = "sha256-+F/t5UJjyqOsabi2J4M9g5JvAqfKjOvlzdhNozRCv70=";
};

vendorHash = "sha256-elDDSAeEpKXn6fhBFB218mWsSq0mo+GcfQsTDOAPSCI=";

subPackages = [ "cmd/golangci-lint" ];

nativeBuildInputs = [ installShellFiles ];

ldflags = [
"-s"
"-w"
"-X main.version=${version}"
"-X main.commit=v${version}"
"-X main.date=19700101-00:00:00"
];

postInstall = ''
for shell in bash zsh fish; do
HOME=$TMPDIR $out/bin/golangci-lint completion $shell > golangci-lint.$shell
installShellCompletion golangci-lint.$shell
done
'';

meta = with lib; {
description = "Fast linters Runner for Go";
homepage = "https://golangci-lint.run/";
changelog = "https://github.com/golangci/golangci-lint/blob/v${version}/CHANGELOG.md";
mainProgram = "golangci-lint";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ SuperSandro2000 mic92 ];
};
}
14 changes: 7 additions & 7 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"homepage": null,
"owner": "nix-community",
"repo": "gomod2nix",
"rev": "31b6d2e40b36456e792cd6cf50d5a8ddd2fa59a1",
"sha256": "0b8cmc8dk34pgcac5s1jvryfcn8kyhbzhh1i22rzv5kf00f09lhb",
"rev": "5d387097aa716f35dd99d848dc26d8d5b62a104c",
"sha256": "1mdwyjz43nnh7gfq4rc54kql6fy65hw17w0p4gwklnfqciwrkax2",
"type": "tarball",
"url": "https://github.com/nix-community/gomod2nix/archive/31b6d2e40b36456e792cd6cf50d5a8ddd2fa59a1.tar.gz",
"url": "https://github.com/nix-community/gomod2nix/archive/5d387097aa716f35dd99d848dc26d8d5b62a104c.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"ibc-rs": {
Expand All @@ -36,15 +36,15 @@
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixpkgs-unstable",
"branch": "release-24.05",
"description": "Nix Packages collection",
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "63dacb46bf939521bdc93981b4cbb7ecb58427a0",
"sha256": "1lr1h35prqkd1mkmzriwlpvxcb34kmhc9dnr48gkm8hh089hifmx",
"rev": "50286248f2d7283682bdd47ba14af33a9233b88b",
"sha256": "19sqfs6pamknhlg3mqpqs3wj0wj1ynj5icfmhqmjjvq08byfc2hl",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/63dacb46bf939521bdc93981b4cbb7ecb58427a0.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/50286248f2d7283682bdd47ba14af33a9233b88b.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"poetry2nix": {
Expand Down
7 changes: 7 additions & 0 deletions x/chainmain/client/cli/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"math"
"strconv"
"time"

Expand Down Expand Up @@ -91,6 +92,9 @@ 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 @@ -106,6 +110,9 @@ 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: 4 additions & 0 deletions x/chainmain/client/cli/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"errors"
"fmt"
"math"
"net"
"os"
"path/filepath"
Expand Down Expand Up @@ -105,6 +106,9 @@ 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))
suite.Equal(1, int(response.Amount)) //nolint:gosec // test only
}

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

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

Expand Down

0 comments on commit fdd5ae9

Please sign in to comment.