Skip to content

Commit

Permalink
linters
Browse files Browse the repository at this point in the history
  • Loading branch information
JekaMas committed May 11, 2022
1 parent 3c2510a commit 1590047
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
run: make all

# TODO: make it work

# - name: Reproducible build test
# run: |
# make geth
Expand Down
86 changes: 85 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ run:
skip-dirs-use-default: true
skip-files:
- core/genesis_alloc.go
- gen_.*.go
- .*_gen.go

linters:
disable-all: true
Expand All @@ -27,9 +29,70 @@ linters:
linters-settings:
gofmt:
simplify: true
auto-fix: false
goconst:
min-len: 3 # minimum length of string constant
min-occurrences: 6 # minimum number of occurrences
min-occurrences: 2 # minimum number of occurrences

gocritic:
# Which checks should be enabled; can't be combined with 'disabled-checks';
# See https://go-critic.github.io/overview#checks-overview
# To check which checks are enabled run `GL_DEBUG=gocritic ./build/bin/golangci-lint run`
# By default list of stable checks is used.
enabled-checks:
- badLock
- filepathJoin
- sortSlice
- sprintfQuotedString
- syncMapLoadAndDelete
- weakCond
- boolExprSimplify
- httpNoBody
- ioutilDeprecated
- nestingReduce
- preferFilepathJoin
- redundantSprint
- stringConcatSimplify
- timeExprSimplify
- typeAssertChain
- yodaStyleExpr
- truncateCmp
- equalFold
- preferDecodeRune
- preferFprint
- preferStringWriter
- preferWriteByte
- sliceClear
#- ruleguard

# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
disabled-checks:
- regexpMust
- exitAfterDefer
- dupBranchBody
- singleCaseSwitch
- unlambda
- captLocal
- commentFormatting
- ifElseChain
- importShadow
- builtinShadow

# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
enabled-tags:
- performance
- diagnostic
- opinionated
- style
disabled-tags:
- experimental
govet:
disable:
- deepequalerrors
- fieldalignment
- shadow
- unsafeptr

issues:
exclude-rules:
Expand All @@ -48,3 +111,24 @@ issues:
- path: cmd/faucet/
linters:
- deadcode
# Exclude some linters from running on tests files.
- path: test\.go
linters:
- gosec
- unused
- deadcode
- gocritic
- path: cmd/devp2p
linters:
- gosec
- unused
- deadcode
- gocritic
- path: metrics/sample\.go
linters:
- gosec
- gocritic
- path: p2p/simulations
linters:
- gosec
- gocritic
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,16 @@ test-integration:
escape:
cd $(path) && go test -gcflags "-m -m" -run none -bench=BenchmarkJumpdest* -benchmem -memprofile mem.out

lint: ## Run linters.
$(GORUN) build/ci.go lint
lint:
@./build/bin/golangci-lint run --config ./.golangci.yml

lintci:
@echo "--> Running linter for code"
@./build/bin/golangci-lint run --config ./.golangci.yml

lintci-deps:
rm -f ./build/bin/golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.46.0

clean:
env GO111MODULE=on go clean -cache
Expand Down
11 changes: 8 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ require (
github.com/fatih/color v1.7.0
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff
github.com/go-critic/go-critic v0.6.3 // indirect
github.com/go-kit/kit v0.9.0 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-stack/stack v1.8.0
github.com/go-toolsmith/astcopy v1.0.1 // indirect
github.com/golang-jwt/jwt/v4 v4.3.0
github.com/golang/protobuf v1.5.2
github.com/golang/snappy v0.0.4
Expand Down Expand Up @@ -59,6 +61,8 @@ require (
github.com/olekukonko/tablewriter v0.0.5
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7
github.com/prometheus/tsdb v0.7.1
github.com/quasilyte/gogrep v0.0.0-20220429205452-5e2753ee08f9 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
github.com/rjeczalik/notify v0.9.1
github.com/rs/cors v1.7.0
github.com/ryanuber/columnize v2.1.2+incompatible
Expand All @@ -72,12 +76,13 @@ require (
go.opentelemetry.io/otel v1.2.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.2.0
go.opentelemetry.io/otel/sdk v1.2.0
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6
golang.org/x/text v0.3.7
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
golang.org/x/tools v0.1.0
golang.org/x/tools v0.1.10
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
google.golang.org/grpc v1.42.0
google.golang.org/protobuf v1.27.1
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
Expand Down
Loading

0 comments on commit 1590047

Please sign in to comment.