Skip to content

Commit a6d16ec

Browse files
author
Arvid Paeglit
committed
fixed linter suggestions. no logic changes yet
1 parent bb2ef26 commit a6d16ec

24 files changed

Lines changed: 9834 additions & 565 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
out
2+
build
23
node_modules
34
.vscode-test
45
*.vsix
5-
yarn-error.log
6+
yarn-error.log

package-lock.json

Lines changed: 9354 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@
224224
"compile": "tsc -p ./",
225225
"watch": "tsc -watch -p ./",
226226
"pretest": "npm run compile",
227-
"test": "node ./out/test/runTest.js"
227+
"test": "node ./out/test/runTest.js",
228+
"lint": "npx eslint src/**/*.ts",
229+
"lint:fix": "npx eslint --fix src/**/*.ts"
228230
},
229231
"devDependencies": {
230232
"@types/glob": "^7.1.3",
@@ -237,6 +239,7 @@
237239
"mocha": "^8.1.3",
238240
"typescript": "^4.0.2",
239241
"eslint": "^7.8.1",
242+
"prettier": "^2.1.1",
240243
"@typescript-eslint/eslint-plugin": "^4.0.1",
241244
"@typescript-eslint/parser": "^4.0.1",
242245
"eslint-plugin-prettier": "^3.1.4",

src/deepcode/DeepCodeExtension.ts

Lines changed: 57 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import * as vscode from "vscode";
2-
import * as open from "open";
1+
import * as vscode from 'vscode';
2+
import open from 'open';
33

4-
import DeepCode from "../interfaces/DeepCodeInterfaces";
5-
import DeepCodeLib from "./lib/modules/DeepCodeLib";
4+
import { ExtensionInterface } from '../interfaces/DeepCodeInterfaces';
5+
import DeepCodeLib from './lib/modules/DeepCodeLib';
66

77
import {
88
DEEPCODE_START_COMMAND,
@@ -14,25 +14,15 @@ import {
1414
DEEPCODE_OPEN_BROWSER_COMMAND,
1515
DEEPCODE_OPEN_LOCAL_COMMAND,
1616
DEEPCODE_OPEN_ISSUE_COMMAND,
17-
} from "./constants/commands";
18-
import {
19-
openDeepcodeSettingsCommand,
20-
createDCIgnoreCommand,
21-
} from "./utils/vscodeCommandsUtils";
17+
} from './constants/commands';
18+
import { openDeepcodeSettingsCommand, createDCIgnoreCommand } from './utils/vscodeCommandsUtils';
2219
import { errorsLogs } from './messages/errorsServerLogMessages';
23-
import {
24-
DEEPCODE_VIEW_SUPPORT,
25-
DEEPCODE_VIEW_ANALYSIS,
26-
} from "./constants/views";
27-
import { SupportProvider } from "./view/SupportProvider";
28-
import { IssueProvider } from "./view/IssueProvider";
29-
30-
class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterface {
31-
private async executeCommand(
32-
name: string,
33-
fn: (...args: any[]) => Promise<any>,
34-
...args: any[]
35-
): Promise<any> {
20+
import { DEEPCODE_VIEW_SUPPORT, DEEPCODE_VIEW_ANALYSIS } from './constants/views';
21+
import { SupportProvider } from './view/SupportProvider';
22+
import { IssueProvider } from './view/IssueProvider';
23+
24+
class DeepCodeExtension extends DeepCodeLib implements ExtensionInterface {
25+
private async executeCommand(name: string, fn: (...args: any[]) => Promise<any>, ...args: any[]): Promise<any> {
3626
try {
3727
await fn(...args);
3828
} catch (error) {
@@ -48,81 +38,56 @@ class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterfa
4838
context.subscriptions.push(
4939
vscode.commands.registerCommand(
5040
DEEPCODE_OPEN_BROWSER_COMMAND,
51-
this.executeCommand.bind(
52-
this,
53-
DEEPCODE_OPEN_BROWSER_COMMAND,
54-
(url: string) => open(url)
55-
)
56-
)
41+
this.executeCommand.bind(this, DEEPCODE_OPEN_BROWSER_COMMAND, (url: string) => open(url)),
42+
),
5743
);
5844

5945
context.subscriptions.push(
60-
vscode.commands.registerCommand(
61-
DEEPCODE_OPEN_LOCAL_COMMAND,
62-
(path: vscode.Uri, range?: vscode.Range) => {
63-
vscode.window.showTextDocument(path, { selection: range }).then(
64-
// no need to wait for processError since then is called asynchronously as well
65-
() => {}, (err) => this.processError(err, {
46+
vscode.commands.registerCommand(DEEPCODE_OPEN_LOCAL_COMMAND, (path: vscode.Uri, range?: vscode.Range) => {
47+
vscode.window.showTextDocument(path, { selection: range }).then(
48+
// no need to wait for processError since then is called asynchronously as well
49+
() => {},
50+
err =>
51+
this.processError(err, {
6652
message: errorsLogs.command(DEEPCODE_OPEN_LOCAL_COMMAND),
67-
})
68-
);
69-
}
70-
)
53+
}),
54+
);
55+
}),
7156
);
7257

7358
context.subscriptions.push(
7459
vscode.commands.registerCommand(
7560
DEEPCODE_LOGIN_COMMAND,
76-
this.executeCommand.bind(
77-
this,
78-
DEEPCODE_LOGIN_COMMAND,
79-
this.initiateLogin.bind(this)
80-
)
81-
)
61+
this.executeCommand.bind(this, DEEPCODE_LOGIN_COMMAND, this.initiateLogin.bind(this)),
62+
),
8263
);
8364

8465
context.subscriptions.push(
8566
vscode.commands.registerCommand(
8667
DEEPCODE_APPROVE_COMMAND,
87-
this.executeCommand.bind(
88-
this,
89-
DEEPCODE_APPROVE_COMMAND,
90-
this.approveUpload.bind(this)
91-
)
92-
)
68+
this.executeCommand.bind(this, DEEPCODE_APPROVE_COMMAND, this.approveUpload.bind(this)),
69+
),
9370
);
9471

9572
context.subscriptions.push(
9673
vscode.commands.registerCommand(
9774
DEEPCODE_START_COMMAND,
98-
this.executeCommand.bind(
99-
this,
100-
DEEPCODE_START_COMMAND,
101-
this.startExtension.bind(this)
102-
)
103-
)
75+
this.executeCommand.bind(this, DEEPCODE_START_COMMAND, this.startExtension.bind(this)),
76+
),
10477
);
10578

10679
context.subscriptions.push(
10780
vscode.commands.registerCommand(
10881
DEEPCODE_SETMODE_COMMAND,
109-
this.executeCommand.bind(
110-
this,
111-
DEEPCODE_SETMODE_COMMAND,
112-
this.setMode.bind(this)
113-
)
114-
)
82+
this.executeCommand.bind(this, DEEPCODE_SETMODE_COMMAND, this.setMode.bind(this)),
83+
),
11584
);
11685

11786
context.subscriptions.push(
11887
vscode.commands.registerCommand(
11988
DEEPCODE_SETTINGS_COMMAND,
120-
this.executeCommand.bind(
121-
this,
122-
DEEPCODE_SETTINGS_COMMAND,
123-
openDeepcodeSettingsCommand
124-
)
125-
)
89+
this.executeCommand.bind(this, DEEPCODE_SETTINGS_COMMAND, openDeepcodeSettingsCommand),
90+
),
12691
);
12792

12893
context.subscriptions.push(
@@ -131,54 +96,42 @@ class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterfa
13196
this.executeCommand.bind(
13297
this,
13398
DEEPCODE_OPEN_ISSUE_COMMAND,
134-
async (
135-
issueId: string,
136-
severity: number,
137-
uri: vscode.Uri,
138-
range: vscode.Range,
139-
) => {
140-
await vscode.commands.executeCommand(
141-
DEEPCODE_OPEN_LOCAL_COMMAND, uri, range
142-
);
99+
async (issueId: string, severity: number, uri: vscode.Uri, range: vscode.Range) => {
100+
await vscode.commands.executeCommand(DEEPCODE_OPEN_LOCAL_COMMAND, uri, range);
143101
await this.trackViewSuggestion(issueId, severity);
144-
}
145-
)
146-
)
102+
},
103+
),
104+
),
147105
);
148106

149107
context.subscriptions.push(
150108
vscode.commands.registerCommand(
151109
DEEPCODE_DCIGNORE_COMMAND,
152-
this.executeCommand.bind(
153-
this,
154-
DEEPCODE_DCIGNORE_COMMAND,
155-
createDCIgnoreCommand
156-
)
157-
)
110+
this.executeCommand.bind(this, DEEPCODE_DCIGNORE_COMMAND, createDCIgnoreCommand),
111+
),
158112
);
159113

160-
vscode.window.registerTreeDataProvider(
161-
DEEPCODE_VIEW_SUPPORT,
162-
new SupportProvider(this)
163-
);
114+
vscode.window.registerTreeDataProvider(DEEPCODE_VIEW_SUPPORT, new SupportProvider(this));
164115

165-
vscode.window.registerTreeDataProvider(
166-
DEEPCODE_VIEW_ANALYSIS,
167-
new IssueProvider(this)
168-
);
116+
vscode.window.registerTreeDataProvider(DEEPCODE_VIEW_ANALYSIS, new IssueProvider(this));
169117

170118
this.activateAll();
171-
this.startExtension().catch((err) => this.processError(err, {
172-
message: errorsLogs.failedExecution,
173-
}));
174-
this.checkWelcomeNotification().catch((err) => this.processError(err, {
175-
message: errorsLogs.welcomeNotification,
176-
}));
177-
this.checkAdvancedMode().catch((err) => this.processError(err, {
178-
message: errorsLogs.checkAdvancedMode,
179-
}));
119+
this.startExtension().catch(err =>
120+
this.processError(err, {
121+
message: errorsLogs.failedExecution,
122+
}),
123+
);
124+
this.checkWelcomeNotification().catch(err =>
125+
this.processError(err, {
126+
message: errorsLogs.welcomeNotification,
127+
}),
128+
);
129+
this.checkAdvancedMode().catch(err =>
130+
this.processError(err, {
131+
message: errorsLogs.checkAdvancedMode,
132+
}),
133+
);
180134
}
181-
182135
}
183136

184137
export default DeepCodeExtension;

src/deepcode/lib/analyzer/DeepCodeAnalyzer.ts

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import * as vscode from "vscode";
2-
import DeepCode from "../../../interfaces/DeepCodeInterfaces";
2+
import {
3+
AnalyzerInterface,
4+
ExtensionInterface,
5+
AnalysisResultsCollectionInterface,
6+
AnalysisResultsInterface,
7+
IssuePositionsInterface,
8+
AnalysisSuggestionsInterface,
9+
AnalysisResultsFileResultsInterface,
10+
IssuesListOptionsInterface,
11+
openedTextEditorType,
12+
} from "../../../interfaces/DeepCodeInterfaces";
313
import {
414
updateFileReviewResultsPositions,
515
createIssueCorrectRange,
@@ -17,35 +27,34 @@ import { errorsLogs } from "../../messages/errorsServerLogMessages";
1727
import { DisposableCodeActionsProvider } from "../deepCodeProviders/codeActionsProvider/DeepCodeIssuesActionsProvider";
1828
import { DisposableHoverProvider } from "../deepCodeProviders/hoverProvider/DeepCodeHoverProvider";
1929

20-
class DeepCodeAnalyzer implements DeepCode.AnalyzerInterface {
30+
class DeepCodeAnalyzer implements AnalyzerInterface {
2131
private SEVERITIES: {
2232
[key: number]: { name: vscode.DiagnosticSeverity; show: boolean };
2333
};
24-
private extension: DeepCode.ExtensionInterface | undefined;
25-
private issueHoverProvider: vscode.Disposable | undefined;
26-
private ignoreActionsProvider: vscode.Disposable | undefined;
34+
private extension: ExtensionInterface | undefined;
2735
private issuesMarkersdecorationType:
2836
| vscode.TextEditorDecorationType
2937
| undefined;
3038
public deepcodeReview: vscode.DiagnosticCollection | undefined;
31-
public analysisResultsCollection: DeepCode.AnalysisResultsCollectionInterface;
39+
public analysisResultsCollection: AnalysisResultsCollectionInterface;
3240

3341
public constructor() {
3442
this.SEVERITIES = createDeepCodeSeveritiesMap();
3543
this.deepcodeReview = vscode.languages.createDiagnosticCollection(DEEPCODE_NAME);
3644

3745
this.analysisResultsCollection = {};
38-
this.ignoreActionsProvider = new DisposableCodeActionsProvider(
46+
47+
new DisposableCodeActionsProvider(
3948
this.deepcodeReview,
4049
{
4150
findSuggestionId: this.findSuggestionId.bind(this),
4251
trackIgnoreSuggestion: this.trackIgnoreSuggestion.bind(this)
4352
}
4453
);
45-
this.issueHoverProvider = new DisposableHoverProvider(this.deepcodeReview);
54+
new DisposableHoverProvider(this.deepcodeReview);
4655
}
4756

48-
public activate(extension: DeepCode.ExtensionInterface) {
57+
public activate(extension: ExtensionInterface) {
4958
this.extension = extension;
5059
}
5160

@@ -69,8 +78,8 @@ class DeepCodeAnalyzer implements DeepCode.AnalyzerInterface {
6978
);
7079
}
7180

72-
public updateAnalysisResultsCollection(results: DeepCode.AnalysisResultsCollectionInterface, rootPath: string): void {
73-
this.analysisResultsCollection[rootPath] = {...results} as unknown as DeepCode.AnalysisResultsInterface;
81+
public updateAnalysisResultsCollection(results: AnalysisResultsCollectionInterface, rootPath: string): void {
82+
this.analysisResultsCollection[rootPath] = {...results} as unknown as AnalysisResultsInterface;
7483
this.createReviewResults();
7584
}
7685

@@ -81,8 +90,8 @@ class DeepCodeAnalyzer implements DeepCode.AnalyzerInterface {
8190
fileUri
8291
}: {
8392
issue: number;
84-
issuePositions: DeepCode.IssuePositionsInterface;
85-
suggestions: DeepCode.AnalysisSuggestionsInterface;
93+
issuePositions: IssuePositionsInterface;
94+
suggestions: AnalysisSuggestionsInterface;
8695
fileUri: vscode.Uri;
8796
}): vscode.Diagnostic {
8897
const message: string = suggestions[issue].message;
@@ -104,7 +113,7 @@ class DeepCodeAnalyzer implements DeepCode.AnalyzerInterface {
104113
}
105114

106115
private createIssuesList(
107-
options: DeepCode.IssuesListOptionsInterface
116+
options: IssuesListOptionsInterface
108117
): vscode.Diagnostic[] {
109118
const issuesList: vscode.Diagnostic[] = [];
110119
const { fileIssuesList, suggestions, fileUri } = options;
@@ -193,8 +202,8 @@ class DeepCodeAnalyzer implements DeepCode.AnalyzerInterface {
193202
}
194203

195204
public async updateReviewResultsPositions(
196-
extension: DeepCode.ExtensionInterface,
197-
updatedFile: DeepCode.openedTextEditorType
205+
extension: ExtensionInterface,
206+
updatedFile: openedTextEditorType
198207
): Promise<void> {
199208
try {
200209
if (
@@ -205,7 +214,7 @@ class DeepCodeAnalyzer implements DeepCode.AnalyzerInterface {
205214
) {
206215
return;
207216
}
208-
const fileIssuesList: DeepCode.AnalysisResultsFileResultsInterface = await updateFileReviewResultsPositions(
217+
const fileIssuesList: AnalysisResultsFileResultsInterface = await updateFileReviewResultsPositions(
209218
this.analysisResultsCollection,
210219
updatedFile
211220
);

src/deepcode/lib/deepCodeProviders/hoverProvider/DeepCodeHoverProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class DisposableHoverProvider implements vscode.Disposable {
1515
this.hoverProvider = vscode.languages.registerHoverProvider(
1616
{ scheme: "file", language: "*" },
1717
{
18-
provideHover(document, position, token) {
18+
provideHover(document, position, _token) {
1919
if (!deepcodeReview || !deepcodeReview.has(document.uri)) {
2020
return;
2121
}

0 commit comments

Comments
 (0)