Skip to content

Commit 34d0cf2

Browse files
committed
Refactor CxSecrets parsing logic to handle resultObject directly for improved clarity
1 parent f4cba64 commit 34d0cf2

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/main/secrets/CxSecrets.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ export default class CxSecretsResult {
66
locations: { line: number, startIndex: number, endIndex: number }[];
77

88
static parseResult(resultObject: any): CxSecretsResult[] {
9-
const results = resultObject.Packages;
109
let secretsResults: CxSecretsResult[] = [];
11-
if (results instanceof Array) {
12-
secretsResults = results.map((member: any) => {
10+
if (resultObject instanceof Array) {
11+
secretsResults = resultObject.map((member: any) => {
1312
const secretsResult = new CxSecretsResult();
1413
secretsResult.title = member.Title;
1514
secretsResult.description = member.Description;
@@ -26,13 +25,13 @@ export default class CxSecretsResult {
2625
});
2726
} else {
2827
const secretsResult = new CxSecretsResult();
29-
secretsResult.title = results.Title;
30-
secretsResult.description = results.Description;
31-
secretsResult.severity = results.Severity;
32-
secretsResult.filepath = results.FilePath;
33-
secretsResult.filepath = results.FilePath;
34-
secretsResult.locations = Array.isArray(results.Locations)
35-
? results.Locations.map((l: any) => ({
28+
secretsResult.title = resultObject.Title;
29+
secretsResult.description = resultObject.Description;
30+
secretsResult.severity = resultObject.Severity;
31+
secretsResult.filepath = resultObject.FilePath;
32+
secretsResult.filepath = resultObject.FilePath;
33+
secretsResult.locations = Array.isArray(resultObject.Locations)
34+
? resultObject.Locations.map((l: any) => ({
3635
line: l.Line,
3736
startIndex: l.StartIndex,
3837
endIndex: l.EndIndex,

0 commit comments

Comments
 (0)