Skip to content

Commit a18a62a

Browse files
committed
lint: upgraded linter and fixed issues
1 parent 8eaf89c commit a18a62a

31 files changed

Lines changed: 128 additions & 60 deletions

.github/workflows/go.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ jobs:
3232
- name: Test (main module)
3333
run: go test -race ./...
3434

35-
- name: Lint (main module)
36-
uses: golangci/golangci-lint-action@v6
35+
- name: golangci-lint
36+
uses: golangci/golangci-lint-action@v7
3737
with:
38-
version: v1.62
38+
version: "v2.0"
3939
github-token: ${{ secrets.GITHUB_TOKEN }}
40-
only-new-issues: true # Required for go-header check
41-
args: --timeout=10m
40+
skip-cache: true
41+
only-new-issues: false
42+
args: --timeout=15m
4243

4344
- name: Test example/devdata_cli (sub module)
4445
run: cd ./examples/devdata_cli && go test -race ./...

.golangci.yml

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,58 @@
1+
version: "2"
2+
run:
3+
modules-download-mode: readonly
4+
tests: true
15
linters:
26
enable:
3-
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers.
4-
- gci # Control golang package import order and make it always deterministic.
5-
- godot # Check if comments end in a period.
6-
- misspell # Finds commonly misspelled English words in comments.
7-
- goheader # Checks is file header matches pattern.
7+
- asciicheck
8+
- bidichk
9+
- dupword
10+
#- errname
11+
- goconst
12+
- godot
13+
- misspell
14+
- nakedret
15+
- nilerr
16+
- rowserrcheck
17+
- sqlclosecheck
18+
- staticcheck
19+
- unconvert
20+
- usestdlibvars
21+
- wastedassign
22+
- whitespace
23+
settings:
24+
staticcheck:
25+
checks:
26+
- all
27+
- -SA1019
28+
- -ST1000
29+
exclusions:
30+
generated: lax
31+
presets:
32+
- comments
33+
- common-false-positives
34+
- legacy
35+
- std-error-handling
36+
paths:
37+
- third_party$
38+
- builtin$
39+
- examples$
40+
issues:
41+
new: false
42+
formatters:
43+
enable:
44+
- gci
45+
- gofmt
846
- gofumpt
9-
10-
linters-settings:
11-
goheader:
12-
values:
13-
const:
14-
COMPANY: Searis AS
15-
regexp:
16-
ANY_AUTHOR: "(.*)"
17-
template-path: .go-header.txt
47+
settings:
48+
gci:
49+
sections:
50+
- standard
51+
- default
52+
- prefix(github.com/clarify/clarify-go/)
53+
exclusions:
54+
generated: lax
55+
paths:
56+
- third_party$
57+
- builtin$
58+
- examples$

automation/automationcli/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"time"
2727

2828
"github.com/clarify/clarify-go"
29+
2930
"github.com/clarify/clarify-go/automation"
3031
"github.com/clarify/clarify-go/internal/logging"
3132
"github.com/clarify/clarify-go/jsonrpc"

automation/routines_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func TestRoutinesSubRoutines(t *testing.T) {
9797
`level=INFO msg=OK routine=routine2`,
9898
},
9999
}))
100-
t.Run("wildcard wildcard", test(testCase{
100+
t.Run("wildcard", test(testCase{
101101
patterns: []string{"*/*"},
102102
expectLines: []string{
103103
`level=INFO msg=OK routine=folder1/folder1/routine1`,
@@ -135,7 +135,7 @@ func TestRoutinesSubRoutines(t *testing.T) {
135135
`level=INFO msg=OK routine=folder1/folder2/routine1`,
136136
},
137137
}))
138-
t.Run("wildcard wildcard routine2", test(testCase{
138+
t.Run("wildcard routine2", test(testCase{
139139
patterns: []string{"*/*/routine2"},
140140
expectLines: []string{
141141
`level=INFO msg=OK routine=folder1/folder1/routine2`,

credentials.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ import (
2424
"strings"
2525
"time"
2626

27-
"github.com/clarify/clarify-go/jsonrpc"
2827
"golang.org/x/oauth2/clientcredentials"
28+
29+
"github.com/clarify/clarify-go/jsonrpc"
2930
)
3031

3132
// Credentials contain a data-structure with Clarify integration credentials.

example_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"time"
2222

2323
"github.com/clarify/clarify-go"
24+
2425
"github.com/clarify/clarify-go/fields"
2526
"github.com/clarify/clarify-go/testdata"
2627
)

examples/automation_cli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ export CLARIFY_EXAMPLE_STATUS_ITEM_ID=...
5656
go run . evaluate/detect-fire
5757
```
5858

59-
You should now have about 45 % chance to see the text "FIRE! FIRE! FIRE!".
59+
You should now have about 45 % chance to see the text "FIRE!".

examples/automation_cli/routines.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,17 @@ import (
2323
"strings"
2424
"time"
2525

26+
"golang.org/x/text/cases"
27+
"golang.org/x/text/language"
28+
2629
"github.com/clarify/clarify-go/automation"
2730
"github.com/clarify/clarify-go/fields"
2831
"github.com/clarify/clarify-go/views"
29-
"golang.org/x/text/cases"
30-
"golang.org/x/text/language"
3132
)
3233

3334
const (
3435
exampleName = "automation_cli"
3536

36-
// For more advanced applications, defining your annotations as constants,
37-
// is less error prone. Annotation keys should be prefixed to avoid
38-
// collision.
39-
keyTransformVersion = "clarify/clarify-go/example/transform"
40-
keySignalAttributesHash = "clarify/clarify-go/example/source-signal/attributes-hash"
41-
keySignalID = "clarify/clarify-go/example/source-signal/id"
42-
4337
// In this example we filter which signals to expose using the following
4438
// annotation keys and values.
4539
keyExampleName = "clarify/clarify-go/example/name"
@@ -191,6 +185,6 @@ var detectFire = automation.EvaluateActions{
191185
},
192186
Actions: []automation.ActionFunc{
193187
automation.ActionSeriesContains("has_fire", 1),
194-
automation.ActionRoutine(automation.LogInfo("FIRE! FIRE! FIRE!")),
188+
automation.ActionRoutine(automation.LogInfo("FIRE!")),
195189
},
196190
}

examples/basic_auth/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"time"
77

88
clarify "github.com/clarify/clarify-go"
9+
910
"github.com/clarify/clarify-go/fields"
1011
"github.com/clarify/clarify-go/views"
1112
)

examples/connect_signals/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77

88
"github.com/clarify/clarify-go"
9+
910
"github.com/clarify/clarify-go/fields"
1011
clarifyx "github.com/clarify/clarify-go/x"
1112
)
@@ -36,5 +37,7 @@ func main() {
3637

3738
enc := json.NewEncoder(os.Stdout)
3839
enc.SetIndent("", " ")
39-
enc.Encode(result)
40+
if err := enc.Encode(result); err != nil {
41+
panic(err)
42+
}
4043
}

0 commit comments

Comments
 (0)