Remediate all lint findings under the canonical golangci-lint config
Fix every finding surfaced by the canonical .golangci.yml with golangci-lint v2.12.2 (refs #61), behavior-preserving throughout: - err113: dynamic errors replaced with package-level sentinels and %w wrapping; direct comparisons converted to errors.Is - goprintffuncname: printf-style helpers renamed with an f suffix (ui.Writer message methods, cli.ReportErrorf, database.Fatalf, vaultik stdoutf) and all call sites updated - revive: stuttering type names renamed (blob.Handler, blob.WithReader, blob.ChunkPosition, storage.URL, storage.Info), doc comments added, unused parameters blanked, package comments added - contextcheck/noctx: ctx threaded through blob.Packer (AddChunk/Flush/FinalizeBlob/PackChunks) and scanner call sites; context-aware exec and sql variants used - funlen/cyclop/gocognit/nestif/dupl: oversized or duplicated functions split into focused helpers across production and test code - paralleltest/tparallel/thelper/usetesting/testpackage: tests parallelized where safe (global log.Initialize kept in the serial phase), helpers marked, t.TempDir adopted, external test packages where only exported API is used - gosec: integer conversions clamped or justified, header timeouts added, remaining findings suppressed with per-site justifications - mnd/goconst/lll/wsl_v5/nlreturn/noinlineerr/errcheck and other mechanical findings fixed directly Remove the deprecated log.LogOptions alias (callers migrated to log.Options). make check is green.
This commit is contained in:
@@ -94,6 +94,11 @@ func (h *TTYHandler) Handle(_ context.Context, r slog.Record) error {
|
||||
if a.Key == "bytes" {
|
||||
value = formatBytes(a.Value.Int64())
|
||||
}
|
||||
case slog.KindAny, slog.KindBool, slog.KindFloat64, slog.KindString,
|
||||
slog.KindTime, slog.KindUint64, slog.KindGroup, slog.KindLogValuer:
|
||||
// Plain string form above is already correct for these kinds.
|
||||
default:
|
||||
// Future kinds also use the plain string form.
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintf(h.out, " %s%s%s=%s%s%s",
|
||||
@@ -109,26 +114,27 @@ func (h *TTYHandler) Handle(_ context.Context, r slog.Record) error {
|
||||
}
|
||||
|
||||
// WithAttrs returns a new handler with the given attributes.
|
||||
func (h *TTYHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
|
||||
func (h *TTYHandler) WithAttrs(_ []slog.Attr) slog.Handler {
|
||||
return h // Simplified for now
|
||||
}
|
||||
|
||||
// WithGroup returns a new handler with the given group name.
|
||||
func (h *TTYHandler) WithGroup(name string) slog.Handler {
|
||||
func (h *TTYHandler) WithGroup(_ string) slog.Handler {
|
||||
return h // Simplified for now
|
||||
}
|
||||
|
||||
// formatDuration formats a duration in a human-readable way
|
||||
func formatDuration(d time.Duration) string {
|
||||
if d < time.Millisecond {
|
||||
switch {
|
||||
case d < time.Millisecond:
|
||||
return fmt.Sprintf("%dµs", d.Microseconds())
|
||||
} else if d < time.Second {
|
||||
case d < time.Second:
|
||||
return fmt.Sprintf("%dms", d.Milliseconds())
|
||||
} else if d < time.Minute {
|
||||
case d < time.Minute:
|
||||
return fmt.Sprintf("%.1fs", d.Seconds())
|
||||
default:
|
||||
return d.String()
|
||||
}
|
||||
|
||||
return d.String()
|
||||
}
|
||||
|
||||
// formatBytes formats bytes in a human-readable way
|
||||
|
||||
Reference in New Issue
Block a user