Skip to content

Commit

Permalink
Merge pull request #514 from smartcontractkit/golangci-lint-rules
Browse files Browse the repository at this point in the history
.golangci.yml: update rules
  • Loading branch information
jmank88 committed Aug 21, 2024
2 parents fd6e1f3 + 83d5fbb commit 8cfc6ff
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 99 deletions.
35 changes: 33 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ linters:
- whitespace
- depguard
- containedctx
- fatcontext
- mirror
- loggercheck
linters-settings:
exhaustive:
default-signifies-exhaustive: true
Expand All @@ -31,8 +34,21 @@ linters-settings:
# - G304
# - G404
govet:
# report about shadowed variables
check-shadowing: true
enable:
- shadow
settings:
printf:
# Additionally check custom logger
funcs:
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Debugf
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Infof
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Warnf
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Errorf
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Panicf
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Fatalf
- (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).AssumptionViolationf
- (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).Tracef
- (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).Criticalf
errorlint:
# Allow formatting of errors without %w
errorf: false
Expand Down Expand Up @@ -111,6 +127,21 @@ linters-settings:
desc: Use gopkg.in/guregu/null.v4 instead
- pkg: "gopkg.in/guregu/null.v3"
desc: Use gopkg.in/guregu/null.v4 instead
- pkg: github.com/go-gorm/gorm
desc: Use github.com/jmoiron/sqlx directly instead
loggercheck:
# Check that *w logging functions have even number of args (i.e., well formed key-value pairs).
rules:
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Debugw
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Infow
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Warnw
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Errorw
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Panicw
- (github.com/smartcontractkit/chainlink-common/pkg/logger.Logger).Fatalw
- (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).AssumptionViolationw
- (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).Tracew
- (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).Criticalw
- (github.com/smartcontractkit/chainlink-common/pkg/logger.SugaredLogger).With
issues:
exclude-rules:
- path: test
Expand Down
58 changes: 12 additions & 46 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

106 changes: 55 additions & 51 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,58 +1,62 @@
{ stdenv, pkgs, lib, scriptDir }:

with pkgs;
let
{
stdenv,
pkgs,
lib,
scriptDir,
}:
with pkgs; let
go = pkgs.go_1_21;

mkShell' = mkShell.override {
# juno requires building with clang, not gcc
stdenv = pkgs.clangStdenv;
};
in
mkShell' {
nativeBuildInputs = [
stdenv.cc.cc.lib
(rust-bin.stable.latest.default.override { extensions = [ "rust-src" ]; })
nodejs-18_x
(yarn.override { nodejs = nodejs-18_x; })
nodePackages.typescript
nodePackages.typescript-language-server
nodePackages.npm
python3

python311Packages.ledgerwallet
go

gopls
delve
(golangci-lint.override { buildGoModule = buildGo121Module; })
gotools

kubectl
kubernetes-helm

postgresql_15 # psql

] ++ lib.optionals stdenv.isLinux [
# ledger specific packages
libudev-zero
libusb1
];

LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.zlib stdenv.cc.cc.lib ]; # lib64

GOROOT = "${go}/share/go";
CGO_ENABLED = 0;
HELM_REPOSITORY_CONFIG = "${scriptDir}/.helm-repositories.yaml";

shellHook = ''
# Update helm repositories
helm repo update > /dev/null
# setup go bin for nix
export GOBIN=$HOME/.nix-go/bin
mkdir -p $GOBIN
export PATH=$GOBIN:$PATH
# install gotestloghelper
go install github.com/smartcontractkit/chainlink-testing-framework/tools/gotestloghelper@latest
'';
}
mkShell' {
nativeBuildInputs =
[
stdenv.cc.cc.lib
(rust-bin.stable.latest.default.override {extensions = ["rust-src"];})
nodejs-18_x
(yarn.override {nodejs = nodejs-18_x;})
nodePackages.typescript
nodePackages.typescript-language-server
nodePackages.npm
python3

python311Packages.ledgerwallet
go

gopls
delve
(golangci-lint.override {buildGoModule = buildGo122Module;})
gotools

kubectl
kubernetes-helm

postgresql_15 # psql
]
++ lib.optionals stdenv.isLinux [
# ledger specific packages
libudev-zero
libusb1
];

LD_LIBRARY_PATH = lib.makeLibraryPath [pkgs.zlib stdenv.cc.cc.lib]; # lib64

GOROOT = "${go}/share/go";
CGO_ENABLED = 0;
HELM_REPOSITORY_CONFIG = "${scriptDir}/.helm-repositories.yaml";

shellHook = ''
# Update helm repositories
helm repo update > /dev/null
# setup go bin for nix
export GOBIN=$HOME/.nix-go/bin
mkdir -p $GOBIN
export PATH=$GOBIN:$PATH
# install gotestloghelper
go install github.com/smartcontractkit/chainlink-testing-framework/tools/gotestloghelper@latest
'';
}

0 comments on commit 8cfc6ff

Please sign in to comment.