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

Specify clippy MSRV #17

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

NxPKG
Copy link
Contributor

@NxPKG NxPKG commented Mar 6, 2025

User description

Notes for Reviewers

This PR fixes #

Signed commits

  • Yes, I signed my commits.

PR Type

enhancement, configuration changes


Description

  • Added a new clippy.toml configuration file.

  • Specified the Minimum Supported Rust Version (MSRV) as 1.72.

  • Addressed the unmaintained status of the ring package indirectly by ensuring compatibility with updated tooling.


Changes walkthrough 📝

Relevant files
Configuration changes
clippy.toml
Added Clippy configuration with MSRV set to 1.72                 

clippy.toml

  • Added a new clippy.toml configuration file.
  • Set the MSRV to 1.72 for Clippy.
  • +1/-0     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Summary by CodeRabbit

    • Chores

      • Updated project configuration to require a minimum supported Rust version of 1.72, ensuring compatibility with modern tooling.
    • New Features

      • Introduced a new compression mechanism with a unified interface through the ZstdCompression enum, enhancing the clarity and structure of compression operations.
      • Added methods for compression and decompression within the new ZstdCompression enum, streamlining data handling processes.

    Signed-off-by: NxPKG <[email protected]>
    @NxPKG NxPKG linked an issue Mar 6, 2025 that may be closed by this pull request
    Copy link

    sourcery-ai bot commented Mar 6, 2025

    Reviewer's Guide by Sourcery

    This pull request specifies the Minimum Supported Rust Version (MSRV) for Clippy by adding a clippy.toml file and setting the msrv key to 1.72.

    No diagrams generated as the changes look simple and do not need a visual representation.

    File-Level Changes

    Change Details Files
    Specified the Minimum Supported Rust Version (MSRV) for Clippy.
    • Added a clippy.toml file.
    • Set the msrv key to 1.72.
    clippy.toml

    Tips and commands

    Interacting with Sourcery

    • Trigger a new review: Comment @sourcery-ai review on the pull request.
    • Continue discussions: Reply directly to Sourcery's review comments.
    • Generate a GitHub issue from a review comment: Ask Sourcery to create an
      issue from a review comment by replying to it. You can also reply to a
      review comment with @sourcery-ai issue to create an issue from it.
    • Generate a pull request title: Write @sourcery-ai anywhere in the pull
      request title to generate a title at any time. You can also comment
      @sourcery-ai title on the pull request to (re-)generate the title at any time.
    • Generate a pull request summary: Write @sourcery-ai summary anywhere in
      the pull request body to generate a PR summary at any time exactly where you
      want it. You can also comment @sourcery-ai summary on the pull request to
      (re-)generate the summary at any time.
    • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
      request to (re-)generate the reviewer's guide at any time.
    • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
      pull request to resolve all Sourcery comments. Useful if you've already
      addressed all the comments and don't want to see them anymore.
    • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
      request to dismiss all existing Sourcery reviews. Especially useful if you
      want to start fresh with a new review - don't forget to comment
      @sourcery-ai review to trigger a new review!
    • Generate a plan of action for an issue: Comment @sourcery-ai plan on
      an issue to generate a plan of action for it.

    Customizing Your Experience

    Access your dashboard to:

    • Enable or disable review features such as the Sourcery-generated pull request
      summary, the reviewer's guide, and others.
    • Change the review language.
    • Add, remove or edit custom review instructions.
    • Adjust other review settings.

    Getting Help

    Copy link

    coderabbitai bot commented Mar 6, 2025

    Warning

    Rate limit exceeded

    @NxPKG has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 50 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 6658165 and 050df46.

    📒 Files selected for processing (2)
    • bongonet-proxy/src/lib.rs (1 hunks)
    • bongonet-proxy/src/proxy_trait.rs (1 hunks)

    Walkthrough

    This pull request introduces a new configuration entry in the clippy.toml file, establishing the minimum supported Rust version (MSRV) as "1.72". Additionally, it refactors the compression mechanism within the HeaderSerde struct by introducing a new enum type ZstdCompression, which simplifies the handling of compression and decompression operations.

    Changes

    File Path Change Summary
    clippy.toml Added configuration entry msrv = "1.72" to specify the minimum Rust version.
    bongonet-header-serde/src/lib.rs Refactored compression mechanism: added enum ZstdCompression, methods compress and decompress_to_buffer.

    Poem

    I'm a rabbit, hopping along the file trail,
    Found a change that made my heart set sail.
    In clippy.toml, a new line shines bright,
    Rust 1.72 is now in sight.
    With every hop, I cheer the code's delight!
    In HeaderSerde, compression takes flight! 🐇✨


    Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

    ❤️ 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.
    • @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

    @sourcery-ai sourcery-ai bot left a comment

    Choose a reason for hiding this comment

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

    Hey @NxPKG - I've reviewed your changes - here's some feedback:

    Overall Comments:

    • Consider adding a comment explaining why this MSRV was chosen.
    Here's what I looked at during the review
    • 🟢 General issues: all looks good
    • 🟢 Security: all looks good
    • 🟢 Testing: all looks good
    • 🟢 Complexity: all looks good
    • 🟢 Documentation: all looks good

    Sourcery is free for open source - if you like our reviews please consider sharing them ✨
    Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis 🔶

    16 - Partially compliant

    Compliant requirements:

    • Partially addresses the unmaintained status of the ring package by ensuring compatibility with updated tooling

    Non-compliant requirements:

    • Does not directly address the core issue of depending on an unmaintained package
    • Does not replace or remove the dependency on the ring package

    Requires further human verification:

    • Verify if specifying MSRV is sufficient as a mitigation strategy for the unmaintained package
    • Determine if a plan exists to replace the ring dependency with a maintained alternative

    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 No relevant tests
    🔒 Security concerns

    Yes, Dependency on unmaintained cryptography:
    The PR doesn't remove or replace the dependency on the unmaintained ring cryptography package. According to the ticket, the package author has announced an indefinite hiatus, meaning security vulnerabilities may go unaddressed. Setting an MSRV doesn't resolve the underlying security risk of using an unmaintained cryptography library.

    ⚡ Recommended focus areas for review

    Incomplete Solution

    The PR only adds MSRV configuration for Clippy but doesn't address the core issue of depending on an unmaintained package. This is a partial solution that may not fully mitigate the security risks.

    msrv = "1.72"

    Copy link

    codiumai-pr-agent-free bot commented Mar 6, 2025

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    Copy link

    codiumai-pr-agent-free bot commented Mar 6, 2025

    CI Feedback 🧐

    (Feedback updated until commit 050df46)

    A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

    Action: build

    Failed stage: Build and push Docker image [❌]

    Failure summary:

    The build failed because of compilation errors in the Rust code:

    1. The code in bongonet-header-serde/src/lib.rs is trying to use CompressionWithDict from the
    thread_zstd module, but this type/struct doesn't exist in that module.

    2. Two specific errors were reported:
    - Error at line 56: Failed to resolve
    thread_zstd::CompressionWithDict when creating a new instance
    - Error at line 103: Cannot find
    the type CompressionWithDict in module thread_zstd

    3. The Docker build process failed with exit code 101 during the cargo build step.

    Relevant error logs:
    1:  ##[group]Operating System
    2:  Ubuntu
    ...
    
    714:  #12 2.696   Downloaded pin-project-lite v0.2.16
    715:  #12 2.704   Downloaded parking_lot v0.12.3
    716:  #12 2.707   Downloaded log v0.4.26
    717:  #12 2.711   Downloaded boring v4.15.0
    718:  #12 2.722   Downloaded aws-lc-rs v1.12.5
    719:  #12 2.736   Downloaded aho-corasick v1.1.3
    720:  #12 2.744   Downloaded tokio-stream v0.1.17
    721:  #12 2.751   Downloaded thrift_codec v0.2.0
    722:  #12 2.755   Downloaded thiserror v1.0.69
    ...
    
    738:  #12 2.811   Downloaded tokio-openssl v0.6.5
    739:  #12 2.813   Downloaded thread_local v1.1.8
    740:  #12 2.815   Downloaded strsim v0.10.0
    741:  #12 2.817   Downloaded rustversion v1.0.20
    742:  #12 2.821   Downloaded rustc-demangle v0.1.24
    743:  #12 2.823   Downloaded rmp-serde v1.3.0
    744:  #12 2.826   Downloaded rmp v0.8.14
    745:  #12 2.833   Downloaded quote v1.0.39
    746:  #12 2.836   Downloaded proc-macro-error v1.0.4
    ...
    
    754:  #12 2.859   Downloaded zstd v0.13.3
    755:  #12 2.863   Downloaded h2 v0.4.8
    756:  #12 2.872   Downloaded futures-util v0.3.31
    757:  #12 2.891   Downloaded crypto-common v0.1.6
    758:  #12 2.892   Downloaded cmake v0.1.54
    759:  #12 2.894   Downloaded cc v1.2.16
    760:  #12 2.900   Downloaded tokio-macros v2.5.0
    761:  #12 2.901   Downloaded tiny-keccak v2.0.2
    762:  #12 2.905   Downloaded thiserror-impl v1.0.69
    763:  #12 2.907   Downloaded termcolor v1.4.1
    764:  #12 2.909   Downloaded signal-hook-registry v1.4.2
    765:  #12 2.911   Downloaded shlex v1.3.0
    766:  #12 2.913   Downloaded seize v0.3.3
    767:  #12 2.916   Downloaded scopeguard v1.2.0
    768:  #12 2.917   Downloaded rustc-hash v1.1.0
    769:  #12 2.919   Downloaded rand_chacha v0.3.1
    770:  #12 2.921   Downloaded proc-macro-error-attr v1.0.4
    ...
    
    896:  #12 11.75    Compiling zerocopy v0.7.35
    897:  #12 12.35    Compiling ppv-lite86 v0.2.20
    898:  #12 13.17    Compiling rand_core v0.6.4
    899:  #12 13.30    Compiling thread_local v1.1.8
    900:  #12 13.49    Compiling ahash v0.8.11
    901:  #12 13.68    Compiling fnv v1.0.7
    902:  #12 13.75    Compiling rand_chacha v0.3.1
    903:  #12 14.98    Compiling const-random v0.1.18
    904:  #12 15.49    Compiling proc-macro-error-attr v1.0.4
    905:  #12 15.68    Compiling dunce v1.0.5
    906:  #12 15.73    Compiling bongonet-error v0.4.0 (/var/opt/bongonet/bongonet-error)
    907:  #12 15.97    Compiling glob v0.3.2
    908:  #12 16.26    Compiling itoa v1.0.15
    909:  #12 16.33    Compiling thiserror v1.0.69
    910:  #12 16.59    Compiling zstd-safe v7.2.3
    911:  #12 16.77    Compiling http v1.2.0
    912:  #12 16.79    Compiling clang-sys v1.8.1
    913:  #12 16.80    Compiling aws-lc-sys v0.26.0
    914:  #12 17.29    Compiling rand v0.8.5
    915:  #12 17.61    Compiling thiserror-impl v1.0.69
    916:  #12 17.84    Compiling futures-macro v0.3.31
    917:  #12 17.90    Compiling futures-channel v0.3.31
    918:  #12 18.06    Compiling proc-macro-error v1.0.4
    ...
    
    1029:  #12 72.56    Compiling openssl v0.10.71
    1030:  #12 72.77    Compiling hostname v0.3.1
    1031:  #12 72.85    Compiling foreign-types v0.3.2
    1032:  #12 72.88    Compiling digest v0.10.7
    1033:  #12 73.01    Compiling local-ip-address v0.5.7
    1034:  #12 76.87    Compiling cf-rustracing v1.1.0
    1035:  #12 77.68    Compiling thrift_codec v0.2.0
    1036:  #12 78.69    Compiling bongonet-header-serde v0.4.0 (/var/opt/bongonet/bongonet-header-serde)
    1037:  #12 78.74 error[E0433]: failed to resolve: could not find `CompressionWithDict` in `thread_zstd`
    1038:  #12 78.74   --> bongonet-header-serde/src/lib.rs:56:69
    1039:  #12 78.74    |
    1040:  #12 78.74 56 |                 compression: ZstdCompression::WithDict(thread_zstd::CompressionWithDict::new(
    1041:  #12 78.74    |                                                                     ^^^^^^^^^^^^^^^^^^^ could not find `CompressionWithDict` in `thread_zstd`
    1042:  #12 78.74 
    1043:  #12 78.75 error[E0412]: cannot find type `CompressionWithDict` in module `thread_zstd`
    1044:  #12 78.75    --> bongonet-header-serde/src/lib.rs:103:27
    1045:  #12 78.75     |
    1046:  #12 78.75 103 |     WithDict(thread_zstd::CompressionWithDict),
    1047:  #12 78.75     |                           ^^^^^^^^^^^^^^^^^^^ not found in `thread_zstd`
    1048:  #12 78.75 
    1049:  #12 78.79 Some errors have detailed explanations: E0412, E0433.
    1050:  #12 78.79 For more information about an error, try `rustc --explain E0412`.
    1051:  #12 78.80 error: could not compile `bongonet-header-serde` (lib) due to 2 previous errors
    1052:  #12 78.80 warning: build failed, waiting for other jobs to finish...
    1053:  #12 ERROR: process "/bin/sh -c cargo build" did not complete successfully: exit code: 101
    1054:  ------
    1055:  > [6/6] RUN cargo build:
    1056:  78.75 error[E0412]: cannot find type `CompressionWithDict` in module `thread_zstd`
    1057:  78.75    --> bongonet-header-serde/src/lib.rs:103:27
    1058:  78.75     |
    1059:  78.75 103 |     WithDict(thread_zstd::CompressionWithDict),
    1060:  78.75     |                           ^^^^^^^^^^^^^^^^^^^ not found in `thread_zstd`
    1061:  78.75 
    1062:  78.79 Some errors have detailed explanations: E0412, E0433.
    1063:  78.79 For more information about an error, try `rustc --explain E0412`.
    1064:  78.80 error: could not compile `bongonet-header-serde` (lib) due to 2 previous errors
    1065:  78.80 warning: build failed, waiting for other jobs to finish...
    ...
    
    1069:  �[0m - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 1)
    1070:  Dockerfile:20
    1071:  --------------------
    1072:  18 |     WORKDIR /var/opt/bongonet
    1073:  19 |     COPY . .
    1074:  20 | >>> RUN cargo build
    1075:  21 |     
    1076:  --------------------
    1077:  ERROR: failed to solve: process "/bin/sh -c cargo build" did not complete successfully: exit code: 101
    1078:  ##[error]buildx failed with: ERROR: failed to solve: process "/bin/sh -c cargo build" did not complete successfully: exit code: 101
    

    Copy link

    @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: 0

    🧹 Nitpick comments (5)
    bongonet-header-serde/src/lib.rs (5)

    99-104: Well-designed enum for compression strategies.

    The enum provides a good abstraction for the two compression scenarios. Consider adding documentation comments to explain the purpose and usage of each variant.

    // Wrapper type to unify compressing with and withuot a dictionary,
    // since the two structs have different inputs for their APIs.
    +/// Enum representing different compression strategies.
    +///
    +/// This enum encapsulates two different approaches to compression:
    +/// - Default: Uses standard compression without a dictionary
    +/// - WithDict: Uses compression with a trained dictionary for better compression ratios
    enum ZstdCompression {
    +    /// Standard compression with specified compression level
        Default(thread_zstd::Compression, i32),
    +    /// Compression with a trained dictionary for improved compression
        WithDict(thread_zstd::CompressionWithDict),
    }

    114-117: Fix error context message in compression.

    The error context message in the compress method incorrectly states "decompress header" which doesn't match the operation being performed.

        fn compress(&self, data: &[u8]) -> Result<Vec<u8>> {
            match &self {
                ZstdCompression::Default(c, level) => c
                    .compress(data, *level)
    -                .map_err(|e| into_error(e, "decompress header")),
    +                .map_err(|e| into_error(e, "compress header")),
                ZstdCompression::WithDict(c) => c

    118-120: Fix error context message in compression (WithDict variant).

    Similar to the previous comment, the error context message for the WithDict variant also needs correction.

                ZstdCompression::WithDict(c) => c
                    .compress(data)
    -                .map_err(|e| into_error(e, "decompress header")),
    +                .map_err(|e| into_error(e, "compress header")),

    111-133: Consider reducing code duplication in error handling.

    Both methods of the ZstdCompression enum have similar error handling patterns. You could potentially refactor this to reduce duplication, especially if more variants are added in the future.

    Here's a possible approach using a helper method:

    impl ZstdCompression {
    +    // Helper method to standardize error handling
    +    fn handle_error<T>(&self, result: std::result::Result<T, &'static str>, context: &'static str) -> Result<T> {
    +        result.map_err(|e| into_error(e, context))
    +    }
    
        fn compress(&self, data: &[u8]) -> Result<Vec<u8>> {
            match &self {
                ZstdCompression::Default(c, level) => c
                    .compress(data, *level)
    -                .map_err(|e| into_error(e, "compress header")),
    +                .map_err(|e| into_error(e, "compress header")),
                ZstdCompression::WithDict(c) => c
                    .compress(data)
    -                .map_err(|e| into_error(e, "compress header")),
    +                .map_err(|e| into_error(e, "compress header")),
            }
        }
    
        fn decompress_to_buffer(&self, source: &[u8], destination: &mut Vec<u8>) -> Result<usize> {
            match &self {
                ZstdCompression::Default(c, _) => c
                    .decompress_to_buffer(source, destination)
    -                .map_err(|e| into_error(e, "decompress header")),
    +                .map_err(|e| into_error(e, "decompress header")),
                ZstdCompression::WithDict(c) => c
                    .decompress_to_buffer(source, destination)
    -                .map_err(|e| into_error(e, "decompress header")),
    +                .map_err(|e| into_error(e, "decompress header")),
            }
        }
    }

    Note: The implementation above maintains the current behavior while introducing the helper method, but doesn't actually use it yet. You would need to refactor the method calls to use this helper.


    99-99: Fix typo in comment.

    There's a small typo in the comment describing the ZstdCompression enum.

    -// Wrapper type to unify compressing with and withuot a dictionary,
    +// Wrapper type to unify compressing with and without a dictionary,
    📜 Review details

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

    📥 Commits

    Reviewing files that changed from the base of the PR and between 15b7761 and 6658165.

    📒 Files selected for processing (1)
    • bongonet-header-serde/src/lib.rs (5 hunks)
    ⏰ Context from checks skipped due to timeout of 90000ms (1)
    • GitHub Check: build
    🔇 Additional comments (5)
    bongonet-header-serde/src/lib.rs (5)

    29-30: Package imports look good!

    The imports now explicitly reference external packages bongonet_error and bongonet_http. This improves clarity and suggests proper modularization of the codebase.


    40-40: Great refactoring of the compression field type.

    Changing the type to use the new ZstdCompression enum provides a cleaner abstraction for handling different compression strategies.


    54-70: Initialization logic looks correct.

    The updated initialization properly uses the new enum variants based on dictionary presence. The conditional logic is clear and maintains the original functionality.


    83-83: Simplified serialization call.

    Using the unified compress method from the ZstdCompression enum improves code clarity by encapsulating the compression details within the enum implementation.


    93-94: Cleaner error handling in deserialization.

    The updated code properly delegates error handling to the ZstdCompression enum implementation, making the code more concise and maintainable.

    NxPKG added 2 commits March 6, 2025 07:07
    Signed-off-by: NxPKG <[email protected]>
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    RUSTSEC-2025-0007: *ring* is unmaintained
    1 participant