Skip to content

enhance linters configuration and improve code readability - #245

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

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.

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

CopilotAI 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
FileDescription
.golangci.ymlEnables gocritic, modernize, revive, and configures issue reporting limits.
user/idtools_unix.goUses short declarations for error checks and simplifies an increment.
signal/signal.goRenames local variable to avoid shadowing (signalsig).
reexec/reexec_test.goUses blank identifier for an unused test callback parameter.
mountinfo/mounted_linux_test.goTweaks test logic around bind-mount detection expectations.
mount/sharedsubtree_linux_test.goRemoves an unnecessary deferred unmount in a test.
mount/mounter_linux_test.goMakes a helper function signature more concise.
devices/device_unix_test.goUses blank identifiers for unused stub parameters in tests.
capability/capability_test.goUses a direct empty-string check for the bounding set assertion.
capability/capability_linux.goReplaces an if/else chain with a switch for clarity.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

CopilotAI 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.

@kolyshkinkolyshkin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems AI-generated, and while some of these changes make sense, honestly I don't like the way it is written (various unrelated changes in one single commit, many complex golangci-lint rules, dropped comments)

@mmorel-35
mmorel-35 marked this pull request as draft August 11, 2026 16:52
@mmorel-35
mmorel-35 marked this pull request as ready for review August 11, 2026 17:16
Sign up for freeto 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.

3 participants

@mmorel-35@kolyshkin