Skip to content

Commit 5fc3337

Browse files
committed
Merge branch 'main' into lint-path2
2 parents 31281a3 + dfc0273 commit 5fc3337

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

.golangci.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ linters-settings:
1818
min-occurrences: 5
1919
ignore-tests: true
2020

21+
gosec:
22+
excludes:
23+
- G107 # Potential HTTP request made with variable url
24+
- G204 # Subprocess launched with function call as argument or cmd arguments
25+
- G404 # Use of weak random number generator (math/rand instead of crypto/rand
26+
2127
errorlint:
2228
# these are still common in Go: for instance, exit errors.
2329
asserts: false
@@ -29,9 +35,9 @@ linters-settings:
2935
min-complexity: 8
3036

3137
nolintlint:
32-
require-explanation: true
33-
allow-unused: false
34-
require-specific: true
38+
require-explanation: true
39+
allow-unused: false
40+
require-specific: true
3541

3642
revive:
3743
ignore-generated-header: true
@@ -108,6 +114,8 @@ linters:
108114
- gocritic
109115
- godot
110116
- gofmt
117+
- gofumpt
118+
- gosec
111119
- goheader
112120
- goimports
113121
- goprintffuncname
@@ -154,17 +162,12 @@ linters:
154162
# - nlreturn
155163
# - testpackage
156164
# - wsl
157-
158165
# Disabled linters, due to not being relevant to our code base:
159166
# - maligned
160167
# - prealloc "For most programs usage of prealloc will be a premature optimization."
161-
162168
# Disabled linters due to bad error messages or bugs
163-
# - gofumpt
164-
# - gosec
165169
# - tagliatelle
166170

167-
168171
issues:
169172
# Excluding configuration per-path, per-linter, per-text and per-source
170173
exclude-rules:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ GOLINT_CONFIG:=$(shell dirname $(LINT_ROOT)/.golangci.yml)
2121

2222
lint: out/linters/shellcheck-$(SHELLCHECK_VERSION)-$(LINT_ARCH)/shellcheck out/linters/hadolint-$(HADOLINT_VERSION)-$(LINT_ARCH) out/linters/golangci-lint-$(GOLINT_VERSION)-$(LINT_ARCH)
2323
out/linters/golangci-lint-$(GOLINT_VERSION)-$(LINT_ARCH) run
24-
out/linters/hadolint-$(HADOLINT_VERSION)-$(LINT_ARCH) -t info $(shell find . -name "*Dockerfile")
24+
out/linters/hadolint-$(HADOLINT_VERSION)-$(LINT_ARCH) $(shell find . -name "*Dockerfile")
2525
out/linters/shellcheck-$(SHELLCHECK_VERSION)-$(LINT_ARCH)/shellcheck $(shell find . -name "*.sh")
2626

2727
out/linters/shellcheck-$(SHELLCHECK_VERSION)-$(LINT_ARCH)/shellcheck:

lint-install.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func updateMakefile(root string, cfg Config, dryRun bool) (string, error) {
128128
edits := myers.ComputeEdits("Makefile", string(existing), string(proposed))
129129
change := gotextdiff.ToUnified(filepath.Base(dest), filepath.Base(dest), string(existing), edits)
130130
if !dryRun {
131-
if err := os.WriteFile(dest, proposed, 0755); err != nil {
131+
if err := os.WriteFile(dest, proposed, 0o600); err != nil {
132132
return "", err
133133
}
134134
}
@@ -154,7 +154,7 @@ func updateGoLint(root string, dryRun bool) (string, error) {
154154
change := gotextdiff.ToUnified(filepath.Base(dest), filepath.Base(dest), string(existing), edits)
155155

156156
if !dryRun {
157-
if err := os.WriteFile(dest, goLintConfig, 0755); err != nil {
157+
if err := os.WriteFile(dest, goLintConfig, 0o600); err != nil {
158158
return "", err
159159
}
160160
}
@@ -176,7 +176,6 @@ func goLintCmd(root string, level string) string {
176176
},
177177
Unsorted: true,
178178
})
179-
180179
if err != nil {
181180
klog.Errorf("unable to find go.mod files: %v", err)
182181
}
@@ -205,11 +204,12 @@ func shellLintCmd(_ string, level string) string {
205204

206205
// dockerLintCmd returns the appropriate docker lint command for a project.
207206
func dockerLintCmd(_ string, level string) string {
208-
threshold := "info"
207+
f := ""
209208
if level == "warn" {
210-
threshold = "none"
209+
f = " --no-fail"
211210
}
212-
return fmt.Sprintf(`out/linters/hadolint-$(HADOLINT_VERSION)-$(LINT_ARCH) -t %s $(shell find . -name "*Dockerfile")`, threshold)
211+
212+
return fmt.Sprintf(`out/linters/hadolint-$(HADOLINT_VERSION)-$(LINT_ARCH)%s $(shell find . -name "*Dockerfile")`, f)
213213
}
214214

215215
// main creates peanut butter & jelly sandwiches with utmost precision.

0 commit comments

Comments
 (0)