Skip to content

Commit 89b9c4d

Browse files
authored
fix(amazonq): Fixed a bug where issues are double counted in the Q chat (aws#6767)
1 parent 8be95a9 commit 89b9c4d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Code Review: Fixed a bug where issues are double counted in the Q chat"
4+
}

packages/core/src/codewhisperer/service/securityScanHandler.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,13 @@ export async function listScanResults(
7474
for (const [key, issues] of codeScanIssueMap.entries()) {
7575
// Project path example: /Users/username/project
7676
// Key example: project/src/main/java/com/example/App.java
77+
const mappedProjectPaths: Set<string> = new Set()
7778
for (const projectPath of projectPaths) {
7879
// We need to remove the project path from the key to get the absolute path to the file
7980
// Do not use .. in between because there could be multiple project paths in the same parent dir.
8081
const filePath = path.join(projectPath, key.split('/').slice(1).join('/'))
8182
if (existsSync(filePath) && statSync(filePath).isFile()) {
83+
mappedProjectPaths.add(filePath)
8284
const document = await vscode.workspace.openTextDocument(filePath)
8385
const aggregatedCodeScanIssue: AggregatedCodeScanIssue = {
8486
filePath: filePath,
@@ -88,7 +90,11 @@ export async function listScanResults(
8890
}
8991
}
9092
const maybeAbsolutePath = `/${key}`
91-
if (existsSync(maybeAbsolutePath) && statSync(maybeAbsolutePath).isFile()) {
93+
if (
94+
!mappedProjectPaths.has(maybeAbsolutePath) &&
95+
existsSync(maybeAbsolutePath) &&
96+
statSync(maybeAbsolutePath).isFile()
97+
) {
9298
const document = await vscode.workspace.openTextDocument(maybeAbsolutePath)
9399
const aggregatedCodeScanIssue: AggregatedCodeScanIssue = {
94100
filePath: maybeAbsolutePath,

0 commit comments

Comments
 (0)