Skip to content
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

Update linter config, remove tests/e2e/go.mod #100

Merged
merged 8 commits into from
Feb 24, 2025
Merged

Conversation

evlekht
Copy link
Member

@evlekht evlekht commented Feb 24, 2025

Improved linter configuration, made it lint examples folder.
Removed tests/e2e/go.mod because it wasn't really needed here, but was preventing lint script from linting files in that dir.
Made a lot of fixed required by linter.

Copy link
Contributor

coderabbitai bot commented Feb 24, 2025

Warning

Rate limit exceeded

@evlekht has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 44 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between dc16064 and 5497de6.

📒 Files selected for processing (4)
  • tests/e2e/blockchain/client.go (5 hunks)
  • tests/e2e/blockchain/network.go (4 hunks)
  • tests/e2e/bot/factory.go (5 hunks)
  • tests/e2e/partner_plugin/factory.go (1 hunks)
📝 Walkthrough

Walkthrough

The changes span several Go source and configuration files. The modifications include added lint configuration settings in the .golangci.yml file, adjustments to logging practices using deferred anonymous functions that ignore errors from logger synchronization, and refactoring of gRPC methods to combine header-sending with return statements or remove unused parameters. Dependency versions along with Go modules have been updated, and numerous test files have undergone type consistency updates (e.g., port types from int to int32), adjustments to file permission modes, and renaming of types (e.g., MatrixServer to Server) for improved clarity and consistency.

Changes

File(s) Summary
.golangci.yml Added new linting settings (exclude-files, exclude-dirs-use-default, modules-download-mode, relative-path-mode, build-tags) to control file inclusion during analysis.
examples/booking/mintnbuy.go, examples/events/listen.go, examples/rpc/client.go Updated logger synchronization to use deferred anonymous functions, streamlined error handling, and simplified type conversion in function calls.
examples/rpc/partner-plugin/handlers/mint_v1.go, examples/rpc/partner-plugin/handlers/mint_v2.go, examples/rpc/partner-plugin/server.go Revised gRPC header handling by combining header send with return statements, removed unused grpc import in v2, and updated method signatures to mark unused parameters.
go.mod, tests/e2e/go.mod Upgraded Go version and dependencies (including new libraries and version bumps); removed the end-to-end test module file.
tests/e2e/blockchain/client.go, tests/e2e/blockchain/network.go, tests/e2e/resources/manager.go Modified function signatures by removing context parameters, converting port types from int to int32, updating regex usage, and adjusting file permission modes.
tests/e2e/bot/factory.go, tests/e2e/matrix/conduit.go, tests/e2e/partner_plugin/factory.go, tests/e2e/tests/test.go Renamed MatrixServer to Server; updated associated method signatures, variable types, and file permissions for consistency.
tests/e2e/e2e_test.go, tests/e2e/process/process.go, tests/e2e/tests/suite.go Enhanced error handling during test setup, grouped constant declarations for better organization, and removed extraneous comments for streamlined formatting.

Sequence Diagram(s)

sequenceDiagram
    participant Client as gRPC Client
    participant Service as MintService
    Client->>Service: Send Mint Request
    Service->>Service: Process request & extract metadata
    Service->>Service: Combine header-sending with response return
    Service-->>Client: Return response with header info
Loading

Poem

I’m a rabbit hopping in the code,
Where deferred functions lighten my load.
gRPC headers dance as responses bloom,
And type updates chase away the gloom.
With every change, I leap with delight,
Debugging by moon and coding by light.
Happy hops in our refactored night!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🔭 Outside diff range comments (1)
examples/rpc/partner-plugin/server.go (1)

68-96: 🛠️ Refactor suggestion

Consider refactoring common metadata handling.

All gRPC methods follow the same pattern for metadata extraction and logging. This could be refactored into a middleware or helper function to reduce code duplication.

func extractAndLogMetadata(ctx context.Context, methodName string) (metadata.Metadata, error) {
    md := metadata.Metadata{}
    if err := md.ExtractMetadata(ctx); err != nil {
        log.Print("error extracting metadata")
        return md, err
    }
    md.Stamp(fmt.Sprintf("%s-%s", "ext-system", "response"))
    log.Printf("Responding to request: %s (%s)", md.RequestID, methodName)
    log.Printf("CMAccount %s received request from CMAccount %s", md.Recipient, md.Sender)
    return md, nil
}

Example usage:

func (p *partnerPlugin) ActivitySearch(ctx context.Context, _ *activityv2.ActivitySearchRequest) (*activityv2.ActivitySearchResponse, error) {
-    md := metadata.Metadata{}
-    err := md.ExtractMetadata(ctx)
-    if err != nil {
-        log.Print("error extracting metadata")
-    }
-    md.Stamp(fmt.Sprintf("%s-%s", "ext-system", "response"))
-    log.Printf("Responding to request: %s (ActivitySearch)", md.RequestID)
+    md, _ := extractAndLogMetadata(ctx, "ActivitySearch")

    response := activityv2.ActivitySearchResponse{
        Header: &typesv1.ResponseHeader{
            Status: typesv1.StatusType_STATUS_TYPE_SUCCESS,
        },
        Metadata: &typesv2.SearchResponseMetadata{SearchId: &typesv1.UUID{Value: md.RequestID}},
    }
-    log.Printf("CMAccount %s received request from CMAccount %s", md.Recipient, md.Sender)

    return &response, grpc.SendHeader(ctx, md.ToGrpcMD())
}

Also applies to: 98-273, 275-311, 313-331, 333-348, 350-366, 368-424, 426-444, 446-462, 481-497, 499-671, 673-708, 710-799, 801-815, 817-831, 833-847, 849-859, 861-871

🧹 Nitpick comments (2)
tests/e2e/matrix/conduit.go (1)

83-83: Consider using strconv.FormatInt for explicit type conversion.

The current implementation uses strconv.Itoa(int(port)) which involves two type conversions. Consider using strconv.FormatInt(int64(port), 10) for a more direct conversion from int64 to string.

-"CONDUIT_PORT="+strconv.Itoa(int(port)),
+"CONDUIT_PORT="+strconv.FormatInt(int64(port), 10),
examples/rpc/partner-plugin/server.go (1)

801-815: Add implementation for insurance-related methods.

The insurance-related methods (InsuranceProductInfo, InsuranceProductList, InsuranceSearch) contain TODO comments but lack implementation. This could affect the functionality of the insurance service.

Would you like me to help implement these methods with example responses similar to other service methods in this file?

Also applies to: 817-831, 833-847

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c6b8e4 and 82cc4a4.

⛔ Files ignored due to path filters (2)
  • go.sum is excluded by !**/*.sum
  • tests/e2e/go.sum is excluded by !**/*.sum
📒 Files selected for processing (19)
  • .golangci.yml (1 hunks)
  • examples/booking/mintnbuy.go (2 hunks)
  • examples/events/listen.go (3 hunks)
  • examples/rpc/client.go (3 hunks)
  • examples/rpc/partner-plugin/handlers/mint_v1.go (1 hunks)
  • examples/rpc/partner-plugin/handlers/mint_v2.go (0 hunks)
  • examples/rpc/partner-plugin/server.go (18 hunks)
  • go.mod (7 hunks)
  • tests/e2e/blockchain/client.go (5 hunks)
  • tests/e2e/blockchain/network.go (4 hunks)
  • tests/e2e/bot/factory.go (5 hunks)
  • tests/e2e/e2e_test.go (1 hunks)
  • tests/e2e/go.mod (0 hunks)
  • tests/e2e/matrix/conduit.go (6 hunks)
  • tests/e2e/partner_plugin/factory.go (1 hunks)
  • tests/e2e/process/process.go (1 hunks)
  • tests/e2e/resources/manager.go (3 hunks)
  • tests/e2e/tests/suite.go (0 hunks)
  • tests/e2e/tests/test.go (1 hunks)
💤 Files with no reviewable changes (3)
  • tests/e2e/tests/suite.go
  • tests/e2e/go.mod
  • examples/rpc/partner-plugin/handlers/mint_v2.go
✅ Files skipped from review due to trivial changes (2)
  • tests/e2e/process/process.go
  • tests/e2e/partner_plugin/factory.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Unit Tests
🔇 Additional comments (22)
tests/e2e/tests/test.go (1)

26-26: LGTM! Type renaming is consistent.

The change from *matrix.MatrixServer to *matrix.Server aligns with the broader codebase changes to simplify type names.

tests/e2e/e2e_test.go (1)

85-88: LGTM! Improved error handling for directory creation.

The addition of error handling for os.MkdirAll ensures that directory creation failures are properly reported, making test failures more debuggable.

examples/rpc/partner-plugin/handlers/mint_v1.go (1)

84-84: LGTM! More concise return statement.

Combining the header sending with the return statement reduces code verbosity while maintaining the same functionality.

.golangci.yml (1)

4-11: LGTM! Enhanced linter configuration.

The new configuration:

  • Properly excludes generated files (*.pb.go) and mocks
  • Uses readonly module mode for safer CI runs
  • Includes e2e build tag for comprehensive linting
examples/booking/mintnbuy.go (2)

33-33: LGTM! Consistent error handling for logger synchronization.

The change to ignore logger sync errors using a deferred anonymous function is a good practice, as these errors are typically non-critical and occur during shutdown.


177-177: LGTM! Removed redundant type conversion.

Simplified the code by removing unnecessary type conversion since tokenDecimals is already of type int32.

examples/events/listen.go (2)

33-33: LGTM! Consistent error handling for logger synchronization.

The change to ignore logger sync errors using a deferred anonymous function aligns with the project's error handling patterns.


36-40: LGTM! Improved error handling with structured logging.

Consistently updated error handling to use sugar.Fatalf instead of log.Fatalf, which provides better structured logging capabilities.

Also applies to: 52-52, 63-63, 71-71, 79-79, 87-87

examples/rpc/client.go (3)

38-38: LGTM! Consistent error handling for logger synchronization.

The change to ignore logger sync errors using a deferred anonymous function aligns with the project's error handling patterns.


123-123: Verify the impact of ignoring shutdown errors.

While ignoring shutdown errors simplifies the code, we should ensure this doesn't mask important cleanup issues.

Please verify that ignoring shutdown errors is safe in your context. Consider logging these errors at debug level instead of completely ignoring them.


134-140: LGTM! Improved type definition and memory allocation.

Good improvements:

  • Defined explicit entry type for better code organization
  • Optimized slice capacity initialization based on known size
go.mod (2)

9-9: Verify stability of RC dependency.

Using a release candidate version (v1.1.0-rc1) of caminogoeth-compat in production might be risky.

Please confirm if there's a stable release available or if the RC version is intentionally chosen for specific features.


3-3:

❓ Verification inconclusive

Verify Go version compatibility.

The specified Go version 1.23.4 seems incorrect as it's higher than the current latest stable version.


🌐 Web query:

What is the latest stable version of Go?

💡 Result:

The latest stable version of Go as of February 24, 2025 is Go 1.24.0, released on February 11, 2025[3][7]. This release follows the standard six-month cadence for major Go updates[1][6].

Key Details:

  • Release Date: February 11, 2025[3][7]
  • Support Status: Actively supported (until two newer major releases exist)[3][4]
  • Previous Versions:
    • Go 1.23.x (latest: v1.23.6 from Feb 4, 2025)[3]
    • Go 1.22.x (latest: v1.22.12 from Feb 4, 2025)[3]

Support Policy:

Each major Go version receives support until two subsequent releases are published[3][4]. For example:

  • Go 1.23 will be supported until Go 1.25 releases
  • Go 1.24 will be supported until Go 1.26 releases

The current support window includes:

Version Support End Date
Go 1.24 ~August 2026
Go 1.23 ~February 2026

Users are recommended to maintain their environments with one of the latest two supported releases for security updates and critical bug fixes[3][4].

Citations:


Action Required: Confirm Go Version and Dependency Stability

  • The go.mod file specifies go 1.23.4; however, as of February 2025 the latest stable release is Go 1.24.0. Please verify whether there’s an intentional reason for remaining on the 1.23 branch or if upgrading to 1.24.0 is feasible.
  • Additionally, review the use of caminogoeth-compat v1.1.0-rc1 to ensure that the release candidate status aligns with your stability requirements.
tests/e2e/bot/factory.go (3)

48-48: LGTM! Type consistency improvement.

The change from *matrix.MatrixServer to *matrix.Server improves type consistency across the codebase.

Also applies to: 69-69


109-109: LGTM! Port type standardization.

Changed port type from int to int32 for consistency with other port-related variables across the codebase.


168-168: LGTM! Enhanced file security.

Changed file permissions from 0o644 to 0o600 to restrict access to owner-only, improving security for sensitive configuration and log files.

Also applies to: 186-186

tests/e2e/blockchain/network.go (1)

63-64: LGTM! Port type standardization.

Changed port-related types from int to int32 for consistency across the codebase.

Also applies to: 255-256

tests/e2e/blockchain/client.go (2)

250-252: LGTM! Simplified method signature.

Removed unnecessary ctx parameter from CMAccount method as it's not used within the function.


377-381: LGTM! Improved regexp compilation.

Changed to MustCompile for the constant regex pattern, which is appropriate as the pattern is known to be valid at compile time.

tests/e2e/resources/manager.go (1)

36-36: LGTM! Port type standardization.

Changed all port-related types from int to int32 for consistency across the codebase. The changes maintain type safety and improve code clarity by:

  • Using consistent types for port numbers
  • Removing unnecessary type conversions
  • Ensuring type safety in map operations and comparisons

Also applies to: 46-46, 51-51, 57-57, 61-61, 64-64, 76-76, 79-79

tests/e2e/matrix/conduit.go (2)

76-78: Good addition of error handling for directory creation.

The error handling for os.MkdirAll is now properly implemented, which helps prevent silent failures.


138-140: Good documentation and thread safety warning.

The comment clearly indicates that the server is not safe for concurrent use, which is important information for users of this type.

@evlekht evlekht changed the title Updage linter config, remove tests/e2e/go.mod Update linter config, remove tests/e2e/go.mod Feb 24, 2025
@evlekht evlekht merged commit 226808d into dev Feb 24, 2025
7 checks passed
@evlekht evlekht deleted the evlekht/fix-linter branch February 24, 2025 17:43
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