Skip to content

Commit 69ef814

Browse files
committed
Initial import
1 parent cc88a4a commit 69ef814

File tree

6 files changed

+440
-1
lines changed

6 files changed

+440
-1
lines changed

.golangci.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# NOTE: This file is populated by the lint-install tool. Local adjustments may be overwritten.
2+
linters-settings:
3+
cyclop:
4+
# NOTE: This is a very high transitional threshold
5+
max-complexity: 36
6+
package-average: 10.0
7+
skip-tests: true
8+
9+
gocognit:
10+
# NOTE: This is a very high transitional threshold
11+
min-complexity: 98
12+
13+
dupl:
14+
threshold: 200
15+
16+
goconst:
17+
min-len: 4
18+
min-occurrences: 5
19+
ignore-tests: true
20+
21+
errorlint:
22+
# these are still common in Go: for instance, exit errors.
23+
asserts: false
24+
25+
exhaustive:
26+
default-signifies-exhaustive: true
27+
28+
nestif:
29+
min-complexity: 7
30+
31+
nolintlint:
32+
require-explanation: true
33+
allow-unused: false
34+
require-specific: true
35+
36+
staticcheck:
37+
go: "1.16"
38+
39+
unused:
40+
go: "1.16"
41+
42+
output:
43+
sort-results: true
44+
45+
linters:
46+
disable-all: true
47+
enable:
48+
- asciicheck
49+
- bodyclose
50+
- cyclop
51+
- deadcode
52+
- dogsled
53+
- dupl
54+
- durationcheck
55+
- errcheck
56+
- errorlint
57+
- exhaustive
58+
- exportloopref
59+
- forcetypeassert
60+
- gocognit
61+
- goconst
62+
- gocritic
63+
- godot
64+
- gofmt
65+
- goheader
66+
- goimports
67+
- goprintffuncname
68+
- gosimple
69+
- govet
70+
- ifshort
71+
- importas
72+
- ineffassign
73+
- makezero
74+
- misspell
75+
- nakedret
76+
- nestif
77+
- nilerr
78+
- noctx
79+
- nolintlint
80+
- predeclared
81+
- promlinter
82+
- revive
83+
- rowserrcheck
84+
- sqlclosecheck
85+
- staticcheck
86+
- structcheck
87+
- stylecheck
88+
- thelper
89+
- tparallel
90+
- typecheck
91+
- unconvert
92+
- unparam
93+
- unused
94+
- varcheck
95+
- wastedassign
96+
- whitespace
97+
98+
# Disabled linters, due to being misaligned with Go practices
99+
# - exhaustivestruct
100+
# - gochecknoglobals
101+
# - gochecknoinits
102+
# - goconst
103+
# - godox
104+
# - goerr113
105+
# - gomnd
106+
# - lll
107+
# - nlreturn
108+
# - testpackage
109+
# - wsl
110+
111+
# Disabled linters, due to not being relevant to our code base:
112+
# - maligned
113+
# - prealloc "For most programs usage of prealloc will be a premature optimization."
114+
115+
# Disabled linters due to bad error messages or bugs
116+
# - gofumpt
117+
# - gosec
118+
# - tagliatelle
119+
120+
121+
issues:
122+
# Excluding configuration per-path, per-linter, per-text and per-source
123+
exclude-rules:
124+
- path: _test\.go
125+
linters:
126+
- gocyclo
127+
- errcheck
128+
- dupl
129+
- gosec
130+
131+
- path: cmd.*
132+
linters:
133+
- noctx
134+
135+
- path: main\.go
136+
linters:
137+
- noctx
138+
139+
# This check is of questionable value
140+
- linters:
141+
- tparallel
142+
text: "call t.Parallel on the top level as well as its subtests"
143+
144+
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
145+
max-same-issues: 10
146+
147+
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
148+
max-issues-per-linter: 100

Makefile.tmpl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
# BEGIN: lint-install {{.Args}}
3+
4+
GOLINT_VERSION ?= v1.41.1
5+
HADOLINT_VERSION ?= v2.6.1
6+
SHELLCHECK_VERSION ?= v0.7.2
7+
LINT_OS := $(shell uname)
8+
LINT_LOWER_OS = $(shell echo $OS | tr '[:upper:]' '[:lower:]')
9+
LINT_ARCH := $(shell uname -m)
10+
11+
lint: {{ if .Shell }}out/linters/shellcheck-$(SHELLCHECK_VERSION)/shellcheck {{ end }}{{ if .Dockerfile }}out/linters/hadolint-$(HADOLINT_VERSION) {{ end }}{{ if .Go}}out/linters/golangci-lint-$(GOLINT_VERSION){{ end }}
12+
{{ if .Go }}out/linters/golangci-lint-$(GOLINT_VERSION) run{{ if eq .Go "warn" }} || true{{ end }}{{ end }}
13+
{{ if .Shell }}out/linters/shellcheck-$(SHELLCHECK_VERSION)/shellcheck $(shell find . -name "*.sh"){{ if eq .Shell "warn" }} || true{{ end }}{{ end }}
14+
{{ if .Dockerfile }}out/linters/hadolint-$(HADOLINT_VERSION) $(shell find . -name "*Dockerfile"){{ if eq .Dockerfile "warn" }} || true{{ end }}{{ end }}
15+
{{ if .Shell}}
16+
out/linters/shellcheck-$(SHELLCHECK_VERSION)/shellcheck:
17+
mkdir -p out/linters
18+
curl -sfL https://github.com/koalaman/shellcheck/releases/download/v0.7.2/shellcheck-$(SHELLCHECK_VERSION).$(LINT_OS).$(LINT_ARCH).tar.xz | tar -C out/linters -xJf -
19+
{{- end }}
20+
{{ if .Dockerfile}}
21+
out/linters/hadolint-$(HADOLINT_VERSION):
22+
mkdir -p out/linters
23+
curl -sfL https://github.com/hadolint/hadolint/releases/download/v2.6.1/hadolint-$(LINT_OS)-$(LINT_ARCH) > out/linters/hadolint-$(HADOLINT_VERSION)
24+
chmod u+x out/linters/hadolint-$(HADOLINT_VERSION)
25+
{{- end }}
26+
{{ if .Go }}
27+
out/linters/golangci-lint-$(GOLINT_VERSION):
28+
mkdir -p out/linters
29+
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b out/linters $(GOLINT_VERSION)
30+
mv out/linters/golangci-lint out/linters/golangci-lint-$(GOLINT_VERSION)
31+
{{- end }}
32+
33+
# END: lint-install {{.Args}}

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,33 @@
11
# lint-install
2-
Consistently install reasonable linter rules for open-source projects
2+
3+
Install sanely configured linters to your project.
4+
5+
This tool specifically supports creating and updating `Makefile` targets, with configured linters for the following languages:
6+
7+
- Go
8+
- Shell
9+
- Dockerfile
10+
11+
## Philosophy
12+
13+
Catch as much as possible, but don't warn about issues that the language authors themselves do not believe in.
14+
15+
## Usage
16+
17+
```
18+
go get github.com/tinkerbell/lint-install
19+
lint-install <repo>
20+
```
21+
22+
## Options
23+
24+
* `--dry-run`: Log what changes would be made if any
25+
* `--shell=warn`: Make shell warnings non-fatal
26+
* `--dockerfile=warn`: Make Dockerfile warnings non-fatal
27+
* `--go=warn`: Make Dockerfile warnings non-fatal
28+
29+
## Languages
30+
31+
- Go
32+
- Shell
33+
- Dockerfile

go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module github.com/tinkerbell/lint-install
2+
3+
go 1.16
4+
5+
require (
6+
github.com/hexops/gotextdiff v1.0.3
7+
github.com/karrick/godirwalk v1.16.1
8+
k8s.io/klog/v2 v2.10.0
9+
)

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
github.com/go-logr/logr v0.4.0 h1:K7/B1jt6fIBQVd4Owv2MqGQClcgf0R266+7C/QjRcLc=
2+
github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
3+
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
4+
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
5+
github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw=
6+
github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
7+
k8s.io/klog/v2 v2.10.0 h1:R2HDMDJsHVTHA2n4RjwbeYXdOcBymXdX/JRb1v0VGhE=
8+
k8s.io/klog/v2 v2.10.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec=

0 commit comments

Comments
 (0)