chore: update golangci-lint config and fix lint issues#542
chore: update golangci-lint config and fix lint issues#542moonD4rk merged 4 commits intofeat/v2-hbd-architecturefrom
Conversation
- Remove stale V1 exclusion rules from .golangci.yml - Add linters: nilerr, bodyclose, durationcheck, nestif - Clean up gosec/gocritic disabled checks with documented reasons - Add cookie-editor JSON fallback for non-cookie categories - Fix testifylint issues: use require for error assertions, assert.NotEmpty/Empty/Positive for idiomatic checks
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feat/v2-hbd-architecture #542 +/- ##
============================================================
- Coverage 68.08% 67.86% -0.22%
============================================================
Files 48 48
Lines 1579 1581 +2
============================================================
- Hits 1075 1073 -2
- Misses 398 400 +2
- Partials 106 108 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Updates the repository’s golangci-lint configuration and adjusts code/tests to satisfy the newly enabled and existing linters, including a behavior change to cookie-editor output to fall back to JSON for non-cookie categories.
Changes:
- Refresh
.golangci.yml: remove stale exclusions, enable additional linters, and document gosec/staticcheck decisions. - Implement
cookie-editorformatter fallback to standard JSON for non-cookie categories. - Fix
testifylintfindings across multiple test files by switching torequire.*where appropriate and using more specific assertions.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
.golangci.yml |
Updates enabled linters/exclusions and documents gosec/staticcheck configuration. |
output/formatter.go |
Wires cookie-editor formatter with a JSON fallback implementation. |
output/cookie_editor.go |
Adds fallback-to-JSON behavior for non-cookie categories in cookie-editor format. |
output/output_test.go |
Updates tests for cookie-editor fallback and improves assertions per testifylint. |
utils/sqliteutil/sqlite_test.go |
Replaces non-fatal assert.NoError with require.NoError for fail-fast behavior. |
utils/fileutil/fileutil_test.go |
Switches to require.NoError on setup/critical path assertions. |
filemanager/session_test.go |
Uses require.NoError for operations that must succeed before further assertions. |
crypto/keyretriever/keyretriever_test.go |
Uses require.Error where error is required for the test to proceed meaningfully. |
crypto/crypto_test.go |
Updates error/emptiness assertions to testifylint-preferred forms and adds require import. |
crypto/asn1pbe_test.go |
Updates error/boolean/emptiness assertions to testifylint-preferred forms and adds require import. |
browser/firefox/extract_history_test.go |
Uses assert.Empty instead of equality-to-empty-string. |
browser/browser_test.go |
Uses assert.NotEmpty instead of len(...) > 0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - G401 # weak crypto SHA1 — required for Chromium PBKDF2 key derivation | ||
| - G402 # TLS MinVersion — not applicable (no TLS in this tool) | ||
| - G405 # weak crypto DES — required for Firefox 3DES decryption | ||
| - G501 # blocklisted import crypto/md5 — not used, keep for safety |
There was a problem hiding this comment.
gosec is configured to exclude G501 (blocklisted import crypto/md5) even though the comment states md5 is not used. Since the repository currently has no crypto/md5 imports, keeping this exclusion reduces protection against accidental future md5 introduction; consider removing the G501 exclusion (or only excluding it if/where md5 is actually required).
| - G501 # blocklisted import crypto/md5 — not used, keep for safety |
- Remove stale V1 exclusion rules from .golangci.yml - Add linters: nilerr, bodyclose, durationcheck, nestif - Clean up gosec/gocritic disabled checks with documented reasons - Enable revive unexported-return rule - Add cookie-editor JSON fallback for non-cookie categories - Fix testifylint issues: use require for error assertions, assert.NotEmpty/Empty for idiomatic checks
Add dupword, errchkjson, exhaustive, forcetypeassert, mirror, predeclared, wastedassign linters. Total enabled: 28 → 35. - exhaustive: configured with default-signifies-exhaustive to accept switch statements with default branches - Other 6 linters: zero-config, all pass with 0 issues
Fix assert.NoError/Error → require.NoError/Error across all test files including Windows-specific copy_windows_test.go (not caught on macOS).
Summary
.golangci.yml(browserdata/, extractor/, Phase 8 wiring, etc.)nilerr,bodyclose,durationcheck,nestif.golangci.yml changes
Removed: 6 stale exclusion rules referencing deleted V1 paths
Added linters: nilerr, bodyclose, durationcheck, nestif
Cleaned up: gosec excludes now have inline comments explaining each rule
Cookie-editor fallback
When using
-f cookie-editor, non-cookie categories now fall back to standard JSON output instead of being silently skipped.Test fixes (testifylint)
assert.Equal(t, nil, err)require.NoError(t, err)assert.Equal(t, true, ...)assert.True(t, ...)assert.Equal(t, "", x)assert.Empty(t, x)assert.True(t, len(x) > 0)assert.NotEmpty(t, x)assert.NoErrorafter error returnrequire.NoError(fail fast)Test plan
go test ./...— all passgolangci-lint run— 0 issues