Repository navigation
feat: add golangci-lint configuration with additional linters - #1936
Conversation
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (78.26%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1936 +/- ##
==========================================
- Coverage 87.29% 87.14% -0.16%
==========================================
Files 143 143
Lines 5535 5540 +5
==========================================
- Hits 4832 4828 -4
- Misses 417 425 +8
- Partials 286 287 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
TerryHowe
left a comment
There was a problem hiding this comment.
It would have been better to enable a few related linters at a time
|
Conflict here needs to be resolved. I think we could ignore codecov for this type of work. |
Signed-off-by: bupd <[email protected]>
Signed-off-by: bupd <[email protected]>
Signed-off-by: bupd <[email protected]>
|
@TerryHowe fixed conflicts. since there are some go antipatterns in code its necessary to have these linters to improve the overall code quality. |
|
I think we should ignore codecov here. |
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive golangci-lint configuration with 11 additional linters and fixes all lint violations across the codebase. The changes include critical bug fixes, improved error handling patterns, resource leak prevention, and code quality improvements.
Key changes:
- Enables additional linters: bodyclose, copyloopvar, errorlint, gosec, nilerr, nilnil, noctx, unconvert, unparam, whitespace, and usetesting
- Fixes a critical bug in tree printer where errors were silently ignored
- Modernizes error handling using
errors.Isanderrors.Asfor better error chain handling - Prevents resource leaks by closing HTTP response bodies in tests
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| .golangci.yml | Adds 11 new linters with appropriate gosec exclusions for project-specific needs |
| internal/tree/printer.go | Fixes bug where recursive print errors were silently ignored (returned nil instead of err) |
| internal/trace/transport.go | Uses errors.Is for io.EOF comparison to properly handle wrapped errors |
| internal/progress/tracker.go | Uses errors.Is for io.EOF comparison in error handling logic |
| internal/progress/tracker_test.go | Updates error comparisons to use errors.Is for more robust error checking |
| internal/mock/repository.go | Removes trailing blank line (whitespace linter) |
| internal/io/tar_utils_test.go | Adds io.LimitReader to prevent unbounded memory consumption in tests (noctx linter) |
| internal/io/io_test.go | Uses errors.Is for io.EOF comparison |
| internal/crypto/certificate_test.go | Closes HTTP response bodies to prevent resource leaks (bodyclose linter) |
| internal/credential/store_test.go | Removes trailing blank line (whitespace linter) |
| internal/cache/target_test.go | Removes unnecessary []byte conversion (unconvert linter) |
| cmd/oras/root/tag.go | Uses errors.As instead of type assertion for safer error type checking (errorlint) |
| cmd/oras/root/manifest/index/update.go | Renames unused parameter to _ (unparam linter) |
| cmd/oras/root/manifest/index/create.go | Adds nolint directives for intentional (nil, nil) returns and splits error handling logic for clarity |
| cmd/oras/root/cp_test.go | Uses errors.Is for error comparisons and removes trailing blank lines |
| cmd/oras/root/cp.go | Renames unused parameter to _ (unparam linter) |
| cmd/oras/root/backup_test.go | Uses errors.Is for error comparisons and removes trailing blank line |
| cmd/oras/root/attach.go | Uses errors.As instead of type assertion (errorlint) |
| cmd/oras/internal/option/target_test.go | Uses errors.As for safer type assertions and removes trailing blank lines |
| cmd/oras/internal/option/remote_test.go | Closes HTTP response bodies and removes trailing blank lines |
| cmd/oras/internal/option/remote.go | Uses errors.Is for error chain checking, renames unused parameter, and fixes format verb to %w |
| cmd/oras/internal/errors/errors_test.go | Uses errors.Is for error comparison |
| cmd/oras/internal/errors/errors.go | Refactors type switches to use errors.As for better error handling (errorlint) |
| cmd/oras/internal/display/status/tty_test.go | Uses errors.Is for error comparisons |
| cmd/oras/internal/display/status/progress/status_test.go | Uses errors.Is for error comparison in helper function |
| cmd/oras/internal/display/status/console/console_test.go | Removes trailing blank line |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks! |
What this PR does / why we need it:
Which issue(s) this PR fixes
Fixes #1935
Please check the following list: