Skip to content

Commit 27f6ead

Browse files
authored
Merge pull request #1832 from alexandear-org/chore/upgrade-golangci-lint-v2
upgrade to Golangci-lint v2; add lint to CI
2 parents d280a2a + b8613a4 commit 27f6ead

254 files changed

Lines changed: 960 additions & 634 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/run-lint.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Lint
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
branches:
12+
- main
13+
14+
jobs:
15+
lint:
16+
runs-on: [self-hosted, style-checker-aarch64]
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v6
20+
21+
- name: Install Go
22+
uses: actions/setup-go@v6
23+
with:
24+
go-version: "1.25"
25+
26+
- name: golangci-lint
27+
uses: golangci/golangci-lint-action@v9
28+
with:
29+
version: v2.11

.golangci.yaml

Lines changed: 44 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,48 @@
1+
version: "2"
12
run:
23
tests: false
3-
skip-dirs:
4-
- benchmark
5-
- tests
6-
- internal/cmd
7-
8-
linters-settings:
9-
gocritic:
10-
disabled-checks:
11-
- singleCaseSwitch
12-
- commentFormatting
13-
14-
decorder:
15-
dec-order:
16-
- type
17-
- const
18-
- var
19-
- func
20-
disable-dec-order-check: false
21-
22-
revive:
23-
enable-all-rules: true
24-
rules:
25-
- name: cyclomatic
26-
disabled: true
27-
- name: argument-limit
28-
disabled: true
29-
- name: function-length
30-
disabled: true
31-
- name: function-result-limit
32-
disabled: true
33-
- name: line-length-limit
34-
disabled: true
35-
- name: file-header
36-
disabled: true
37-
- name: cognitive-complexity
38-
disabled: true
39-
- name: banned-characters
40-
disabled: true
41-
- name: max-public-structs
42-
disabled: true
43-
- name: add-constant
44-
disabled: true
45-
- name: unhandled-error
46-
disabled: true
47-
- name: deep-exit
48-
disabled: true
49-
- name: nested-structs
50-
disabled: true
51-
52-
gofmt:
53-
rewrite-rules:
54-
- pattern: 'interface{}'
55-
replacement: 'any'
56-
- pattern: 'a[b:len(a)]'
57-
replacement: 'a[b:]'
58-
594
linters:
60-
disable-all: true
5+
default: none
6+
enable:
7+
- asciicheck
8+
- bodyclose
9+
- gocritic
10+
- govet
11+
- ineffassign
12+
- misspell
13+
- staticcheck
14+
settings:
15+
gocritic:
16+
disabled-checks:
17+
- commentFormatting
18+
- singleCaseSwitch
19+
exclusions:
20+
presets:
21+
- comments
22+
- common-false-positives
23+
- legacy
24+
- std-error-handling
25+
rules:
26+
- linters: [staticcheck]
27+
path: "lib/cityhash102"
28+
paths:
29+
- benchmark
30+
- examples
31+
- tests
32+
formatters:
6133
enable:
62-
- asciicheck
63-
- bodyclose
64-
- depguard
65-
- gocritic
66-
- gofmt
67-
- govet
68-
- ineffassign
69-
- imports
70-
- misspell
71-
- staticcheck
34+
- gofmt
35+
- goimports
36+
exclusions:
37+
paths:
38+
- examples
39+
settings:
40+
gofmt:
41+
rewrite-rules:
42+
- pattern: interface{}
43+
replacement: any
44+
- pattern: a[b:len(a)]
45+
replacement: a[b:]
46+
goimports:
47+
local-prefixes:
48+
- "github.com/ClickHouse/clickhouse-go/v2"

benchmark/json_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import (
44
"context"
55
"crypto/tls"
66
"encoding/json"
7+
"os"
8+
"testing"
9+
710
"github.com/ClickHouse/clickhouse-go/v2"
811
"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
912
clickhouse_tests "github.com/ClickHouse/clickhouse-go/v2/tests"
10-
"os"
11-
"testing"
1213
)
1314

1415
const testSet string = "json_bench"

benchmark/v2/read-native/basic_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package main
33
import (
44
"context"
55
"fmt"
6-
"github.com/ClickHouse/clickhouse-go/v2"
76
"log"
87
"testing"
98
"time"
9+
10+
"github.com/ClickHouse/clickhouse-go/v2"
1011
)
1112

1213
func getConnection() clickhouse.Conn {

benchmark/v2/write-compress-buffer-limit/write_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package main
33
import (
44
"context"
55
"fmt"
6-
"github.com/ClickHouse/clickhouse-go/v2"
76
"log"
87
"runtime"
98
"testing"
109
"time"
10+
11+
"github.com/ClickHouse/clickhouse-go/v2"
1112
)
1213

1314
func bToMb(b uint64) uint64 {

benchmark/v2/write-native/write_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package main
22

33
import (
44
"context"
5-
"github.com/ClickHouse/clickhouse-go/v2"
65
"log"
76
"testing"
87
"time"
8+
9+
"github.com/ClickHouse/clickhouse-go/v2"
910
)
1011

1112
func getConnection() clickhouse.Conn {

bind.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ func format(tz *time.Location, scale TimeUnit, v any) (string, error) {
391391
}
392392

393393
func join[E any](tz *time.Location, scale TimeUnit, values []E) (string, error) {
394-
items := make([]string, len(values), len(values))
394+
items := make([]string, len(values))
395395
for i := range values {
396396
val, err := format(tz, scale, values[i])
397397
if err != nil {

clickhouse_options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"time"
1515

1616
"github.com/ClickHouse/ch-go/compress"
17+
1718
"github.com/ClickHouse/clickhouse-go/v2/lib/churl"
1819
)
1920

@@ -423,7 +424,7 @@ func (o Options) setDefaults() *Options {
423424
if o.MaxCompressionBuffer <= 0 {
424425
o.MaxCompressionBuffer = 10485760
425426
}
426-
if o.Addr == nil || len(o.Addr) == 0 {
427+
if len(o.Addr) == 0 {
427428
switch o.Protocol {
428429
case Native:
429430
o.Addr = []string{"localhost:9000"}

clickhouse_rows_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package clickhouse
22

33
import (
4-
"github.com/ClickHouse/clickhouse-go/v2/lib/column"
5-
"github.com/ClickHouse/clickhouse-go/v2/lib/proto"
6-
"github.com/stretchr/testify/assert"
74
"strconv"
85
"testing"
6+
7+
"github.com/stretchr/testify/assert"
8+
9+
"github.com/ClickHouse/clickhouse-go/v2/lib/column"
10+
"github.com/ClickHouse/clickhouse-go/v2/lib/proto"
911
)
1012

1113
func TestReadWithEmptyBlock(t *testing.T) {

clickhouse_std.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (o *stdConnOpener) Connect(ctx context.Context) (_ driver.Conn, err error)
5555
}
5656
}
5757

58-
if o.opt.Addr == nil || len(o.opt.Addr) == 0 {
58+
if len(o.opt.Addr) == 0 {
5959
return nil, ErrAcquireConnNoAddress
6060
}
6161

0 commit comments

Comments
 (0)