Skip to content

Commit 57ce869

Browse files
committed
update codebase
1 parent b2a3bb4 commit 57ce869

File tree

22 files changed

+923
-737
lines changed

22 files changed

+923
-737
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ on:
99

1010
permissions: {} # No default permissions
1111

12-
env:
13-
GO_VERSION: '1.23.4'
14-
1512
jobs:
1613
test:
1714
runs-on: ubuntu-latest
@@ -26,7 +23,7 @@ jobs:
2623
- name: Setup Go
2724
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
2825
with:
29-
go-version: ${{ env.GO_VERSION }}
26+
go-version: 'stable'
3027
cache: false
3128

3229
- name: Test

.golangci.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ linters:
152152

153153
nakedret:
154154
# Default: 30
155-
max-func-lines: 4
155+
max-func-lines: 7
156156

157157
nestif:
158-
min-complexity: 12
158+
min-complexity: 15
159159

160160
nolintlint:
161161
# Exclude following linters from requiring an explanation.
@@ -171,17 +171,11 @@ linters:
171171
rules:
172172
- name: add-constant
173173
severity: warning
174-
disabled: false
175-
exclude: [""]
176-
arguments:
177-
- max-lit-count: "5"
178-
allow-strs: '"","\n"'
179-
allow-ints: "0,1,2,3,24,30,60,100,365,0o600,0o700,0o750,0o755"
180-
allow-floats: "0.0,0.,1.0,1.,2.0,2."
174+
disabled: true
181175
- name: cognitive-complexity
182-
arguments: [55]
176+
disabled: true # prefer maintidx
183177
- name: cyclomatic
184-
arguments: [60]
178+
disabled: true # prefer maintidx
185179
- name: function-length
186180
arguments: [150, 225]
187181
- name: line-length-limit
@@ -192,6 +186,8 @@ linters:
192186
arguments: [10]
193187
- name: flag-parameter # fixes are difficult
194188
disabled: true
189+
- name: bare-return
190+
disabled: true
195191

196192
rowserrcheck:
197193
# database/sql is always checked.
@@ -213,8 +209,14 @@ linters:
213209
os-temp-dir: true
214210

215211
varnamelen:
216-
max-distance: 40
212+
max-distance: 75
217213
min-name-length: 2
214+
check-receivers: false
215+
ignore-names:
216+
- r
217+
- w
218+
- f
219+
- err
218220

219221
exclusions:
220222
# Default: []

.yamllint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ rules:
1111
document-start: disable
1212
line-length:
1313
level: warning
14-
max: 200
14+
max: 160
1515
allow-non-breakable-inline-mappings: true
1616
truthy: disable

Makefile

Lines changed: 85 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -95,56 +95,117 @@ help:
9595
@echo " make ko-build - Build server container with ko"
9696
@echo " make ko-publish - Publish server container with ko"
9797

98-
# BEGIN: lint-install - POSIX-compliant version
99-
# Works with both BSD make and GNU make
98+
# BEGIN: lint-install .
99+
# http://github.com/codeGROOVE-dev/lint-install
100100

101101
.PHONY: lint
102102
lint: _lint
103103

104-
# Use simple assignment for maximum compatibility
105-
LINT_ARCH != uname -m || echo x86_64
106-
LINT_OS != uname || echo Darwin
107-
LINT_ROOT = .
104+
LINT_ARCH := $(shell uname -m)
105+
LINT_OS := $(shell uname)
106+
LINT_OS_LOWER := $(shell echo $(LINT_OS) | tr '[:upper:]' '[:lower:]')
107+
LINT_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
108108

109-
LINTERS =
110-
FIXERS =
109+
# shellcheck and hadolint lack arm64 native binaries: rely on x86-64 emulation
110+
ifeq ($(LINT_OS),Darwin)
111+
ifeq ($(LINT_ARCH),arm64)
112+
LINT_ARCH=x86_64
113+
endif
114+
endif
111115

112-
GOLANGCI_LINT_CONFIG = $(LINT_ROOT)/.golangci.yml
113-
GOLANGCI_LINT_VERSION = v2.3.1
114-
GOLANGCI_LINT_BIN = $(LINT_ROOT)/out/linters/golangci-lint-$(GOLANGCI_LINT_VERSION)-$(LINT_ARCH)
116+
LINTERS :=
117+
FIXERS :=
115118

119+
SHELLCHECK_VERSION ?= v0.11.0
120+
SHELLCHECK_BIN := $(LINT_ROOT)/out/linters/shellcheck-$(SHELLCHECK_VERSION)-$(LINT_ARCH)
121+
$(SHELLCHECK_BIN):
122+
mkdir -p $(LINT_ROOT)/out/linters
123+
curl -sSfL -o $@.tar.xz https://github.com/koalaman/shellcheck/releases/download/$(SHELLCHECK_VERSION)/shellcheck-$(SHELLCHECK_VERSION).$(LINT_OS_LOWER).$(LINT_ARCH).tar.xz \
124+
|| echo "Unable to fetch shellcheck for $(LINT_OS)/$(LINT_ARCH): falling back to locally install"
125+
test -f $@.tar.xz \
126+
&& tar -C $(LINT_ROOT)/out/linters -xJf $@.tar.xz \
127+
&& mv $(LINT_ROOT)/out/linters/shellcheck-$(SHELLCHECK_VERSION)/shellcheck $@ \
128+
|| printf "#!/usr/bin/env shellcheck\n" > $@
129+
chmod u+x $@
130+
131+
LINTERS += shellcheck-lint
132+
shellcheck-lint: $(SHELLCHECK_BIN)
133+
$(SHELLCHECK_BIN) $(shell find . -name "*.sh")
134+
135+
FIXERS += shellcheck-fix
136+
shellcheck-fix: $(SHELLCHECK_BIN)
137+
$(SHELLCHECK_BIN) $(shell find . -name "*.sh") -f diff | { read -t 1 line || exit 0; { echo "$$line" && cat; } | git apply -p2; }
138+
139+
GOLANGCI_LINT_CONFIG := $(LINT_ROOT)/.golangci.yml
140+
GOLANGCI_LINT_VERSION ?= v2.7.2
141+
GOLANGCI_LINT_BIN := $(LINT_ROOT)/out/linters/golangci-lint-$(GOLANGCI_LINT_VERSION)-$(LINT_ARCH)
116142
$(GOLANGCI_LINT_BIN):
117143
mkdir -p $(LINT_ROOT)/out/linters
118144
rm -rf $(LINT_ROOT)/out/linters/golangci-lint-*
119145
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LINT_ROOT)/out/linters $(GOLANGCI_LINT_VERSION)
120-
mv $(LINT_ROOT)/out/linters/golangci-lint $(GOLANGCI_LINT_BIN)
146+
mv $(LINT_ROOT)/out/linters/golangci-lint $@
121147

122148
LINTERS += golangci-lint-lint
123149
golangci-lint-lint: $(GOLANGCI_LINT_BIN)
124-
find . -name go.mod -execdir $(GOLANGCI_LINT_BIN) run -c $(GOLANGCI_LINT_CONFIG) \;
150+
find . -name go.mod -execdir "$(GOLANGCI_LINT_BIN)" run -c "$(GOLANGCI_LINT_CONFIG)" \;
125151

126152
FIXERS += golangci-lint-fix
127153
golangci-lint-fix: $(GOLANGCI_LINT_BIN)
128-
find . -name go.mod -execdir $(GOLANGCI_LINT_BIN) run -c $(GOLANGCI_LINT_CONFIG) --fix \;
129-
130-
YAMLLINT_VERSION = 1.37.1
131-
YAMLLINT_ROOT = $(LINT_ROOT)/out/linters/yamllint-$(YAMLLINT_VERSION)
132-
YAMLLINT_BIN = $(YAMLLINT_ROOT)/dist/bin/yamllint
154+
find . -name go.mod -execdir "$(GOLANGCI_LINT_BIN)" run -c "$(GOLANGCI_LINT_CONFIG)" --fix \;
133155

156+
YAMLLINT_VERSION ?= 1.37.1
157+
YAMLLINT_ROOT := $(LINT_ROOT)/out/linters/yamllint-$(YAMLLINT_VERSION)
158+
YAMLLINT_BIN := $(YAMLLINT_ROOT)/dist/bin/yamllint
134159
$(YAMLLINT_BIN):
135160
mkdir -p $(LINT_ROOT)/out/linters
136161
rm -rf $(LINT_ROOT)/out/linters/yamllint-*
137162
curl -sSfL https://github.com/adrienverge/yamllint/archive/refs/tags/v$(YAMLLINT_VERSION).tar.gz | tar -C $(LINT_ROOT)/out/linters -zxf -
138-
cd $(YAMLLINT_ROOT) && (pip3 install --target dist . || pip install --target dist .)
163+
cd $(YAMLLINT_ROOT) && pip3 install --target dist . || pip install --target dist .
139164

140165
LINTERS += yamllint-lint
141166
yamllint-lint: $(YAMLLINT_BIN)
142-
PYTHONPATH=$(YAMLLINT_ROOT)/dist $(YAMLLINT_BIN) .
167+
PYTHONPATH=$(YAMLLINT_ROOT)/dist $(YAMLLINT_ROOT)/dist/bin/yamllint .
168+
169+
BIOME_VERSION ?= 2.3.8
170+
BIOME_BIN := $(LINT_ROOT)/out/linters/biome-$(BIOME_VERSION)-$(LINT_ARCH)
171+
BIOME_CONFIG := $(LINT_ROOT)/biome.json
172+
173+
# Map architecture names for Biome downloads
174+
BIOME_ARCH := $(LINT_ARCH)
175+
ifeq ($(LINT_ARCH),x86_64)
176+
BIOME_ARCH := x64
177+
endif
178+
179+
$(BIOME_BIN):
180+
mkdir -p $(LINT_ROOT)/out/linters
181+
rm -rf $(LINT_ROOT)/out/linters/biome-*
182+
curl -sSfL -o $@ https://github.com/biomejs/biome/releases/download/%40biomejs%2Fbiome%40$(BIOME_VERSION)/biome-$(LINT_OS_LOWER)-$(BIOME_ARCH) \
183+
|| echo "Unable to fetch biome for $(LINT_OS_LOWER)/$(BIOME_ARCH), falling back to local install"
184+
test -f $@ || printf "#!/usr/bin/env biome\n" > $@
185+
chmod u+x $@
186+
187+
LINTERS += biome-lint
188+
biome-lint: $(BIOME_BIN)
189+
$(BIOME_BIN) check --config-path=$(BIOME_CONFIG) .
190+
191+
FIXERS += biome-fix
192+
biome-fix: $(BIOME_BIN)
193+
$(BIOME_BIN) check --write --config-path=$(BIOME_CONFIG) .
143194

144195
.PHONY: _lint $(LINTERS)
145-
_lint: $(LINTERS)
196+
_lint:
197+
@exit_code=0; \
198+
for target in $(LINTERS); do \
199+
$(MAKE) $$target || exit_code=1; \
200+
done; \
201+
exit $$exit_code
146202

147203
.PHONY: fix $(FIXERS)
148-
fix: $(FIXERS)
149-
150-
# END: lint-install
204+
fix:
205+
@exit_code=0; \
206+
for target in $(FIXERS); do \
207+
$(MAKE) $$target || exit_code=1; \
208+
done; \
209+
exit $$exit_code
210+
211+
# END: lint-install .

biome.json

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"ignoreUnknown": false,
10+
"includes": [
11+
"**",
12+
"!**/node_modules",
13+
"!**/dist",
14+
"!**/build",
15+
"!**/out",
16+
"!**/coverage",
17+
"!**/.next",
18+
"!**/.nuxt",
19+
"!**/*.html"
20+
]
21+
},
22+
"formatter": {
23+
"enabled": true,
24+
"formatWithErrors": false,
25+
"indentStyle": "space",
26+
"indentWidth": 2,
27+
"lineWidth": 100
28+
},
29+
"assist": { "actions": { "source": { "organizeImports": "on" } } },
30+
"linter": {
31+
"enabled": true,
32+
"rules": {
33+
"recommended": true,
34+
"complexity": {
35+
"noExtraBooleanCast": "error",
36+
"noUselessCatch": "error",
37+
"noUselessTypeConstraint": "error",
38+
"noAdjacentSpacesInRegex": "error",
39+
"noArguments": "error"
40+
},
41+
"correctness": {
42+
"noConstAssign": "error",
43+
"noConstantCondition": "error",
44+
"noEmptyCharacterClassInRegex": "error",
45+
"noEmptyPattern": "error",
46+
"noGlobalObjectCalls": "error",
47+
"noInnerDeclarations": "error",
48+
"noInvalidConstructorSuper": "error",
49+
"noNonoctalDecimalEscape": "error",
50+
"noPrecisionLoss": "error",
51+
"noSelfAssign": "error",
52+
"noSetterReturn": "error",
53+
"noSwitchDeclarations": "error",
54+
"noUndeclaredVariables": "error",
55+
"noUnreachable": "error",
56+
"noUnreachableSuper": "error",
57+
"noUnsafeFinally": "error",
58+
"noUnsafeOptionalChaining": "error",
59+
"noUnusedLabels": "error",
60+
"noUnusedVariables": "error",
61+
"useIsNan": "error",
62+
"useValidForDirection": "error",
63+
"useYield": "error",
64+
"noInvalidBuiltinInstantiation": "error",
65+
"useValidTypeof": "error"
66+
},
67+
"security": {
68+
"noDangerouslySetInnerHtml": "warn",
69+
"noDangerouslySetInnerHtmlWithChildren": "error"
70+
},
71+
"style": {
72+
"useConst": "error"
73+
},
74+
"suspicious": {
75+
"noAssignInExpressions": "error",
76+
"noAsyncPromiseExecutor": "error",
77+
"noCatchAssign": "error",
78+
"noClassAssign": "error",
79+
"noCompareNegZero": "error",
80+
"noControlCharactersInRegex": "error",
81+
"noDebugger": "error",
82+
"noDoubleEquals": "warn",
83+
"noDuplicateCase": "error",
84+
"noDuplicateClassMembers": "error",
85+
"noDuplicateObjectKeys": "error",
86+
"noDuplicateParameters": "error",
87+
"noEmptyBlockStatements": "warn",
88+
"noExplicitAny": "warn",
89+
"noExtraNonNullAssertion": "error",
90+
"noFallthroughSwitchClause": "error",
91+
"noFunctionAssign": "error",
92+
"noGlobalAssign": "error",
93+
"noImportAssign": "error",
94+
"noMisleadingCharacterClass": "error",
95+
"noPrototypeBuiltins": "error",
96+
"noRedeclare": "error",
97+
"noShadowRestrictedNames": "error",
98+
"noUnsafeDeclarationMerging": "error",
99+
"noUnsafeNegation": "error",
100+
"useGetterReturn": "error",
101+
"noWith": "error",
102+
"noVar": "error"
103+
}
104+
}
105+
},
106+
"javascript": {
107+
"formatter": {
108+
"quoteStyle": "double",
109+
"jsxQuoteStyle": "double",
110+
"quoteProperties": "asNeeded",
111+
"trailingCommas": "es5",
112+
"semicolons": "always",
113+
"arrowParentheses": "always",
114+
"bracketSpacing": true,
115+
"bracketSameLine": false
116+
}
117+
},
118+
"json": {
119+
"formatter": {
120+
"enabled": true,
121+
"indentStyle": "space",
122+
"indentWidth": 2
123+
},
124+
"parser": {
125+
"allowComments": true,
126+
"allowTrailingCommas": false
127+
}
128+
}
129+
}

0 commit comments

Comments
 (0)