Skip to content

Commit

Permalink
NEW (Extension) @W-16442046@ Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jag-j committed Aug 16, 2024
1 parent 3f1c22a commit d5bf863
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/apexguru/apex-guru-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ export function transformStringToRuleResult(fileName: string, jsonString: string
};

reports.forEach(parsed => {
const encodedCodeBefore = parsed.properties.find((prop: ApexGuruProperty) => prop.name === 'code_before')?.value ?? '';
const encodedCodeAfter = parsed.properties.find((prop: ApexGuruProperty) => prop.name === 'code_after')?.value ?? '';
const encodedCodeBefore = parsed.properties.find((prop: ApexGuruProperty) => prop.name === 'code_before')?.value;
const encodedCodeAfter = parsed.properties.find((prop: ApexGuruProperty) => prop.name === 'code_after')?.value;
const lineNumber = parseInt(parsed.properties.find((prop: ApexGuruProperty) => prop.name === 'line_number')?.value);

const violation: ApexGuruViolation = {
Expand All @@ -139,8 +139,8 @@ export function transformStringToRuleResult(fileName: string, jsonString: string
category: parsed.type, // Replace with actual category if available
line: lineNumber,
column: 1,
currentCode: Buffer.from(encodedCodeBefore, 'base64').toString('utf8'),
suggestedCode: Buffer.from(encodedCodeAfter, 'base64').toString('utf8'),
currentCode: encodedCodeBefore ? Buffer.from(encodedCodeBefore, 'base64').toString('utf8') : encodedCodeBefore,
suggestedCode: encodedCodeAfter ? Buffer.from(encodedCodeAfter, 'base64').toString('utf8') : encodedCodeAfter,
};

ruleResult.violations.push(violation);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class DiagnosticManager {
if (engine === 'apexguru') {
const apexGuruViolation = violation as ApexGuruViolation;

if (apexGuruViolation.suggestedCode) {
if (apexGuruViolation.suggestedCode !== undefined) {
diagnostic.relatedInformation = [
new vscode.DiagnosticRelatedInformation(
new vscode.Location(vscode.Uri.parse('Current Code'), range),
Expand Down
2 changes: 1 addition & 1 deletion src/test/suite/apexguru/apex-guru-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ suite('Apex Guru Test Suite', () => {
category: 'BestPractices',
line: 10,
column: 1,
currentCode: '',
currentCode: undefined,
suggestedCode: 'System.out.println("Hello World");'
}]
});
Expand Down

0 comments on commit d5bf863

Please sign in to comment.