Skip to content

enhance linters configuration and improve code readability - #245

Open
mmorel-35 wants to merge 1 commit into
moby:mainfrom
mmorel-35:linters
Open

enhance linters configuration and improve code readability#245
mmorel-35 wants to merge 1 commit into
moby:mainfrom
mmorel-35:linters

Conversation

@mmorel-35

Copy link
Copy Markdown

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, set max-issues-per-linter and max-same-issues to 0 to report all issues.
  • Refactored several test and function signatures to use blank identifiers for unused parameters, improving code clarity and linter compliance .

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 in lookupSubRangesFile for clarity.

Bug Fixes and Test Improvements:

  • capability/capability_linux.go: Replaced if/else chains with a switch statement in mkString for 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 in TestSubtreeUnbindable for cleanup, streamlining test logic.

Minor Corrections and Consistency Improvements:

  • signal/signal.go: Renamed a variable from signal to sig to avoid shadowing and improve code clarity.
  • mount/mounter_linux_test.go: Updated function signature for validateMount to use a more concise parameter list.
  • mountinfo/mounted_linux_test.go Improved test logic for bind mount detection and error handling.

Copilot AI lite review requested due to automatic review settings August 7, 2026 11:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yml to 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., switch in 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 (signalsig).
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.

Comment thread mountinfo/mounted_linux_test.go
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Copilot AI review requested due to automatic review settings August 7, 2026 11:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants