Skip to content

Conversation

@ferhatelmas
Copy link
Contributor

Related to #1753

Copilot AI review requested due to automatic review settings December 4, 2025 22:13
Copy link
Contributor

Copilot AI left a 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 gocritic and nolintlint linters in .golangci.yaml with an exclusion rule for plumbing/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 using plumbing.ZeroHash constant

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]>
@ferhatelmas ferhatelmas force-pushed the ferhat/gocritic-nolint branch from d471551 to baadba2 Compare December 4, 2025 22:27
Signed-off-by: ferhat elmas <[email protected]>
@ferhatelmas ferhatelmas force-pushed the ferhat/gocritic-nolint branch from baadba2 to 74d1e20 Compare December 4, 2025 22:39
Copy link
Member

@pjbgf pjbgf left a 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. 🙇

@pjbgf pjbgf merged commit f9b6d05 into go-git:main Dec 5, 2025
16 checks passed
@ferhatelmas ferhatelmas deleted the ferhat/gocritic-nolint branch December 5, 2025 21:45
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