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:
2026-08-07 18:51:21 +00:00
parent 6cf9211407
commit 7ae470e530
121 changed files with 8344 additions and 5406 deletions

View File

@@ -7,8 +7,26 @@ import (
"strings"
)
// StorageURL represents a parsed storage URL.
type StorageURL struct {
// Storage URL scheme names.
const (
schemeFile = "file"
schemeS3 = "s3"
schemeRclone = "rclone"
)
// Sentinel errors for storage URL parsing.
var (
ErrEmptyStorageURL = errors.New("storage URL is empty")
ErrEmptyFilePath = errors.New("file URL path is empty")
ErrMissingBucket = errors.New("s3 URL missing bucket name")
ErrMissingRemote = errors.New("rclone URL missing remote name")
ErrUnsupportedScheme = errors.New(
"unsupported URL scheme: must start with s3://, file://, or rclone://")
ErrUnsupportedStorage = errors.New("unsupported storage scheme")
)
// URL represents a parsed storage URL.
type URL struct {
Scheme string // "s3", "file", or "rclone"
Bucket string // S3 bucket name (empty for file/rclone)
Prefix string // Path within bucket or filesystem base path
@@ -23,20 +41,20 @@ type StorageURL struct {
// - s3://bucket/prefix?endpoint=host&region=us-east-1&ssl=true
// - file:///absolute/path/to/backup
// - rclone://remote/path/to/backups
func ParseStorageURL(rawURL string) (*StorageURL, error) {
func ParseStorageURL(rawURL string) (*URL, error) {
if rawURL == "" {
return nil, errors.New("storage URL is empty")
return nil, ErrEmptyStorageURL
}
// Handle file:// URLs
if after, ok := strings.CutPrefix(rawURL, "file://"); ok {
path := after
if path == "" {
return nil, errors.New("file URL path is empty")
return nil, ErrEmptyFilePath
}
return &StorageURL{
Scheme: "file",
return &URL{
Scheme: schemeFile,
Prefix: path,
}, nil
}
@@ -50,7 +68,7 @@ func ParseStorageURL(rawURL string) (*StorageURL, error) {
bucket := u.Host
if bucket == "" {
return nil, errors.New("s3 URL missing bucket name")
return nil, ErrMissingBucket
}
prefix := strings.TrimPrefix(u.Path, "/")
@@ -62,8 +80,8 @@ func ParseStorageURL(rawURL string) (*StorageURL, error) {
useSSL = false
}
return &StorageURL{
Scheme: "s3",
return &URL{
Scheme: schemeS3,
Bucket: bucket,
Prefix: prefix,
Endpoint: query.Get("endpoint"),
@@ -81,27 +99,27 @@ func ParseStorageURL(rawURL string) (*StorageURL, error) {
remote := u.Host
if remote == "" {
return nil, errors.New("rclone URL missing remote name")
return nil, ErrMissingRemote
}
path := strings.TrimPrefix(u.Path, "/")
return &StorageURL{
Scheme: "rclone",
return &URL{
Scheme: schemeRclone,
Prefix: path,
RcloneRemote: remote,
}, nil
}
return nil, errors.New("unsupported URL scheme: must start with s3://, file://, or rclone://")
return nil, ErrUnsupportedScheme
}
// String returns a human-readable representation of the storage URL.
func (u *StorageURL) String() string {
func (u *URL) String() string {
switch u.Scheme {
case "file":
case schemeFile:
return "file://" + u.Prefix
case "s3":
case schemeS3:
endpoint := u.Endpoint
if endpoint == "" {
endpoint = "s3.amazonaws.com"
@@ -112,7 +130,7 @@ func (u *StorageURL) String() string {
}
return fmt.Sprintf("s3://%s (endpoint: %s)", u.Bucket, endpoint)
case "rclone":
case schemeRclone:
if u.Prefix != "" {
return fmt.Sprintf("rclone://%s/%s", u.RcloneRemote, u.Prefix)
}