Skip to content

Commit 04d2019

Browse files
committed
lint: golangci-lint v2
1 parent 50cbf9d commit 04d2019

File tree

4 files changed

+33
-14
lines changed

4 files changed

+33
-14
lines changed

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ jobs:
2525
- name: Run linters
2626
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
2727
with:
28-
version: v1.64.4
28+
version: v2.0.1

.golangci.yml

+30-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
1-
run:
2-
timeout: 5m
1+
version: "2"
32
linters:
3+
enable:
4+
- copyloopvar
5+
exclusions:
6+
generated: lax
7+
presets:
8+
- comments
9+
- common-false-positives
10+
- legacy
11+
- std-error-handling
12+
rules:
13+
- linters:
14+
- staticcheck
15+
path: terraform/
16+
- linters:
17+
- staticcheck
18+
text: 'ST1005:' # allow capitlized error strings
19+
paths:
20+
- terraform/
21+
- third_party$
22+
- builtin$
23+
- examples$
24+
formatters:
425
enable:
526
- gci
627
- gofmt
7-
- copyloopvar
8-
issues:
9-
exclude-dirs:
10-
- terraform/
11-
exclude-rules:
12-
- path: terraform/
13-
linters:
14-
- gosimple
28+
exclusions:
29+
generated: lax
30+
paths:
31+
- terraform/
32+
- third_party$
33+
- builtin$
34+
- examples$

plugin/discovery.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,10 @@ func pluginClientError(err error, config *tflint.PluginConfig) error {
156156
search := "Incompatible API version with plugin."
157157

158158
if strings.Contains(message, search) {
159-
message = strings.Replace(
159+
message = strings.ReplaceAll(
160160
message,
161161
search,
162162
fmt.Sprintf(`TFLint is not compatible with this version of the %q plugin. A newer TFLint or plugin version may be required.`, config.Name),
163-
-1,
164163
)
165164

166165
return errors.New(message)

tflint/annotation.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func hclAnnotations(path string, file *hcl.File) (Annotations, hcl.Diagnostics)
5656
// tflint-ignore-file annotation
5757
match = fileAnnotationPattern.FindStringSubmatch(string(token.Bytes))
5858
if len(match) == 2 {
59-
if !(token.Range.Start.Line == 1 && token.Range.Start.Column == 1) {
59+
if token.Range.Start.Line != 1 || token.Range.Start.Column != 1 {
6060
diags = append(diags, &hcl.Diagnostic{
6161
Severity: hcl.DiagError,
6262
Summary: "tflint-ignore-file annotation must be written at the top of file",

0 commit comments

Comments
 (0)