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

Migrate readme to v3 #1188

Merged
merged 6 commits into from
Mar 2, 2025
Merged

Migrate readme to v3 #1188

merged 6 commits into from
Mar 2, 2025

Conversation

snapsl
Copy link
Contributor

@snapsl snapsl commented Mar 1, 2025

I tried to change as little as possible.
Overall, I think a little restructuring of the readme file could be beneficial to make it more readable.

closes #1186

Summary by CodeRabbit

Summary by CodeRabbit

  • Documentation

    • Updated documentation examples to reflect design best practices by transitioning from directly instantiable classes to abstract ones.
    • Added "(NEW)" to the "Classic classes" section to highlight new content.
  • Refactor

    • Adjusted sample code for improved clarity, ensuring that foundational components serve as blueprints rather than objects that can be instantiated directly.
    • Enhanced class declarations to include const keywords for factory constructors, promoting immutability.
    • Introduced a fromJson factory method in the MyResponse class for improved JSON deserialization.
    • Reformatted factory method definitions for brevity.

Copy link

coderabbitai bot commented Mar 1, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes involve modifications to the README.md file related to the Freezed package, focusing on class declarations and factory constructors. The Person class has been updated to include the @freezed annotation, and the const keyword has been added to several factory constructors. Additionally, a new fromJson factory method is introduced for the MyResponse class, along with minor formatting adjustments for brevity.

Changes

File Change Summary
packages/.../README.md Updated class declarations for Person, Example, MyFreezedClass, Company, Director, and Assistant to include the const keyword in their factory constructors; modified Person class to include named parameters in the private constructor; added fromJson factory method to MyResponse; minor formatting changes for brevity.

Poem

I hopped through the lines of code with glee,
Transforming classes abstractly, you see.
Concrete forms now fade away,
Abstract dreams lead the way.
With a twitch of my nose and a joyful leap,
CodeRabbit smiles as we take a giant leap!
🐰✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7521a31 and 6cb8a91.

📒 Files selected for processing (1)
  • packages/freezed/README.md (11 hunks)

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

@snapsl snapsl marked this pull request as draft March 1, 2025 11:43
@snapsl snapsl changed the title Migrate readme to v3 #1186 Migrate readme to v3 Mar 1, 2025
@snapsl snapsl marked this pull request as ready for review March 1, 2025 16:36
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 (1)
packages/freezed/README.md (1)

255-264: Alternative Assertion Approach Using a Private Constructor

Providing an alternative example that uses a private constructor (i.e. Person._({required this.name}) : assert(name.isNotEmpty, 'name cannot be empty');) offers flexibility for developers who prefer embedding assertions directly in the constructor. To avoid any potential confusion, consider adding a brief comment noting that this is an alternative to the @Assert decorator approach.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f8328a3 and 7521a31.

📒 Files selected for processing (1)
  • packages/freezed/README.md (13 hunks)
🔇 Additional comments (5)
packages/freezed/README.md (5)

47-47: Index Update: Highlighting "Classic classes (NEW)"

The addition of "(NEW)" in the Classic classes index clearly signals updated content to the reader. Ensure that any accompanying explanation in the section reinforces why these classes are highlighted as new.


245-249: Enhanced Validation with @Assert

Adding the @Assert('name.isNotEmpty', 'name cannot be empty') decorator in the Person factory constructor improves input validation and prevents empty names. This change adheres to good defensive programming practices.


784-786: JSON Deserialization for MyResponse

The newly added fromJson factory method for MyResponse:

factory MyResponse.fromJson(Map<String, dynamic> json) =>
    _$MyResponseFromJson(json);

facilitates built-in JSON deserialization. Its concise arrow syntax improves clarity and aligns with best practices.


1187-1191: Updated Example for Specific Model Behavior

The example using @Freezed() to create an abstract Person class clearly demonstrates how to declare a model in line with the new v3 guidelines. This example is succinct and serves as a good reference.


1196-1201: Customizing Generated Code with @freezed Parameters

The updated snippet:

@Freezed(
  // Disable the generation of copyWith/==
  copyWith: false,
  equal: false,
)
abstract class Person with _$Person { ... }

effectively shows how to alter the generated behavior for a model. Please verify that disabling copyWith and equality overrides aligns with your project requirements, as these settings affect immutability and object comparisons.

@lishaduck
Copy link
Contributor

@snapsl, I've got some other changes in #1183. Would you like me to PR your fork so there's just one PR for @rrousselGit to review (because there's some conflicts right now, so it'll be slower to merge them in serial)?

@snapsl
Copy link
Contributor Author

snapsl commented Mar 1, 2025

@lishaduck Thank you for the notice.
I don't think this is necessary. The changes in the readme can be edited on the fly.

@@ -44,7 +44,7 @@ to focus on the definition of your model.
- [Extending classes](#extending-classes)
- [Defining a mutable class instead of an immutable one](#defining-a-mutable-class-instead-of-an-immutable-one)
- [Allowing the mutation of Lists/Maps/Sets](#allowing-the-mutation-of-listsmapssets)
- [Classic classes](#classic-classes)
- [Classic classes (NEW)](#classic-classes-new)
Copy link
Owner

Choose a reason for hiding this comment

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

I don't like that (new) stuff.

If folks want to know what's new, there's the changelog

@rrousselGit
Copy link
Owner

LGTM!

@rrousselGit rrousselGit merged commit e683659 into rrousselGit:master Mar 2, 2025
3 checks passed
@snapsl snapsl deleted the fix_readme branch March 3, 2025 07: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.

Migrate readme to v3
3 participants