-
Notifications
You must be signed in to change notification settings - Fork 868
Enable gocritic and nolintlint linters #1781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
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 enables the gocritic and nolintlint linters and applies the necessary code refactoring to comply with their requirements. The changes focus on improving code readability and consistency through simpler control flow structures and idiomatic Go patterns.
Key Changes
- Enabled
gocriticandnolintlintlinters in.golangci.yamlwith an exclusion rule forplumbing/hash.go - Refactored if-else chains to switch statements for better readability and maintainability across multiple files
- Applied idiomatic improvements like compound assignment operators (
+=), removing unnecessary slice expressions, and usingplumbing.ZeroHashconstant
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
.golangci.yaml |
Added gocritic and nolintlint linters with exclusion for deprecatedComment in plumbing/hash.go |
worktree.go |
Simplified nested if-else to else-if structure |
storage/filesystem/object_test.go |
Simplified error handling by directly returning io.Copy result |
repository.go |
Converted if-else chain to switch statement for error handling |
plumbing/transport/upload_pack.go |
Refactored if-else chain to switch statement for cleaner control flow |
plumbing/transport/serve.go |
Simplified switch statement with single case to if statement |
plumbing/transport/loader.go |
Applied compound assignment operator (+=) |
plumbing/objectid.go |
Simplified switch to if and removed unnecessary slice expression |
plumbing/object/rename.go |
Converted if-else chains to switch statements with labeled breaks |
plumbing/object/patch.go |
Converted if-else chain to switch statement |
plumbing/hash/hash_test.go |
Converted if-else chain to switch statement for test assertions |
plumbing/format/packfile/patch_delta.go |
Converted if-else chain to switch statement |
plumbing/format/packfile/parser.go |
Converted if-else chain to switch statement |
plumbing/format/packfile/encoder_test.go |
Removed unnecessary slice expressions |
plumbing/format/packfile/diff_delta.go |
Converted if-else chain to switch statement |
plumbing/format/index/decoder_test.go |
Replaced plumbing.NewHash("") with plumbing.ZeroHash constant |
plumbing/format/idxfile/idxfile.go |
Converted if-else chain to switch statement |
plumbing/format/gitattributes/dir.go |
Applied compound assignment operator and slices.Concat |
plumbing/format/commitgraph/file.go |
Converted if-else chains to switch statements |
plumbing/format/commitgraph/encoder.go |
Converted if-else chain to switch statement |
example_test.go |
Changed log.Fatal to log.Print with return for proper cleanup; two functions missing return statements |
blame.go |
Converted if-else chains to switch statements with labeled breaks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: ferhat elmas <[email protected]>
d471551 to
baadba2
Compare
Signed-off-by: ferhat elmas <[email protected]>
baadba2 to
74d1e20
Compare
pjbgf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ferhatelmas thanks for working on this. 🙇
Related to #1753