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

style: Improve code style by putting private after public #17

Merged
merged 2 commits into from
Nov 1, 2024

Conversation

sitaowang1998
Copy link
Collaborator

@sitaowang1998 sitaowang1998 commented Nov 1, 2024

Description

Improve code style by putting private after public in class definition.

Validation performed

  • task:lint

Summary by CodeRabbit

  • Refactor
    • Reorganized member variable declarations in the Data, TaskInput, TaskOutput, and TaskGraph classes for improved structure.
    • Changed visibility of certain member variables in the TaskInput and Task classes from private to public.
    • Adjusted the order of member variables in the TaskOutput and TaskGraph classes without altering functionality.

Copy link
Contributor

coderabbitai bot commented Nov 1, 2024

Walkthrough

The pull request includes modifications to the Data, TaskInput, TaskOutput, and TaskGraph classes across three header files. The changes primarily involve reorganizing member variable declarations, specifically moving private member variables to the end of their respective class definitions while retaining their access control. The public methods and constructors remain unchanged, ensuring no alterations to functionality.

Changes

File Change Summary
src/spider/core/Data.hpp Reorganized member variables: m_id, m_key, m_value, and init_id() moved to the end.
src/spider/core/Task.hpp TaskInput: Changed visibility of m_task_output, m_value, m_data_id to public.
TaskOutput: Reordered member variables, moving m_value, m_data_id, and m_type to the end.
src/spider/core/TaskGraph.hpp Moved private member variables m_tasks and m_dependencies to the end of the class definition.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Data
    participant TaskInput
    participant TaskOutput
    participant TaskGraph

    User->>Data: Access member variables
    Data->>User: Return values

    User->>TaskInput: Access member variables
    TaskInput->>User: Return values

    User->>TaskOutput: Access member variables
    TaskOutput->>User: Return values

    User->>TaskGraph: Access tasks and dependencies
    TaskGraph->>User: Return tasks and dependencies
Loading

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

🧹 Outside diff range and nitpick comments (1)
src/spider/core/Task.hpp (1)

41-45: Add explicit private section marker and fix indentation

The private member variables should be properly grouped under an explicit private: section marker to improve readability and maintain consistency with the class structure pattern used elsewhere in the codebase.

Apply this diff to improve the structure:

-    std::optional<std::tuple<boost::uuids::uuid, std::uint8_t>> m_task_output;
-    std::optional<std::string> m_value;
-    std::optional<boost::uuids::uuid> m_data_id;
-    std::string m_type;
+private:
+    std::optional<std::tuple<boost::uuids::uuid, std::uint8_t>> m_task_output;
+    std::optional<std::string> m_value;
+    std::optional<boost::uuids::uuid> m_data_id;
+    std::string m_type;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9b858c9 and 47dd27c.

📒 Files selected for processing (3)
  • src/spider/core/Data.hpp (2 hunks)
  • src/spider/core/Task.hpp (2 hunks)
  • src/spider/core/TaskGraph.hpp (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • src/spider/core/Data.hpp
  • src/spider/core/TaskGraph.hpp
🔇 Additional comments (2)
src/spider/core/Task.hpp (2)

64-68: LGTM! Well-structured member organization

The private member variables are properly organized with correct access control marker and consistent indentation. The empty line before the private section provides good visual separation.


41-45: Consider standardizing member organization across all classes

While TaskOutput follows the new style perfectly, there's inconsistency in how private members are organized across different classes in this file. Consider:

  1. Applying the same style (with explicit private marker and spacing) to TaskInput
  2. Updating the Task class to follow the same pattern for consistency

Let's check if this style is being consistently applied across the codebase:

Also applies to: 64-68

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

🧹 Outside diff range and nitpick comments (1)
src/spider/core/Task.hpp (1)

120-129: LGTM! Private members well-organized with proper separation.

The private section follows good C++ practices:

  • Clear separation from public interface with an empty line
  • Logical grouping of related members (identifiers, state, configuration, collections)

Consider adding comments to group related private members for better maintainability, especially since this class has more members than the others:

 private:
+    // Identification
     boost::uuids::uuid m_id;
     std::string m_function_name;
+    // State and metadata
     TaskState m_state = TaskState::Pending;
     TaskCreatorType m_creator_type;
     boost::uuids::uuid m_creator_id;
     float m_timeout = 0;
+    // Task graph connections
     std::vector<TaskInput> m_inputs;
     std::vector<TaskOutput> m_outputs;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 47dd27c and d473cb9.

📒 Files selected for processing (1)
  • src/spider/core/Task.hpp (3 hunks)
🔇 Additional comments (2)
src/spider/core/Task.hpp (2)

41-45: LGTM! Private members properly placed after public interface.

The placement of private members after the public interface follows the Google C++ Style Guide recommendations, improving readability by presenting the public API first.


64-68: LGTM! Well-structured private section with proper separation.

The private section is properly separated from the public interface with an empty line, and the member variables are logically grouped together.

@sitaowang1998 sitaowang1998 merged commit 00e4f4c into y-scope:main Nov 1, 2024
4 checks passed
@sitaowang1998 sitaowang1998 deleted the style branch November 1, 2024 05:04
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