Skip to content

Commit 264dab5

Browse files
committed
Apply quality framework: linter fix, tests, pre-commit hooks
- Migrate golangci-lint config from v1 to v2 format (fixes broken linter due to output.formats schema change) - Update golangci-lint install target to v2.5.0 - Add pre-commit hooks for go formatting and linting, with go test on pre-push - Add trust-critical unit tests for clone management: GetClone error paths, UpdateCloneStatus/UpdateCloneSnapshot with nonexistent clones, destroyPreChecks protection bypass for fatal clones, connectionString formatting, GetCloningState, IsProtected, ProtectionExpiresIn - Add API error handling tests: SendError with model and generic errors, SendBadRequestError, SendUnauthorizedError, SendNotFoundError, WriteJSON/ReadJSON error cases, errDetailsMsg formatting https://claude.ai/code/session_01BMygsj1Bb967LXm7guNEBS
1 parent 04e3e8e commit 264dab5

5 files changed

Lines changed: 429 additions & 108 deletions

File tree

.pre-commit-config.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,27 @@ repos:
33
rev: v8.30.0
44
hooks:
55
- id: gitleaks
6+
7+
- repo: local
8+
hooks:
9+
- id: go-fmt
10+
name: go fmt
11+
language: system
12+
entry: bash -c 'cd engine && gofmt -l -w .'
13+
types: [go]
14+
pass_filenames: false
15+
16+
- id: go-lint
17+
name: golangci-lint
18+
language: system
19+
entry: bash -c 'cd engine && golangci-lint run --new-from-rev=HEAD~1'
20+
types: [go]
21+
pass_filenames: false
22+
23+
- id: go-test
24+
name: go test
25+
language: system
26+
entry: bash -c 'cd engine && go test -race -count=1 -timeout=5m ./...'
27+
types: [go]
28+
pass_filenames: false
29+
stages: [pre-push]

engine/.golangci.yml

Lines changed: 90 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,116 @@
1+
version: "2"
12
run:
2-
timeout: 2m
33
issues-exit-code: 1
44
tests: true
55
output:
66
formats:
7-
- format: colored-line-number
8-
print-issued-lines: true
9-
print-linter-name: true
10-
11-
linters-settings:
12-
errcheck:
13-
check-type-assertions: false
14-
check-blank: false
15-
exclude-functions:
16-
- (*os.File).Close
17-
errorlint:
18-
errorf: true
19-
asserts: true
20-
comparison: true
21-
gofmt:
22-
simplify: true
23-
gofumpt:
24-
extra-rules: false
25-
gosimple:
26-
checks: [ "all" ]
27-
goimports:
28-
local-prefixes: gitlab.com/postgres-ai/database-lab
29-
dupl:
30-
threshold: 120
31-
goconst:
32-
min-len: 3
33-
min-occurrences: 5
34-
lll:
35-
line-length: 140
36-
tab-width: 1
37-
mnd:
38-
ignored-functions:
39-
- strconv.Format*
40-
- os.*
41-
- strconv.Parse*
42-
- strings.SplitN
43-
- bytes.SplitN
44-
revive:
45-
confidence: 0.8
46-
unused:
47-
exported-fields-are-used: false
48-
unparam:
49-
check-exported: false
50-
nakedret:
51-
max-func-lines: 20
52-
prealloc:
53-
simple: true
54-
range-loops: true
55-
for-loops: true
56-
gocritic:
57-
disabled-checks:
58-
- regexpMust
59-
- rangeValCopy
60-
- appendAssign
61-
- hugeParam
62-
enabled-tags:
63-
- performance
64-
disabled-tags:
65-
- experimental
66-
staticcheck:
67-
checks: [ "all" ]
68-
7+
text:
8+
path: stdout
9+
print-linter-name: true
10+
print-issued-lines: true
6911
linters:
7012
enable:
7113
- dupl
72-
- errcheck
7314
- gochecknoinits
7415
- goconst
7516
- gocritic
76-
- goimports
77-
- gosimple
78-
- govet
79-
- ineffassign
8017
- lll
8118
- misspell
8219
- mnd
8320
- prealloc
8421
- revive
8522
- staticcheck
86-
- stylecheck
8723
- unconvert
88-
- unused
8924
- unparam
9025
- wsl
91-
enable-all: false
9226
disable:
9327
- depguard
28+
- gocyclo
9429
- gosec
95-
- gocyclo # currently unmaintained
96-
fast: false
97-
30+
settings:
31+
dupl:
32+
threshold: 120
33+
errcheck:
34+
check-type-assertions: false
35+
check-blank: false
36+
exclude-functions:
37+
- (*os.File).Close
38+
errorlint:
39+
errorf: true
40+
asserts: true
41+
comparison: true
42+
goconst:
43+
min-len: 3
44+
min-occurrences: 5
45+
gocritic:
46+
disabled-checks:
47+
- regexpMust
48+
- rangeValCopy
49+
- appendAssign
50+
- hugeParam
51+
enabled-tags:
52+
- performance
53+
disabled-tags:
54+
- experimental
55+
lll:
56+
line-length: 140
57+
tab-width: 1
58+
mnd:
59+
ignored-functions:
60+
- strconv.Format*
61+
- os.*
62+
- strconv.Parse*
63+
- strings.SplitN
64+
- bytes.SplitN
65+
nakedret:
66+
max-func-lines: 20
67+
prealloc:
68+
simple: true
69+
range-loops: true
70+
for-loops: true
71+
revive:
72+
confidence: 0.8
73+
staticcheck:
74+
checks:
75+
- all
76+
unparam:
77+
check-exported: false
78+
unused:
79+
exported-fields-are-used: false
80+
exclusions:
81+
generated: lax
82+
rules:
83+
- linters:
84+
- dupl
85+
- errcheck
86+
- gocyclo
87+
- lll
88+
- mnd
89+
- wsl
90+
path: _test\.go
91+
paths:
92+
- vendor
93+
- third_party$
94+
- builtin$
95+
- examples$
9896
issues:
99-
exclude-rules:
100-
- path: _test\.go
101-
linters:
102-
- dupl
103-
- gocyclo
104-
- lll
105-
- errcheck
106-
- wsl
107-
- mnd
108-
exclude-dirs:
109-
- vendor
110-
111-
exclude-use-default: false
11297
max-issues-per-linter: 0
11398
max-same-issues: 0
99+
formatters:
100+
enable:
101+
- goimports
102+
settings:
103+
gofmt:
104+
simplify: true
105+
gofumpt:
106+
extra-rules: false
107+
goimports:
108+
local-prefixes:
109+
- gitlab.com/postgres-ai/database-lab
110+
exclusions:
111+
generated: lax
112+
paths:
113+
- vendor
114+
- third_party$
115+
- builtin$
116+
- examples$

engine/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ help: ## Display the help message
3535
all: clean build ## Build all binary components of the project
3636

3737
install-lint: ## Install the linter to $GOPATH/bin which is expected to be in $PATH
38-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.64.8
38+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.5.0
3939

4040
run-lint: ## Run linters
4141
golangci-lint run

0 commit comments

Comments
 (0)