Skip to content

Commit 774ee71

Browse files
committed
Fixed reporting and updateReviewResultsPositions for non-workspace analysis.
1 parent 7e9385c commit 774ee71

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/deepcode/lib/analyzer/DeepCodeAnalyzer.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,15 @@ class DeepCodeAnalyzer implements DeepCode.AnalyzerInterface {
207207
this.analysisResultsCollection,
208208
updatedFile
209209
);
210-
this.analysisResultsCollection[updatedFile.workspace].files[
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+
this.analysisResultsCollection[workspace].files[
211213
updatedFile.filePathInWorkspace
212214
] = { ...fileIssuesList };
213215
if (this.deepcodeReview) {
214216
const issues = this.createIssuesList({
215217
fileIssuesList,
216-
suggestions: this.analysisResultsCollection[updatedFile.workspace].suggestions,
218+
suggestions: this.analysisResultsCollection[workspace].suggestions,
217219
fileUri: vscode.Uri.file(updatedFile.fullPath)
218220
});
219221
this.deepcodeReview.set(vscode.Uri.file(updatedFile.fullPath), [
@@ -224,7 +226,7 @@ class DeepCodeAnalyzer implements DeepCode.AnalyzerInterface {
224226
} catch (err) {
225227
extension.errorHandler.processError(extension, err, {
226228
message: errorsLogs.updateReviewPositions,
227-
bundleId: extension.remoteBundles[updatedFile.workspace].bundleId,
229+
bundleId: (extension.remoteBundles[updatedFile.workspace] || {}).bundleId,
228230
data: {
229231
[updatedFile.filePathInWorkspace]: updatedFile.contentChanges
230232
}

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)