-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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: Change SequenceDB to class based architecture. #6272
base: develop
Are you sure you want to change the base?
Refactor: Change SequenceDB to class based architecture. #6272
Conversation
…to messages during parsing.
…saurabh/refactor/convert-sequenceDb-to-class
🦋 Changeset detectedLatest commit: 451c886 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
commit: |
// JSON.parse the text | ||
try { | ||
let sanitizedText = sanitizeText(text.text, getConfig()); | ||
sanitizedText = sanitizedText.replace(/&/g, '&'); |
Check failure
Code scanning / CodeQL
Double escaping or unescaping High
here
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 9 hours ago
To fix the problem, we should remove the unnecessary replacements of &
and =
after the sanitizeText
function call. This ensures that the text remains properly sanitized and prevents any double unescaping issues.
-
Copy modified line R399 -
Copy modified line R413
@@ -398,5 +398,3 @@ | ||
try { | ||
let sanitizedText = sanitizeText(text.text, getConfig()); | ||
sanitizedText = sanitizedText.replace(/&/g, '&'); | ||
sanitizedText = sanitizedText.replace(/=/g, '='); | ||
const sanitizedText = sanitizeText(text.text, getConfig()); | ||
const links = JSON.parse(sanitizedText); | ||
@@ -414,6 +412,4 @@ | ||
const links: Record<string, string> = {}; | ||
let sanitizedText = sanitizeText(text.text, getConfig()); | ||
const sanitizedText = sanitizeText(text.text, getConfig()); | ||
const sep = sanitizedText.indexOf('@'); | ||
sanitizedText = sanitizedText.replace(/&/g, '&'); | ||
sanitizedText = sanitizedText.replace(/=/g, '='); | ||
const label = sanitizedText.slice(0, sep - 1).trim(); |
const links: Record<string, string> = {}; | ||
let sanitizedText = sanitizeText(text.text, getConfig()); | ||
const sep = sanitizedText.indexOf('@'); | ||
sanitizedText = sanitizedText.replace(/&/g, '&'); |
Check failure
Code scanning / CodeQL
Double escaping or unescaping High
here
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 9 hours ago
To fix the problem, we need to ensure that unescaping operations are not performed redundantly. The best way to achieve this is to avoid manual unescaping and rely on a well-tested library for sanitization and unescaping. This will help prevent double unescaping and ensure that the data is processed correctly.
We will remove the manual unescaping operations and rely on the sanitizeText
function to handle any necessary unescaping. If sanitizeText
does not perform unescaping, we should update it to do so.
-
Copy modified line R399 -
Copy modified line R413
@@ -398,5 +398,3 @@ | ||
try { | ||
let sanitizedText = sanitizeText(text.text, getConfig()); | ||
sanitizedText = sanitizedText.replace(/&/g, '&'); | ||
sanitizedText = sanitizedText.replace(/=/g, '='); | ||
const sanitizedText = sanitizeText(text.text, getConfig()); | ||
const links = JSON.parse(sanitizedText); | ||
@@ -414,6 +412,4 @@ | ||
const links: Record<string, string> = {}; | ||
let sanitizedText = sanitizeText(text.text, getConfig()); | ||
const sanitizedText = sanitizeText(text.text, getConfig()); | ||
const sep = sanitizedText.indexOf('@'); | ||
sanitizedText = sanitizedText.replace(/&/g, '&'); | ||
sanitizedText = sanitizedText.replace(/=/g, '='); | ||
const label = sanitizedText.slice(0, sep - 1).trim(); |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6272 +/- ##
=======================================
Coverage 4.47% 4.47%
=======================================
Files 385 384 -1
Lines 54191 54179 -12
Branches 598 623 +25
=======================================
Hits 2425 2425
+ Misses 51766 51754 -12
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
The this.setWrap(getConfig().wrap);
in the constructor seems to be the only thing I'm a bit nervous about, the rest of the PR seems good to me (as long as the visual regression tests come back green ✔️)
const diagram1 = await Diagram.fromText(str); | ||
|
||
await diagram1.renderer.draw(str, 'tst', '1.2.3', diagram1); // needs to be rendered for the correct value of visibility auto numbers | ||
expect(diagram1.db.showSequenceNumbers()).toBe(true); |
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.
suggestion(super non-blocking): I wonder if it's easier to just delete the let diagram
at
// const parser = sequence.parser; | |
let diagram; |
Because then the test would be:
const diagram = await Diagram.fromText(str);
await diagram.renderer.draw(str, 'tst', '1.2.3', diagram); // needs to be rendered for the correct value of visibility auto numbers
expect(diagram.db.showSequenceNumbers()).toBe(true);
So you'll be changing much less lines of code in this PR.
@@ -1917,10 +1847,11 @@ Note left of Alice: Bob thinks | |||
Bob->>Alice: Fine!`; | |||
|
|||
await mermaidAPI.parse(str); |
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.
todo: There's a couple of mermaidAPI.parse
calls you can delete from these unit tests, since they don't do anything.
await mermaidAPI.parse(str); |
@aloisklink i think we can refactor it into separate PR |
📑 Summary
diagramObject.db
is called.Resolves #
📏 Design Decisions
📋 Tasks
Make sure you
MERMAID_RELEASE_VERSION
is used for all new features.pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.