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

NEW (Extension) @W-16442046@ Apex guru fixer logic - to show and insert apex guru suggestions #116

Merged
merged 9 commits into from
Aug 19, 2024

Conversation

jag-j
Copy link
Collaborator

@jag-j jag-j commented Aug 14, 2024

No description provided.

@jag-j jag-j requested review from stephen-carter-at-sf and jfeingold35 and removed request for stephen-carter-at-sf August 15, 2024 15:17
Comment on lines 141 to 142
currentCode: Buffer.from(encodedCodeBefore, 'base64').toString('utf8'),
suggestedCode: Buffer.from(encodedCodeAfter, 'base64').toString('utf8'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

If currentCode and suggestedCode is equal to `` (i.e. empty)… does it show this in the popup box still?
I ask because I would have assumed that to trigger whether it shows up or not would be based on undefined or null instead. Because maybe the after code is indeed empty and we want to show that instead of hide it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As explained in slack, this doesn't show up.

Copy link
Collaborator

@stephen-carter-at-sf stephen-carter-at-sf Aug 16, 2024

Choose a reason for hiding this comment

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

Maybe not today. But it could in the future.

Instead of

(prop: ApexGuruProperty) => prop.name === 'code_after')?.value ?? ''

Why not just send in the value always even if it is undefined.

Then your line

if (apexGuruViolation.suggestedCode) {

code could just switch to

if (apexGuruViolation.suggestedCode !== undefined) {

or maybe just

if (typeof apexGuruViolation.suggestedCode  === 'string') {

so that it allows for empty strings.

if (engine === 'apexguru') {
const apexGuruViolation = violation as ApexGuruViolation;

if (apexGuruViolation.suggestedCode?.trim()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the suggestedCode is empty... maybe that is because we are suggesting to replace it. Can we instead just explicitly check if the suggestedCode is undefined as a way of determining this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah! this is a super-edge case. But valid point. Let me take care of this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

@jag-j jag-j merged commit 6ac34f3 into dev Aug 19, 2024
7 checks passed
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.

2 participants