Skip to content

chore(lint): comprehensive lint + structural refactors (dist backend, eviction, middleware)#48

Merged
hyp3rd merged 1 commit intomainfrom
feat/distributed-backend
Aug 22, 2025
Merged

chore(lint): comprehensive lint + structural refactors (dist backend, eviction, middleware)#48
hyp3rd merged 1 commit intomainfrom
feat/distributed-backend

Conversation

@hyp3rd
Copy link
Owner

@hyp3rd hyp3rd commented Aug 22, 2025

No description provided.

Copilot AI review requested due to automatic review settings August 22, 2025 21:22
@trunk-io
Copy link

trunk-io bot commented Aug 22, 2025

Running Code Quality on PRs by uploading data to Trunk will soon be removed. You can still run checks on your PRs using trunk-action - see the migration guide for more information.

@hyp3rd hyp3rd merged commit b65e067 into main Aug 22, 2025
4 of 5 checks passed
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 is a comprehensive lint and structural refactoring PR that applies linting fixes throughout the codebase, focusing on code formatting, error handling improvements, and structural optimizations for the distributed backend, eviction algorithms, and middleware components.

Key changes include:

  • Enabled comprehensive linting rules (revive, wsl_v5) with 160+ configuration changes
  • Refactored error handling to use errors.Is() for proper error comparison
  • Updated loop syntax to use modern Go range patterns (for range N instead of for i := 0; i < N; i++)

Reviewed Changes

Copilot reviewed 54 out of 54 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
.golangci.yaml Added comprehensive revive and wsl_v5 linter configurations
tests/*.go Applied whitespace formatting, modern loop syntax, and error handling improvements
pkg/eviction/*.go Refactored eviction algorithms with improved documentation and structural optimizations
pkg/middleware/*.go Extracted constants for attribute keys and improved code organization
pkg/backend/*.go Major structural refactoring of distributed memory backend with improved error handling
management_http.go Split large function into smaller helper methods for better maintainability

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

)

shouldExpire := test.expectedErr == sentinel.ErrKeyExpired
shouldExpire := errors.Is(test.expectedErr, sentinel.ErrKeyExpired)
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

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

Using errors.Is() with sentinel.ErrKeyExpired assumes it's a wrapped error, but the original direct comparison suggests it's a sentinel value. This could cause false negatives if the error is not wrapped. Consider verifying that sentinel.ErrKeyExpired is properly implemented as a wrapped error or revert to direct comparison.

Suggested change
shouldExpire := errors.Is(test.expectedErr, sentinel.ErrKeyExpired)
shouldExpire := test.expectedErr == sentinel.ErrKeyExpired

Copilot uses AI. Check for mistakes.
return false
}

func (c *ClockAlgorithm) tryInsertInFreeSlot(key string, value any) bool { //nolint:ireturn
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

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

The //nolint:ireturn comment appears incorrect here. This function returns a boolean, not an interface, so the ireturn linter should not apply. Consider removing this comment as it's misleading.

Suggested change
func (c *ClockAlgorithm) tryInsertInFreeSlot(key string, value any) bool { //nolint:ireturn
func (c *ClockAlgorithm) tryInsertInFreeSlot(key string, value any) bool {

Copilot uses AI. Check for mistakes.

const (
errMsgNewRequest = "new request"
errMsgDoRequest = "do request"
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

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

[nitpick] These error message constants are overly generic and don't provide specific context about the operation. Consider more descriptive names like errMsgCreateHTTPRequest and errMsgExecuteHTTPRequest to improve debugging clarity.

Suggested change
errMsgDoRequest = "do request"
errMsgCreateSetRequest = "create set request"
errMsgExecuteSetRequest = "execute set request"

Copilot uses AI. Check for mistakes.
go func() { // capture server errors (ignored intentionally for now)
serveErr := s.app.Listener(ln)
if serveErr != nil { // separated for noinlineerr linter
_ = serveErr
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

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

Silently ignoring server errors with _ = serveErr makes debugging difficult. Consider logging the error or providing a callback mechanism to handle server startup failures, especially since this is infrastructure code.

Suggested change
_ = serveErr
go func() { // capture server errors (log them)
serveErr := s.app.Listener(ln)
if serveErr != nil { // separated for noinlineerr linter
log.Printf("distHTTPServer: server error: %v", serveErr)

Copilot uses AI. Check for mistakes.
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.

1 participant