Skip to content

Commit 0c0246b

Browse files
authored
Merge pull request #44 from DeepCodeAI/fixed_report_and_update_positions
Fixed reporting and update positions
2 parents 7e9385c + 9ef11b3 commit 0c0246b

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/deepcode/lib/analyzer/DeepCodeAnalyzer.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,14 @@ class DeepCodeAnalyzer implements DeepCode.AnalyzerInterface {
207207
this.analysisResultsCollection,
208208
updatedFile
209209
);
210-
this.analysisResultsCollection[updatedFile.workspace].files[
211-
updatedFile.filePathInWorkspace
212-
] = { ...fileIssuesList };
210+
// Opening a project directory instead of a workspace leads to empty updatedFile.workspace field
211+
const workspace = updatedFile.workspace || Object.keys(this.analysisResultsCollection)[0];
212+
const filepath = updatedFile.filePathInWorkspace || updatedFile.fullPath.replace(workspace, "");
213+
this.analysisResultsCollection[workspace].files[filepath] = { ...fileIssuesList };
213214
if (this.deepcodeReview) {
214215
const issues = this.createIssuesList({
215216
fileIssuesList,
216-
suggestions: this.analysisResultsCollection[updatedFile.workspace].suggestions,
217+
suggestions: this.analysisResultsCollection[workspace].suggestions,
217218
fileUri: vscode.Uri.file(updatedFile.fullPath)
218219
});
219220
this.deepcodeReview.set(vscode.Uri.file(updatedFile.fullPath), [
@@ -224,7 +225,7 @@ class DeepCodeAnalyzer implements DeepCode.AnalyzerInterface {
224225
} catch (err) {
225226
extension.errorHandler.processError(extension, err, {
226227
message: errorsLogs.updateReviewPositions,
227-
bundleId: extension.remoteBundles[updatedFile.workspace].bundleId,
228+
bundleId: (extension.remoteBundles[updatedFile.workspace] || {}).bundleId,
228229
data: {
229230
[updatedFile.filePathInWorkspace]: updatedFile.contentChanges
230231
}

src/deepcode/lib/modules/ReportModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ReportModule extends BaseDeepCodeModule implements DeepCode.ReportModuleIn
88
// return true;
99

1010
// disabling request sending in dev mode or to self-managed instances.
11-
return process.env.NODE_ENV === "production" && this.baseURL === this.defaultBaseURL;
11+
return this.baseURL === this.defaultBaseURL;
1212
}
1313

1414
public async sendError(options: {[key: string]: any}): Promise<void> {

src/deepcode/utils/analysisUtils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ export const updateFileReviewResultsPositions = (
9494
const offsetedline = changesRange.start.line + 1;
9595
const charOffset = 1;
9696

97+
// Opening a project directory instead of a workspace leads to empty updatedFile.workspace field
98+
const workspace = updatedFile.workspace || Object.keys(analysisResultsCollection)[0];
99+
const filepath = updatedFile.filePathInWorkspace || updatedFile.fullPath.replace(workspace, "");
97100
const fileIssuesList = {
98-
...analysisResultsCollection[updatedFile.workspace].files[
99-
updatedFile.filePathInWorkspace
100-
]
101+
...analysisResultsCollection[workspace].files[filepath]
101102
};
102-
103103
for (const issue in fileIssuesList) {
104104
for (const [index, position] of fileIssuesList[issue].entries()) {
105105
const currentLineIsOnEdgeOfIssueRange =

0 commit comments

Comments
 (0)