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

refactor(core): Modernize function signatures in the streaming decompressor interface and its implementations to align with the latest C++ coding guidelines. #702

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

Bill-hbrhbr
Copy link
Contributor

@Bill-hbrhbr Bill-hbrhbr commented Jan 30, 2025

Description

Use the following clang-tidy checks to fix all function signature issues:

    modernize-use-nodiscard,
    modernize-use-override,
    modernize-pass-by-value,
    modernize-use-trailing-return-type,
    bugprone-exception-escape,
    bugprone-forward-declaration-namespace,
    bugprone-forwarding-reference-overload,
    bugprone-macro-parentheses,
    bugprone-unused-return-value,
    readability-avoid-const-params-in-decls,
    readability-convert-member-functions-to-static,
    readability-inconsistent-declaration-parameter-name,
    readability-redundant-function-ptr-dereference,
    readability-redundant-declaration,
    readability-redundant-member-init,
    readability-redundant-return-type,
    performance-unnecessary-value-param,
    performance-move-const-arg,
    misc-unused-parameters,
    misc-misplaced-const,
    misc-definitions-in-headers,
    misc-no-recursion,
    misc-const-correctness,
    misc-static-assert,
    clang-analyzer-core.CallAndMessage,
    clang-analyzer-core.UndefinedFunction,
    clang-analyzer-cplusplus.NewDeleteLeaks,
    clang-analyzer-cplusplus.VirtualCall,
    clang-analyzer-cplusplus.Move,
    clang-analyzer-core.StackAddressEscape

Note that this is an overly thorough checklist regarding function signatures, but it's still a subset of the complete config.

Validation performed

  • No change to functionality. All unit tests still pass.

Summary by CodeRabbit

  • Refactor

    • Updated method signatures across multiple decompression classes to use modern C++ syntax
    • Added trailing return types and [[nodiscard]] attributes to improve code clarity
    • Enhanced destructor and constructor definitions for better memory management
  • Code Quality

    • Improved type safety and code readability in streaming compression components
    • Explicitly marked method overrides and default constructors

The changes primarily focus on modernizing the codebase's syntax and improving type safety without altering core functionality.

Copy link
Contributor

coderabbitai bot commented Jan 30, 2025

Walkthrough

The pull request introduces modifications to several header and implementation files within the clp::streaming_compression namespace, focusing on method signature updates and enhancing code consistency. The primary changes involve adopting trailing return type syntax, adding [[nodiscard]] attributes, explicitly marking destructors as override, and defining move and copy constructors. These modifications primarily affect the Decompressor classes in different compression implementations, ensuring more modern C++ coding practices and improving type safety.

Changes

File Change Summary
components/core/src/clp/WriterInterface.hpp Added virtual destructor to WriterInterface class
components/core/src/clp/streaming_compression/Compressor.hpp Updated destructor to explicitly override
components/core/src/clp/streaming_compression/Decompressor.hpp Updated method signatures with trailing return types, added [[nodiscard]], modified destructor and constructors
components/core/src/clp/streaming_compression/passthrough/Decompressor.hpp Similar changes to method signatures and constructors
components/core/src/clp/streaming_compression/passthrough/Decompressor.cpp Updated method signatures with trailing return types
components/core/src/clp/streaming_compression/zstd/Decompressor.hpp Updated method signatures, added [[nodiscard]], modified constructors
components/core/src/clp/streaming_compression/zstd/Decompressor.cpp Updated method signatures with trailing return types

Possibly related PRs

Suggested reviewers

  • LinZhihao-723
  • gibber9809
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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.

@Bill-hbrhbr Bill-hbrhbr changed the title fix(core-clp): update function signatures to comply with Clang-Tidy checks fixs(core-clp): update function signatures to comply with Clang-Tidy checks Jan 30, 2025
@Bill-hbrhbr Bill-hbrhbr changed the title fixs(core-clp): update function signatures to comply with Clang-Tidy checks refactor(core-clp): update function signatures to comply with Clang-Tidy checks Jan 30, 2025
@Bill-hbrhbr Bill-hbrhbr changed the title refactor(core-clp): update function signatures to comply with Clang-Tidy checks refactor(core-clp): update function signatures to comply with Clang-Tidy checks. Jan 30, 2025
@Bill-hbrhbr Bill-hbrhbr changed the title refactor(core-clp): update function signatures to comply with Clang-Tidy checks. refactor(core-clp): modernize function signatures in the streaming decompressor interface and its implementations to comply with Clang-Tidy checks. Jan 30, 2025
@Bill-hbrhbr Bill-hbrhbr changed the title refactor(core-clp): modernize function signatures in the streaming decompressor interface and its implementations to comply with Clang-Tidy checks. refactor(core-clp): Modernize function signatures in the streaming decompressor interface and its implementations to comply with Clang-Tidy checks. Jan 30, 2025
@Bill-hbrhbr Bill-hbrhbr marked this pull request as ready for review January 30, 2025 03:31
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: 0

🧹 Nitpick comments (2)
components/core/src/clp/streaming_compression/zstd/Decompressor.hpp (2)

40-48: LGTM! Well-structured special member functions.

The special member functions follow the Rule of Five correctly:

  • Destructor is properly marked override
  • Copy operations are explicitly deleted
  • Move operations are defaulted and correctly marked noexcept

Consider grouping the special member functions together by moving the destructor declaration after the move assignment operator for better readability:

-    ~Decompressor() override;
-
     // Delete copy constructor and assignment operator
     Decompressor(Decompressor const&) = delete;
     auto operator=(Decompressor const&) -> Decompressor& = delete;

     // Default move constructor and assignment operator
     Decompressor(Decompressor&&) noexcept = default;
     auto operator=(Decompressor&&) noexcept -> Decompressor& = default;
+    ~Decompressor() override;

82-84: Consider omitting void return type.

While the signatures are correct, modern C++ allows omitting the -> void return type specification.

-    auto open(char const* compressed_data_buf, size_t compressed_data_buf_size) -> void override;
-    auto open(ReaderInterface& reader, size_t read_buffer_capacity) -> void override;
-    auto close() -> void override;
+    void open(char const* compressed_data_buf, size_t compressed_data_buf_size) override;
+    void open(ReaderInterface& reader, size_t read_buffer_capacity) override;
+    void close() override;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4586095 and 5b66f92.

📒 Files selected for processing (7)
  • components/core/src/clp/WriterInterface.hpp (1 hunks)
  • components/core/src/clp/streaming_compression/Compressor.hpp (1 hunks)
  • components/core/src/clp/streaming_compression/Decompressor.hpp (2 hunks)
  • components/core/src/clp/streaming_compression/passthrough/Decompressor.cpp (7 hunks)
  • components/core/src/clp/streaming_compression/passthrough/Decompressor.hpp (4 hunks)
  • components/core/src/clp/streaming_compression/zstd/Decompressor.cpp (9 hunks)
  • components/core/src/clp/streaming_compression/zstd/Decompressor.hpp (5 hunks)
✅ Files skipped from review due to trivial changes (2)
  • components/core/src/clp/streaming_compression/passthrough/Decompressor.cpp
  • components/core/src/clp/streaming_compression/zstd/Decompressor.cpp
🧰 Additional context used
📓 Path-based instructions (5)
components/core/src/clp/WriterInterface.hpp (1)

Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

components/core/src/clp/streaming_compression/Compressor.hpp (1)

Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

components/core/src/clp/streaming_compression/Decompressor.hpp (1)

Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

components/core/src/clp/streaming_compression/zstd/Decompressor.hpp (1)

Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

components/core/src/clp/streaming_compression/passthrough/Decompressor.hpp (1)

Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: centos-stream-9-static-linked-bins
  • GitHub Check: ubuntu-jammy-static-linked-bins
  • GitHub Check: ubuntu-focal-static-linked-bins
  • GitHub Check: centos-stream-9-dynamic-linked-bins
  • GitHub Check: ubuntu-focal-dynamic-linked-bins
  • GitHub Check: ubuntu-jammy-dynamic-linked-bins
  • GitHub Check: build-macos (macos-13, false)
  • GitHub Check: build-macos (macos-13, true)
🔇 Additional comments (13)
components/core/src/clp/WriterInterface.hpp (1)

24-25: LGTM! Virtual destructor addition enhances class hierarchy safety.

The addition of a virtual destructor is essential for proper cleanup when derived classes are deleted through base class pointers.

components/core/src/clp/streaming_compression/Compressor.hpp (1)

35-35: LGTM! Explicit override improves clarity.

The explicit override keyword on the destructor clearly indicates the inheritance relationship with WriterInterface.

components/core/src/clp/streaming_compression/Decompressor.hpp (4)

21-24: LGTM! Enhanced method signature with [[nodiscard]] and trailing return type.

The addition of [[nodiscard]] ensures the error message isn't accidentally ignored, and the trailing return type improves readability.


30-30: LGTM! Explicit override improves clarity.

The explicit override keyword on the destructor clearly indicates the inheritance relationship.


32-38: LGTM! Well-defined special member functions.

Explicitly declaring copy/move operations improves class design clarity:

  • Copy operations properly deleted
  • Move operations defaulted with noexcept

46-65: LGTM! Modernized method signatures.

Methods updated with:

  • Trailing return types for improved readability
  • [[nodiscard]] attribute where appropriate
  • Consistent formatting
components/core/src/clp/streaming_compression/passthrough/Decompressor.hpp (4)

22-25: LGTM! Enhanced method signature with [[nodiscard]] and trailing return type.

Consistent with parent class changes, improving error handling safety.


36-36: LGTM! Explicit override improves clarity.

Consistent with parent class destructor declaration.


38-44: LGTM! Well-defined special member functions.

Special member functions follow modern C++ best practices and maintain consistency with parent class.


Line range hint 57-92: LGTM! Modernized method signatures.

All interface method implementations consistently updated with:

  • Trailing return types
  • [[nodiscard]] attribute where appropriate
  • Clear parameter documentation
components/core/src/clp/streaming_compression/zstd/Decompressor.hpp (3)

27-29: LGTM! Good use of modern C++ features.

The updated signature properly uses [[nodiscard]] to prevent accidental ignoring of error messages and adopts the trailing return type syntax.


63-64: LGTM! Proper use of [[nodiscard]] for error handling methods.

The reader interface methods correctly use [[nodiscard]] to ensure error codes are not accidentally ignored.

Also applies to: 72-72, 79-79


94-98: LGTM! Consistent use of modern C++ features.

The method signatures properly use:

  • [[nodiscard]] for methods returning error codes
  • Trailing return type syntax
  • override specifier where applicable

Also applies to: 109-109

@Bill-hbrhbr Bill-hbrhbr requested a review from davidlion January 30, 2025 03:35
@Bill-hbrhbr Bill-hbrhbr changed the title refactor(core-clp): Modernize function signatures in the streaming decompressor interface and its implementations to comply with Clang-Tidy checks. refactor(core): Modernize function signatures in the streaming decompressor interface and its implementations to comply with Clang-Tidy checks. Feb 2, 2025
Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

lgtm. For the PR title, how about:

refactor(core): Modernize function signatures in the streaming decompressor interface and its implementations to align with the latest C++ coding guidelines.

@LinZhihao-723
Copy link
Member

Also I've noticed that there are still many unresolved clang-tidy warnings in the current source files. We shouldn't lose track of these issues; are you planning to fix them in the coming PRs soon?

@Bill-hbrhbr
Copy link
Contributor Author

Also I've noticed that there are still many unresolved clang-tidy warnings in the current source files. We shouldn't lose track of these issues; are you planning to fix them in the coming PRs soon?

Yes this is the first PR of a series that is to come

@Bill-hbrhbr Bill-hbrhbr changed the title refactor(core): Modernize function signatures in the streaming decompressor interface and its implementations to comply with Clang-Tidy checks. refactor(core): Modernize function signatures in the streaming decompressor interface and its implementations to align with the latest C++ coding guidelines. Feb 3, 2025
@Bill-hbrhbr Bill-hbrhbr merged commit 121b717 into y-scope:main Feb 3, 2025
29 of 31 checks passed
@Bill-hbrhbr Bill-hbrhbr deleted the decompressor-fix-signatures branch February 3, 2025 04:41
@LinZhihao-723
Copy link
Member

Also I've noticed that there are still many unresolved clang-tidy warnings in the current source files. We shouldn't lose track of these issues; are you planning to fix them in the coming PRs soon?

Yes this is the first PR of a series that is to come

Can we create a GitHub issue to keep track of this PR series?

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