Skip to content

Commit bbcc4da

Browse files
authored
refactor!: Batch longest strategy, Latest deps, linting changes (#7)
* refactor: use batch longest padding strategy * chore: bump deps * chore: linting updates * chore: revert batch longest * chore: use "BatchLongest" * chore: update encoding len BREAKING
1 parent 7fe735e commit bbcc4da

File tree

360 files changed

+7522
-6416
lines changed

Some content is hidden

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

360 files changed

+7522
-6416
lines changed

.github/workflows/release.yml

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ jobs:
4949
with:
5050
fetch-depth: 0
5151

52+
- uses: actions/setup-node@v4
53+
with:
54+
node-version: 20
55+
5256
- name: "🔧 setup Bun"
5357
uses: oven-sh/setup-bun@v1
5458

.golangci.yml

+271
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
# This code is licensed under the terms of the MIT license https://opensource.org/license/mit
2+
# Copyright (c) 2021 Marat Reymers
3+
4+
run:
5+
# Timeout for analysis, e.g. 30s, 5m.
6+
# Default: 1m
7+
timeout: 3m
8+
9+
10+
# This file contains only configs which differ from defaults.
11+
# All possible options can be found here https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
12+
linters-settings:
13+
cyclop:
14+
# The maximal code complexity to report.
15+
# Default: 10
16+
max-complexity: 30
17+
# The maximal average package complexity.
18+
# If it's higher than 0.0 (float) the check is enabled
19+
# Default: 0.0
20+
package-average: 10.0
21+
22+
errcheck:
23+
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
24+
# Such cases aren't reported by default.
25+
# Default: false
26+
check-type-assertions: true
27+
28+
exhaustive:
29+
# Program elements to check for exhaustiveness.
30+
# Default: [ switch ]
31+
check:
32+
- switch
33+
- map
34+
35+
exhaustruct:
36+
# List of regular expressions to exclude struct packages and names from check.
37+
# Default: []
38+
exclude:
39+
# std libs
40+
- "^net/http.Client$"
41+
- "^net/http.Cookie$"
42+
- "^net/http.Request$"
43+
- "^net/http.Response$"
44+
- "^net/http.Server$"
45+
- "^net/http.Transport$"
46+
- "^net/url.URL$"
47+
- "^os/exec.Cmd$"
48+
- "^reflect.StructField$"
49+
# public libs
50+
- "^github.com/Shopify/sarama.Config$"
51+
- "^github.com/Shopify/sarama.ProducerMessage$"
52+
- "^github.com/mitchellh/mapstructure.DecoderConfig$"
53+
- "^github.com/prometheus/client_golang/.+Opts$"
54+
- "^github.com/spf13/cobra.Command$"
55+
- "^github.com/spf13/cobra.CompletionOptions$"
56+
- "^github.com/stretchr/testify/mock.Mock$"
57+
- "^github.com/testcontainers/testcontainers-go.+Request$"
58+
- "^github.com/testcontainers/testcontainers-go.FromDockerfile$"
59+
- "^golang.org/x/tools/go/analysis.Analyzer$"
60+
- "^google.golang.org/protobuf/.+Options$"
61+
- "^gopkg.in/yaml.v3.Node$"
62+
63+
funlen:
64+
# Checks the number of lines in a function.
65+
# If lower than 0, disable the check.
66+
# Default: 60
67+
lines: 100
68+
# Checks the number of statements in a function.
69+
# If lower than 0, disable the check.
70+
# Default: 40
71+
statements: 50
72+
# Ignore comments when counting lines.
73+
# Default false
74+
ignore-comments: true
75+
76+
gocognit:
77+
# Minimal code complexity to report.
78+
# Default: 30 (but we recommend 10-20)
79+
min-complexity: 20
80+
81+
gocritic:
82+
# Settings passed to gocritic.
83+
# The settings key is the name of a supported gocritic checker.
84+
# The list of supported checkers can be find in https://go-critic.github.io/overview.
85+
settings:
86+
captLocal:
87+
# Whether to restrict checker to params only.
88+
# Default: true
89+
paramsOnly: false
90+
underef:
91+
# Whether to skip (*x).method() calls where x is a pointer receiver.
92+
# Default: true
93+
skipRecvDeref: false
94+
95+
gomnd:
96+
# List of function patterns to exclude from analysis.
97+
# Values always ignored: `time.Date`,
98+
# `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`,
99+
# `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`.
100+
# Default: []
101+
ignored-functions:
102+
- flag.Arg
103+
- flag.Duration.*
104+
- flag.Float.*
105+
- flag.Int.*
106+
- flag.Uint.*
107+
- os.Chmod
108+
- os.Mkdir.*
109+
- os.OpenFile
110+
- os.WriteFile
111+
- prometheus.ExponentialBuckets.*
112+
- prometheus.LinearBuckets
113+
114+
gomodguard:
115+
blocked:
116+
# List of blocked modules.
117+
# Default: []
118+
modules:
119+
- github.com/golang/protobuf:
120+
recommendations:
121+
- google.golang.org/protobuf
122+
reason: "see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules"
123+
- github.com/satori/go.uuid:
124+
recommendations:
125+
- github.com/google/uuid
126+
reason: "satori's package is not maintained"
127+
- github.com/gofrs/uuid:
128+
recommendations:
129+
- github.com/google/uuid
130+
reason: "gofrs' package is not go module"
131+
132+
govet:
133+
# Enable all analyzers.
134+
# Default: false
135+
enable-all: true
136+
# Disable analyzers by name.
137+
# Run `go tool vet help` to see all analyzers.
138+
# Default: []
139+
disable:
140+
- fieldalignment # too strict
141+
# Settings per analyzer.
142+
settings:
143+
shadow:
144+
# Whether to be strict about shadowing; can be noisy.
145+
# Default: false
146+
strict: true
147+
148+
nakedret:
149+
# Make an issue if func has more lines of code than this setting, and it has naked returns.
150+
# Default: 30
151+
max-func-lines: 0
152+
153+
nolintlint:
154+
# Exclude following linters from requiring an explanation.
155+
# Default: []
156+
allow-no-explanation: [ funlen, gocognit, lll ]
157+
# Enable to require an explanation of nonzero length after each nolint directive.
158+
# Default: false
159+
require-explanation: true
160+
# Enable to require nolint directives to mention the specific linter being suppressed.
161+
# Default: false
162+
require-specific: true
163+
164+
rowserrcheck:
165+
# database/sql is always checked
166+
# Default: []
167+
packages:
168+
- github.com/jmoiron/sqlx
169+
170+
tenv:
171+
# The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.
172+
# Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.
173+
# Default: false
174+
all: true
175+
176+
177+
linters:
178+
disable-all: true
179+
enable:
180+
## enabled by default
181+
- errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases
182+
- gosimple # specializes in simplifying a code
183+
- govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
184+
- ineffassign # detects when assignments to existing variables are not used
185+
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks
186+
- typecheck # like the front-end of a Go compiler, parses and type-checks Go code
187+
- unused # checks for unused constants, variables, functions and types
188+
## disabled by default
189+
- asasalint # checks for pass []any as any in variadic func(...any)
190+
- asciicheck # checks that your code does not contain non-ASCII identifiers
191+
- bidichk # checks for dangerous unicode character sequences
192+
- bodyclose # checks whether HTTP response body is closed successfully
193+
- cyclop # checks function and package cyclomatic complexity
194+
- dupl # tool for code clone detection
195+
- durationcheck # checks for two durations multiplied together
196+
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
197+
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
198+
- execinquery # checks query string in Query function which reads your Go src files and warning it finds
199+
- exhaustive # checks exhaustiveness of enum switch statements
200+
- exportloopref # checks for pointers to enclosing loop variables
201+
- forbidigo # forbids identifiers
202+
- funlen # tool for detection of long functions
203+
- gocheckcompilerdirectives # validates go compiler directive comments (//go:)
204+
- gochecknoglobals # checks that no global variables exist
205+
- gochecknoinits # checks that no init functions are present in Go code
206+
- gochecksumtype # checks exhaustiveness on Go "sum types"
207+
- gocognit # computes and checks the cognitive complexity of functions
208+
- goconst # finds repeated strings that could be replaced by a constant
209+
- gocritic # provides diagnostics that check for bugs, performance and style issues
210+
- gocyclo # computes and checks the cyclomatic complexity of functions
211+
- godot # checks if comments end in a period
212+
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
213+
- gomnd # detects magic numbers
214+
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
215+
- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations
216+
- goprintffuncname # checks that printf-like functions are named with f at the end
217+
- gosec # inspects source code for security problems
218+
- lll # reports long lines
219+
- loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
220+
- makezero # finds slice declarations with non-zero initial length
221+
- mirror # reports wrong mirror patterns of bytes/strings usage
222+
- musttag # enforces field tags in (un)marshaled structs
223+
- nakedret # finds naked returns in functions greater than a specified function length
224+
- nestif # reports deeply nested if statements
225+
- nilerr # finds the code that returns nil even if it checks that the error is not nil
226+
- nilnil # checks that there is no simultaneous return of nil error and an invalid value
227+
- noctx # finds sending http request without context.Context
228+
- nolintlint # reports ill-formed or insufficient nolint directives
229+
- nonamedreturns # reports all named returns
230+
- nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL
231+
- perfsprint # checks that fmt.Sprintf can be replaced with a faster alternative
232+
- predeclared # finds code that shadows one of Go's predeclared identifiers
233+
- promlinter # checks Prometheus metrics naming via promlint
234+
- protogetter # reports direct reads from proto message fields when getters should be used
235+
- reassign # checks that package variables are not reassigned
236+
- revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
237+
- rowserrcheck # checks whether Err of rows is checked successfully
238+
- sloglint # ensure consistent code style when using log/slog
239+
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
240+
- stylecheck # is a replacement for golint
241+
- tenv # detects using os.Setenv instead of t.Setenv since Go1.17
242+
- testableexamples # checks if examples are testable (have an expected output)
243+
- testifylint # checks usage of github.com/stretchr/testify
244+
- testpackage # makes you use a separate _test package
245+
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
246+
- unconvert # removes unnecessary type conversions
247+
- unparam # reports unused function parameters
248+
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library
249+
- wastedassign # finds wasted assignment statements
250+
- whitespace # detects leading and trailing whitespace
251+
252+
issues:
253+
# Maximum count of issues with the same text.
254+
# Set to 0 to disable.
255+
# Default: 3
256+
max-same-issues: 50
257+
258+
exclude-rules:
259+
- source: "(noinspection|TODO)"
260+
linters: [ godot ]
261+
- source: "//noinspection"
262+
linters: [ gocritic ]
263+
- path: "_test\\.go"
264+
linters:
265+
- bodyclose
266+
- dupl
267+
- funlen
268+
- goconst
269+
- gosec
270+
- noctx
271+
- wrapcheck

0 commit comments

Comments
 (0)