FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: enforce type-safe value in setCellStyles by redfish4ktc · Pull Request #1028 · maxGraph/maxGraph · GitHub

forked from jgraph/mxgraph

fix: enforce type-safe value in setCellStyles - #1028

Draft
redfish4ktc wants to merge 3 commits into
mainfrom
refactor/improve_signature_types_setCellStyles
Draft

fix: enforce type-safe value in setCellStyles#1028
redfish4ktc wants to merge 3 commits into
mainfrom
refactor/improve_signature_types_setCellStyles

Conversation

redfish4ktc commented Mar 24, 2026
edited
Loading

Copy link
Copy Markdown
Member

This is a WIP

description for enforce type-safe value in setCellStyles
Previously, any value type could be passed for any style key without compile-time error, allowing bugs like passing a string for a boolean property.
Using a generic constraint ensures the value type matches the key's declared type in CellStateStyle, catching mismatches at compile
time.

Tasks

Increase the scope of this PR:

Other tasks

  • improve the PR description. Not really a breaking change as wrong values leads to bug

This is a breaking change for any consumer calling setCellStyles with a value that does not match the type of the specified key. These calls were already semantically incorrect — the stricter type now surfaces the error at compile time.

Notes

Covers #840
Should be merged after #1026

Previously, any value type could be passed for any style key without
compile-time error, allowing bugs like passing a string for a boolean
property. Using a generic constraint ensures the value type matches the
key's declared type in CellStateStyle, catching mismatches at compile
time.
redfish4ktc added the bug Something isn't working label Mar 24, 2026

coderabbitai Bot commented Mar 24, 2026
edited
Loading

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d7675152-6b7f-417b-ab4b-76b5afbe6dbd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Quality Gate failed

Failed conditions
17.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@@ -241,14 +241,14 @@ class GraphLayout {
* Disables or enables the edge style of the given edge.
*/
setEdgeStyleEnabled(edge: Cell, value: any): void {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

suggestion: the type of the value parameter should be a boolean.Do we allow undefined?

*/
setOrthogonalEdge(edge: Cell, value: any): void {
this.graph.setCellStyles('orthogonal', value ? '1' : '0', [edge]);
this.graph.setCellStyles('orthogonal', !!value, [edge]);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

suggestion: the type of the value parameter should be a boolean. Do we allow undefined?

Comment on lines +204 to 209
this.setCellStyles(source ? 'exitPerimeter' : 'entryPerimeter', false, [
edge,
]);
} else {
this.setCellStyles(source ? 'exitPerimeter' : 'entryPerimeter', null, [edge]);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

suggestion: there is a duplication here, the value is not the same depending on the result of the if condition, but the rest of the implementation is the same.

@@ -201,7 +201,9 @@ export const ConnectionsMixin: PartialType = {

// Only writes 0 since 1 is default

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

nitpick: adapt this comment (use boolean instead of number)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL