enhance linters configuration and improve code readability - #245
Open
mmorel-35 wants to merge 1 commit into
Open
enhance linters configuration and improve code readability#245mmorel-35 wants to merge 1 commit into
mmorel-35 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens Go linting and performs small refactors across runtime code and tests to improve readability and linter compliance.
Changes:
- Expanded
.golangci.ymlto enable additional linters and report all issues. - Refactored Go code and tests for clearer variable usage (avoiding shadowing / unused params) and minor readability improvements.
- Simplified a few test/control-flow snippets (e.g.,
switchin capability string formatting, minor test cleanup).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
.golangci.yml |
Enables gocritic, modernize, revive, and configures issue reporting limits. |
user/idtools_unix.go |
Uses short declarations for error checks and simplifies an increment. |
signal/signal.go |
Renames local variable to avoid shadowing (signal → sig). |
reexec/reexec_test.go |
Uses blank identifier for an unused test callback parameter. |
mountinfo/mounted_linux_test.go |
Tweaks test logic around bind-mount detection expectations. |
mount/sharedsubtree_linux_test.go |
Removes an unnecessary deferred unmount in a test. |
mount/mounter_linux_test.go |
Makes a helper function signature more concise. |
devices/device_unix_test.go |
Uses blank identifiers for unused stub parameters in tests. |
capability/capability_test.go |
Uses a direct empty-string check for the bounding set assertion. |
capability/capability_linux.go |
Replaces an if/else chain with a switch for clarity. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This introduces several improvements and code quality enhancements across the codebase, including updates to linter configuration, refactoring for clarity and maintainability, and minor bug fixes. The most significant changes are grouped below.
Linter and Code Quality Enhancements:
.golangci.yml: Enabled additional linters (gocritic,modernize,revive) and configured their rules to catch more code issues and enforce consistent style. Also, setmax-issues-per-linterandmax-same-issuesto 0 to report all issues.Code Refactoring and Simplification:
user/idtools_unix.go: Refactored variable assignments to use short variable declarations for error handling, improving readability and preventing potential variable shadowing issues.user/idtools_unix.go: Simplified increment operation inlookupSubRangesFilefor clarity.Bug Fixes and Test Improvements:
capability/capability_linux.go: Replacedif/elsechains with aswitchstatement inmkStringfor improved logic clarity.capability/capability_test.go: Improved empty string check for bounding set in tests.mount/sharedsubtree_linux_test.go: Removed unnecessary deferred function inTestSubtreeUnbindablefor cleanup, streamlining test logic.Minor Corrections and Consistency Improvements:
signal/signal.go: Renamed a variable fromsignaltosigto avoid shadowing and improve code clarity.mount/mounter_linux_test.go: Updated function signature forvalidateMountto use a more concise parameter list.mountinfo/mounted_linux_test.goImproved test logic for bind mount detection and error handling.