Skip to content

Commit a3279a2

Browse files
committed
linter+tools: use dockerized tools
1 parent 68dcb16 commit a3279a2

File tree

6 files changed

+1692
-10
lines changed

6 files changed

+1692
-10
lines changed

.golangci.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
run:
2+
# timeout for analysis
3+
deadline: 10m
4+
5+
linters-settings:
6+
govet:
7+
# Don't report about shadowed variables
8+
check-shadowing: false
9+
gofmt:
10+
# simplify code: gofmt with `-s` option, true by default
11+
simplify: true
12+
whitespace:
13+
multi-func: true
14+
multi-if: true
15+
16+
linters:
17+
enable:
18+
- gofmt
19+
- whitespace
20+
- asciicheck
21+
- bidichk
22+
- bodyclose
23+
- deadcode
24+
- decorder
25+
- depguard
26+
- dupl
27+
- durationcheck
28+
- errcheck
29+
- errchkjson
30+
- execinquery
31+
- exportloopref
32+
- goconst
33+
- gocritic
34+
- godot
35+
- goheader
36+
- goimports
37+
- gomodguard
38+
- goprintffuncname
39+
- gosec
40+
- gosimple
41+
- govet
42+
- grouper
43+
- importas
44+
- ineffassign
45+
- makezero
46+
- misspell
47+
- nakedret
48+
- nonamedreturns
49+
- nosprintfhostport
50+
- predeclared
51+
- revive
52+
- rowserrcheck
53+
- sqlclosecheck
54+
- staticcheck
55+
- structcheck
56+
- tagliatelle
57+
- tenv
58+
- typecheck
59+
- unconvert
60+
- unparam
61+
- unused
62+
- varcheck
63+
- wastedassign

Makefile

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
PKG := github.com/lightninglabs/lndmon
22
ESCPKG := github.com\/lightninglabs\/lndmon
3+
TOOLS_DIR := tools
34

45
LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
6+
GOIMPORTS_PKG := github.com/rinchsan/gosimports/cmd/gosimports
57

68
GO_BIN := ${GOPATH}/bin
79
LINT_BIN := $(GO_BIN)/golangci-lint
810

9-
LINT_COMMIT := v1.18.0
10-
11-
DEPGET := cd /tmp && GO111MODULE=on go get -v
12-
GOBUILD := GO111MODULE=on go build -v
11+
GOBUILD := go build -v
1312

1413
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
1514
GOLIST := go list -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/'
1615

1716
RM := rm -f
1817
CP := cp
1918
MAKE := make
19+
DOCKER_TOOLS = docker run -v $$(pwd):/build lndmon-tools
2020

2121
LINT = $(LINT_BIN) run -v
2222

@@ -28,9 +28,9 @@ all: lint build
2828
# DEPENDENCIES
2929
# ============
3030

31-
$(LINT_BIN):
32-
@$(call print, "Fetching linter")
33-
$(DEPGET) $(LINT_PKG)@$(LINT_COMMIT)
31+
goimports:
32+
@$(call print, "Installing goimports.")
33+
cd $(TOOLS_DIR); go install -trimpath -tags=tools $(GOIMPORTS_PKG)
3434

3535
# ============
3636
# INSTALLATION
@@ -43,13 +43,19 @@ build:
4343
# =========
4444
# UTILITIES
4545
# =========
46-
fmt:
46+
docker-tools:
47+
@$(call print, "Building tools docker image.")
48+
docker build -q -t lndmon-tools $(TOOLS_DIR)
49+
50+
fmt: goimports
51+
@$(call print, "Fixing imports.")
52+
gosimports -w $(GOFILES_NOVENDOR)
4753
@$(call print, "Formatting source.")
4854
gofmt -l -w -s $(GOFILES_NOVENDOR)
4955

50-
lint: $(LINT_BIN)
56+
lint: docker-tools
5157
@$(call print, "Linting source.")
52-
$(LINT)
58+
$(DOCKER_TOOLS) golangci-lint run -v $(LINT_WORKERS)
5359

5460
list:
5561
@$(call print, "Listing commands.")

tools/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM golang:1.18-buster
2+
3+
RUN apt-get update && apt-get install -y git
4+
ENV GOCACHE=/tmp/build/.cache
5+
ENV GOMODCACHE=/tmp/build/.modcache
6+
7+
COPY . /tmp/tools
8+
9+
RUN cd /tmp \
10+
&& mkdir -p /tmp/build/.cache \
11+
&& mkdir -p /tmp/build/.modcache \
12+
&& cd /tmp/tools \
13+
&& go install -trimpath -tags=tools github.com/golangci/golangci-lint/cmd/golangci-lint \
14+
&& chmod -R 777 /tmp/build/
15+
16+
WORKDIR /build

tools/go.mod

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
module github.com/lightninglabs/lndmon/tools
2+
3+
go 1.18
4+
5+
require (
6+
github.com/golangci/golangci-lint v1.46.2
7+
github.com/rinchsan/gosimports v0.1.5
8+
)
9+
10+
require (
11+
4d63.com/gochecknoglobals v0.1.0 // indirect
12+
github.com/Antonboom/errname v0.1.6 // indirect
13+
github.com/Antonboom/nilnil v0.1.1 // indirect
14+
github.com/BurntSushi/toml v1.1.0 // indirect
15+
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
16+
github.com/GaijinEntertainment/go-exhaustruct/v2 v2.1.0 // indirect
17+
github.com/Masterminds/semver v1.5.0 // indirect
18+
github.com/OpenPeeDeeP/depguard v1.1.0 // indirect
19+
github.com/alexkohler/prealloc v1.0.0 // indirect
20+
github.com/ashanbrown/forbidigo v1.3.0 // indirect
21+
github.com/ashanbrown/makezero v1.1.1 // indirect
22+
github.com/beorn7/perks v1.0.1 // indirect
23+
github.com/bkielbasa/cyclop v1.2.0 // indirect
24+
github.com/blizzy78/varnamelen v0.8.0 // indirect
25+
github.com/bombsimon/wsl/v3 v3.3.0 // indirect
26+
github.com/breml/bidichk v0.2.3 // indirect
27+
github.com/breml/errchkjson v0.3.0 // indirect
28+
github.com/butuzov/ireturn v0.1.1 // indirect
29+
github.com/cespare/xxhash/v2 v2.1.2 // indirect
30+
github.com/charithe/durationcheck v0.0.9 // indirect
31+
github.com/chavacava/garif v0.0.0-20220316182200-5cad0b5181d4 // indirect
32+
github.com/daixiang0/gci v0.3.3 // indirect
33+
github.com/davecgh/go-spew v1.1.1 // indirect
34+
github.com/denis-tingaikin/go-header v0.4.3 // indirect
35+
github.com/esimonov/ifshort v1.0.4 // indirect
36+
github.com/ettle/strcase v0.1.1 // indirect
37+
github.com/fatih/color v1.13.0 // indirect
38+
github.com/fatih/structtag v1.2.0 // indirect
39+
github.com/firefart/nonamedreturns v1.0.1 // indirect
40+
github.com/fsnotify/fsnotify v1.5.4 // indirect
41+
github.com/fzipp/gocyclo v0.5.1 // indirect
42+
github.com/go-critic/go-critic v0.6.3 // indirect
43+
github.com/go-toolsmith/astcast v1.0.0 // indirect
44+
github.com/go-toolsmith/astcopy v1.0.0 // indirect
45+
github.com/go-toolsmith/astequal v1.0.1 // indirect
46+
github.com/go-toolsmith/astfmt v1.0.0 // indirect
47+
github.com/go-toolsmith/astp v1.0.0 // indirect
48+
github.com/go-toolsmith/strparse v1.0.0 // indirect
49+
github.com/go-toolsmith/typep v1.0.2 // indirect
50+
github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b // indirect
51+
github.com/gobwas/glob v0.2.3 // indirect
52+
github.com/gofrs/flock v0.8.1 // indirect
53+
github.com/golang/protobuf v1.5.2 // indirect
54+
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect
55+
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect
56+
github.com/golangci/go-misc v0.0.0-20220329215616-d24fe342adfe // indirect
57+
github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a // indirect
58+
github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0 // indirect
59+
github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca // indirect
60+
github.com/golangci/misspell v0.3.5 // indirect
61+
github.com/golangci/revgrep v0.0.0-20210930125155-c22e5001d4f2 // indirect
62+
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect
63+
github.com/google/go-cmp v0.5.7 // indirect
64+
github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8 // indirect
65+
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
66+
github.com/gostaticanalysis/comment v1.4.2 // indirect
67+
github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect
68+
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
69+
github.com/hashicorp/errwrap v1.0.0 // indirect
70+
github.com/hashicorp/go-multierror v1.1.1 // indirect
71+
github.com/hashicorp/go-version v1.4.0 // indirect
72+
github.com/hashicorp/hcl v1.0.0 // indirect
73+
github.com/hexops/gotextdiff v1.0.3 // indirect
74+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
75+
github.com/jgautheron/goconst v1.5.1 // indirect
76+
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
77+
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect
78+
github.com/julz/importas v0.1.0 // indirect
79+
github.com/kisielk/errcheck v1.6.0 // indirect
80+
github.com/kisielk/gotool v1.0.0 // indirect
81+
github.com/kulti/thelper v0.6.2 // indirect
82+
github.com/kunwardeep/paralleltest v1.0.3 // indirect
83+
github.com/kyoh86/exportloopref v0.1.8 // indirect
84+
github.com/ldez/gomoddirectives v0.2.3 // indirect
85+
github.com/ldez/tagliatelle v0.3.1 // indirect
86+
github.com/leonklingele/grouper v1.1.0 // indirect
87+
github.com/lufeee/execinquery v1.2.1 // indirect
88+
github.com/magiconair/properties v1.8.6 // indirect
89+
github.com/maratori/testpackage v1.0.1 // indirect
90+
github.com/matoous/godox v0.0.0-20210227103229-6504466cf951 // indirect
91+
github.com/mattn/go-colorable v0.1.12 // indirect
92+
github.com/mattn/go-isatty v0.0.14 // indirect
93+
github.com/mattn/go-runewidth v0.0.9 // indirect
94+
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
95+
github.com/mbilski/exhaustivestruct v1.2.0 // indirect
96+
github.com/mgechev/revive v1.2.1 // indirect
97+
github.com/mitchellh/go-homedir v1.1.0 // indirect
98+
github.com/mitchellh/mapstructure v1.5.0 // indirect
99+
github.com/moricho/tparallel v0.2.1 // indirect
100+
github.com/nakabonne/nestif v0.3.1 // indirect
101+
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 // indirect
102+
github.com/nishanths/exhaustive v0.7.11 // indirect
103+
github.com/nishanths/predeclared v0.2.2 // indirect
104+
github.com/olekukonko/tablewriter v0.0.5 // indirect
105+
github.com/pelletier/go-toml v1.9.5 // indirect
106+
github.com/pelletier/go-toml/v2 v2.0.0 // indirect
107+
github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d // indirect
108+
github.com/pkg/errors v0.9.1 // indirect
109+
github.com/pmezard/go-difflib v1.0.0 // indirect
110+
github.com/polyfloyd/go-errorlint v1.0.0 // indirect
111+
github.com/prometheus/client_golang v1.12.1 // indirect
112+
github.com/prometheus/client_model v0.2.0 // indirect
113+
github.com/prometheus/common v0.32.1 // indirect
114+
github.com/prometheus/procfs v0.7.3 // indirect
115+
github.com/quasilyte/go-ruleguard v0.3.16-0.20220213074421-6aa060fab41a // indirect
116+
github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 // indirect
117+
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect
118+
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
119+
github.com/ryancurrah/gomodguard v1.2.3 // indirect
120+
github.com/ryanrolds/sqlclosecheck v0.3.0 // indirect
121+
github.com/sanposhiho/wastedassign/v2 v2.0.6 // indirect
122+
github.com/securego/gosec/v2 v2.11.0 // indirect
123+
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect
124+
github.com/sirupsen/logrus v1.8.1 // indirect
125+
github.com/sivchari/containedctx v1.0.2 // indirect
126+
github.com/sivchari/tenv v1.5.0 // indirect
127+
github.com/sonatard/noctx v0.0.1 // indirect
128+
github.com/sourcegraph/go-diff v0.6.1 // indirect
129+
github.com/spf13/afero v1.8.2 // indirect
130+
github.com/spf13/cast v1.4.1 // indirect
131+
github.com/spf13/cobra v1.4.0 // indirect
132+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
133+
github.com/spf13/pflag v1.0.5 // indirect
134+
github.com/spf13/viper v1.11.0 // indirect
135+
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
136+
github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect
137+
github.com/stretchr/objx v0.1.1 // indirect
138+
github.com/stretchr/testify v1.7.1 // indirect
139+
github.com/subosito/gotenv v1.2.0 // indirect
140+
github.com/sylvia7788/contextcheck v1.0.4 // indirect
141+
github.com/tdakkota/asciicheck v0.1.1 // indirect
142+
github.com/tetafro/godot v1.4.11 // indirect
143+
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 // indirect
144+
github.com/tomarrell/wrapcheck/v2 v2.6.1 // indirect
145+
github.com/tommy-muehle/go-mnd/v2 v2.5.0 // indirect
146+
github.com/ultraware/funlen v0.0.3 // indirect
147+
github.com/ultraware/whitespace v0.0.5 // indirect
148+
github.com/uudashr/gocognit v1.0.5 // indirect
149+
github.com/yagipy/maintidx v1.0.0 // indirect
150+
github.com/yeya24/promlinter v0.2.0 // indirect
151+
gitlab.com/bosi/decorder v0.2.1 // indirect
152+
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect
153+
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
154+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
155+
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
156+
golang.org/x/text v0.3.7 // indirect
157+
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a // indirect
158+
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
159+
google.golang.org/protobuf v1.28.0 // indirect
160+
gopkg.in/ini.v1 v1.66.4 // indirect
161+
gopkg.in/yaml.v2 v2.4.0 // indirect
162+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
163+
honnef.co/go/tools v0.3.1 // indirect
164+
mvdan.cc/gofumpt v0.3.1 // indirect
165+
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect
166+
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
167+
mvdan.cc/unparam v0.0.0-20211214103731-d0ef000c54e5 // indirect
168+
)

0 commit comments

Comments
 (0)