-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Support expandable in initial form data #21153
Conversation
WalkthroughWalkthroughThe recent update enhances the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant FormComponent
participant computeInitialHaFormData
User ->> FormComponent: Load form
FormComponent ->> computeInitialHaFormData: Call with schema
computeInitialHaFormData -->> computeInitialHaFormData: Process schema
alt contains expandable field
computeInitialHaFormData -->> computeInitialHaFormData: Recursively process expandable field
end
computeInitialHaFormData -->> FormComponent: Return initial data
FormComponent -->> User: Render form with initial data
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Additional context usedBiome
Additional comments not posted (2)
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
@@ -2,7 +2,7 @@ import type { Selector } from "../../data/selector"; | |||
import type { HaFormSchema } from "./types"; | |||
|
|||
export const computeInitialHaFormData = ( | |||
schema: HaFormSchema[] | |||
schema: HaFormSchema[] | readonly HaFormSchema[] | |||
): Record<string, any> => { | |||
const data = {}; | |||
schema.forEach((field) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reduce cognitive complexity.
The function computeInitialHaFormData
has a cognitive complexity score of 120, which is significantly higher than the maximum allowed score of 15. This high complexity can make the function hard to understand and maintain. Consider refactoring the function to simplify its logic, possibly by breaking it down into smaller helper functions or by simplifying conditional branches.
Tools
Biome
[error] 8-8: Excessive complexity detected. (lint/complexity/noExcessiveCognitiveComplexity)
Please refactor this function to reduce its complexity score from 120 to the max allowed complexity 15.
@@ -2,7 +2,7 @@ | |||
import type { HaFormSchema } from "./types"; | |||
|
|||
export const computeInitialHaFormData = ( | |||
schema: HaFormSchema[] | |||
schema: HaFormSchema[] | readonly HaFormSchema[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify a more precise type than any
.
The use of any
in the function's return type can disable type checking, which is not ideal in TypeScript. Consider specifying a more detailed type for better type safety and easier maintenance.
- ): Record<string, any> => {
+ ): Record<string, unknown> => {
Committable suggestion was skipped due to low confidence.
Proposed change
Needed for: home-assistant/core#118369
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed:
Summary by CodeRabbit