Skip to content

Commit a8c46fe

Browse files
committed
Fixed lint suggestions.
1 parent 5cfd322 commit a8c46fe

12 files changed

Lines changed: 71 additions & 74 deletions

src/deepcode/lib/modules/BaseDeepCodeModule.ts

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,31 @@ import DeepCodeFilesWatcher from "../watchers/DeepCodeFilesWatcher";
66
import DeepCodeWorkspaceFoldersWatcher from "../watchers/WorkspaceFoldersWatcher";
77
import DeepCodeEditorsWatcher from "../watchers/EditorsWatcher";
88
import DeepCodeSettingsWatcher from "../watchers/DeepCodeSettingsWatcher";
9-
// import DeepCodeErrorhandler from "../errorHandler/DeepCodeErrorHandler";
109
import { IDE_NAME } from "../../constants/general";
1110

1211
export default abstract class BaseDeepCodeModule implements DeepCode.BaseDeepCodeModuleInterface {
13-
public currentWorkspacePath: string;
14-
public workspacesPaths: Array<string>;
15-
public hashesBundles: DeepCode.HashesBundlesInterface;
16-
public serverFilesFilterList: DeepCode.AllowedServerFilterListInterface;
17-
public remoteBundles: DeepCode.RemoteBundlesCollectionInterface;
18-
public analyzer: DeepCode.AnalyzerInterface;
19-
public statusBarItem: DeepCode.StatusBarItemInterface;
20-
public filesWatcher: DeepCode.DeepCodeWatcherInterface;
21-
public workspacesWatcher: DeepCode.DeepCodeWatcherInterface;
22-
public editorsWatcher: DeepCode.DeepCodeWatcherInterface;
23-
public settingsWatcher: DeepCode.DeepCodeWatcherInterface;
24-
// public errorHandler: DeepCode.ErrorHandlerInterface;
12+
currentWorkspacePath: string;
13+
workspacesPaths: Array<string>;
14+
hashesBundles: DeepCode.HashesBundlesInterface;
15+
serverFilesFilterList: DeepCode.AllowedServerFilterListInterface;
16+
remoteBundles: DeepCode.RemoteBundlesCollectionInterface;
17+
analyzer: DeepCode.AnalyzerInterface;
18+
statusBarItem: DeepCode.StatusBarItemInterface;
19+
filesWatcher: DeepCode.DeepCodeWatcherInterface;
20+
workspacesWatcher: DeepCode.DeepCodeWatcherInterface;
21+
editorsWatcher: DeepCode.DeepCodeWatcherInterface;
22+
settingsWatcher: DeepCode.DeepCodeWatcherInterface;
2523

2624
// Views and analysis progress
27-
public refreshViewEmitter: vscode.EventEmitter<any>;
28-
public analysisStatus: string = '';
29-
public analysisProgress: number = 0;
25+
refreshViewEmitter: vscode.EventEmitter<any>;
26+
analysisStatus = '';
27+
analysisProgress = 0;
3028

3129
// These attributes are used in tests
32-
public staticToken = '';
33-
public staticBaseURL = '';
34-
public defaultBaseURL = 'https://www.deepcode.ai';
35-
public staticUploadApproved = false;
30+
staticToken = '';
31+
staticBaseURL = '';
32+
defaultBaseURL = 'https://www.deepcode.ai';
33+
staticUploadApproved = false;
3634

3735
constructor() {
3836
this.currentWorkspacePath = "";
@@ -46,52 +44,51 @@ export default abstract class BaseDeepCodeModule implements DeepCode.BaseDeepCod
4644
this.workspacesWatcher = new DeepCodeWorkspaceFoldersWatcher();
4745
this.editorsWatcher = new DeepCodeEditorsWatcher();
4846
this.settingsWatcher = new DeepCodeSettingsWatcher();
49-
// this.errorHandler = new DeepCodeErrorhandler();
5047
this.refreshViewEmitter = new vscode.EventEmitter<any>();
5148
this.analysisStatus = '';
5249
this.analysisProgress = 0;
5350
}
5451

55-
public get baseURL(): string {
52+
get baseURL(): string {
5653
// @ts-ignore */}
5754
return this.staticBaseURL || vscode.workspace.getConfiguration('deepcode').get('url') || this.defaultBaseURL;
5855
}
5956

60-
public get termsConditionsUrl(): string {
57+
get termsConditionsUrl(): string {
6158
return `${this.baseURL}/tc?utm_source=vsc`;
6259
}
6360

64-
public get token(): string {
61+
get token(): string {
6562
// @ts-ignore */}
6663
return this.staticToken || vscode.workspace.getConfiguration('deepcode').get('token');
6764
}
6865

69-
public async setToken(token: string): Promise<void> {
66+
async setToken(token: string): Promise<void> {
7067
this.staticToken = '';
7168
await vscode.workspace.getConfiguration('deepcode').update('token', token, true);
7269
}
7370

74-
public get source(): string {
71+
get source(): string {
7572
return process.env['GITPOD_WORKSPACE_ID'] ? 'gitpod' : IDE_NAME;
7673
}
7774

78-
public get uploadApproved(): boolean {
75+
get uploadApproved(): boolean {
7976
return this.staticUploadApproved || this.source !== IDE_NAME || !!(vscode.workspace.getConfiguration('deepcode').get('uploadApproved'));
8077
}
8178

82-
public async setUploadApproved(value: boolean = true): Promise<void> {
79+
async setUploadApproved(value = true): Promise<void> {
8380
await vscode.workspace.getConfiguration('deepcode').update('uploadApproved', value, true);
8481
}
8582

86-
public get shouldReportErrors(): boolean {
83+
get shouldReportErrors(): boolean {
8784
return !!vscode.workspace.getConfiguration('deepcode').get('yesCrashReport');
8885
}
8986

90-
public get shouldReportEvents(): boolean {
87+
get shouldReportEvents(): boolean {
9188
return !!vscode.workspace.getConfiguration('deepcode').get('yesTelemetry');
9289
}
9390

94-
public refreshViews(content?: any): void {
91+
refreshViews(content?: any): void {
9592
this.refreshViewEmitter.fire(content || undefined);
9693
}
9794

src/deepcode/lib/modules/DeepCodeLib.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export default class DeepCodeLib extends BundlesModule implements DeepCode.DeepC
1818
console.log("DeepCode: starting execution pipeline");
1919
setContext(DEEPCODE_CONTEXT.ERROR, false);
2020

21-
let loggedIn = await this.checkSession();
21+
const loggedIn = await this.checkSession();
2222
if (!loggedIn) return;
23-
let approved = await this.checkApproval();
23+
const approved = await this.checkApproval();
2424
if (!approved) return;
2525
await this.startAnalysis();
2626

src/deepcode/lib/modules/LoginModule.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import DeepCode from "../../../interfaces/DeepCodeInterfaces";
33
import http from "../../http/requests";
44
import { setContext, viewInBrowser } from "../../utils/vscodeCommandsUtils";
55
import { DEEPCODE_CONTEXT } from "../../constants/views";
6-
6+
import { errorsLogs } from "../../messages/errorsServerLogMessages";
77

88
const sleep = (duration: number) => new Promise(resolve => setTimeout(resolve, duration));
99

1010
abstract class LoginModule extends ReportModule implements DeepCode.LoginModuleInterface {
1111
private pendingLogin: boolean = false;
1212

13-
public async initiateLogin(): Promise<void> {
13+
async initiateLogin(): Promise<void> {
1414
if (this.pendingLogin) {
1515
return;
1616
}
@@ -19,21 +19,21 @@ abstract class LoginModule extends ReportModule implements DeepCode.LoginModuleI
1919
try {
2020
setContext(DEEPCODE_CONTEXT.LOGGEDIN, false);
2121
const result = await http.login(this.baseURL, this.source);
22-
let { sessionToken, loginURL } = result;
22+
const { sessionToken, loginURL } = result;
2323
if (!sessionToken || !loginURL) {
24-
throw new Error(`Failed to create a new session with response: ${JSON.stringify(result)}`);
24+
throw new Error(errorsLogs.login);
2525
}
2626
await this.setToken(sessionToken);
2727
await viewInBrowser(loginURL);
2828
await this.waitLoginConfirmation();
2929
} catch (err) {
30-
await this.processError(err);
30+
await this.processError(err, { message: errorsLogs.login });
3131
} finally {
3232
this.pendingLogin = false;
3333
}
3434
}
3535

36-
public async checkSession(): Promise<boolean> {
36+
async checkSession(): Promise<boolean> {
3737
let validSession = false;
3838
if (this.token) {
3939
validSession = !!(await http.checkSession(this.baseURL, this.token));
@@ -55,13 +55,13 @@ abstract class LoginModule extends ReportModule implements DeepCode.LoginModuleI
5555
}
5656
}
5757

58-
public async checkApproval(): Promise<boolean> {
59-
let approved = this.uploadApproved;
58+
async checkApproval(): Promise<boolean> {
59+
const approved = this.uploadApproved;
6060
setContext(DEEPCODE_CONTEXT.APPROVED, approved);
6161
return approved;
6262
}
6363

64-
public async approveUpload(): Promise<void> {
64+
async approveUpload(): Promise<void> {
6565
this.setUploadApproved(true);
6666
this.checkApproval();
6767
}

src/deepcode/lib/modules/ReportModule.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ abstract class ReportModule extends BaseDeepCodeModule implements DeepCode.Repor
1818
return this.baseURL === this.defaultBaseURL;
1919
}
2020

21-
public resetTransientErrors(): void {
21+
resetTransientErrors(): void {
2222
this.transientErrors = 0;
2323
}
2424

25-
public async sendError(options: {[key: string]: any}): Promise<void> {
25+
async sendError(options: {[key: string]: any}): Promise<void> {
2626
if (!this.shouldReport || !this.shouldReportErrors) return;
2727
await http.sendError(this.baseURL, {
2828
source: this.source,
@@ -31,7 +31,7 @@ abstract class ReportModule extends BaseDeepCodeModule implements DeepCode.Repor
3131
});
3232
}
3333

34-
public async sendEvent(event: string, options: {[key: string]: any}): Promise<void> {
34+
async sendEvent(event: string, options: {[key: string]: any}): Promise<void> {
3535
if (!this.shouldReport || !this.shouldReportEvents) return;
3636
await http.sendEvent(this.baseURL, {
3737
type: event,
@@ -41,7 +41,7 @@ abstract class ReportModule extends BaseDeepCodeModule implements DeepCode.Repor
4141
});
4242
}
4343

44-
public async processError(
44+
async processError(
4545
error: DeepCode.errorType,
4646
options: { [key: string]: any } = {}
4747
): Promise<void> {
@@ -117,7 +117,7 @@ abstract class ReportModule extends BaseDeepCodeModule implements DeepCode.Repor
117117
try {
118118
type = `${error.statusCode || ""} ${error.name || ""}`.trim();
119119
} catch (e) {
120-
type = "unknown"
120+
type = "unknown";
121121
}
122122
try {
123123
await this.sendError({

src/deepcode/utils/packageUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ALLOWED_PAYLOAD_SIZE } from "../constants/general";
1212
const SAFE_PAYLOAD_SIZE = ALLOWED_PAYLOAD_SIZE / 2;
1313

1414
interface ProgressInterface {
15-
onProgress: (value: number) => void,
15+
onProgress: (value: number) => void;
1616
percentDone?: number;
1717
multiplier?: number;
1818
}
@@ -125,4 +125,4 @@ export const getBaseExclusionFilter = (): ExclusionFilter => {
125125
rootExclusionRule.addExclusions(EXCLUDED_NAMES, "");
126126
exclusionFilter.addExclusionRule(rootExclusionRule);
127127
return exclusionFilter;
128-
}
128+
};

src/deepcode/utils/vscodeCommandsUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ export const startDeepCodeCommand = (): void => {
1515
vscode.commands.executeCommand(DEEPCODE_START_COMMAND);
1616
};
1717

18-
export function setContext(key: string, value: unknown) {
18+
export const setContext = (key: string, value: unknown): void => {
1919
console.log("DeepCode context",key, value);
2020
vscode.commands.executeCommand('setContext', `${DEEPCODE_CONTEXT_PREFIX}${key}`, value);
2121
};
2222

23-
export function viewInBrowser(url: string) {
23+
export const viewInBrowser = (url: string): void => {
2424
vscode.commands.executeCommand(DEEPCODE_OPEN_BROWSER, url);
2525
};

src/deepcode/view/IssueProvider.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Uri, Range, Diagnostic } from 'vscode';
2-
import { NodeProvider } from './NodeProvider'
3-
import { Node } from './Node'
2+
import { NodeProvider } from './NodeProvider';
3+
import { Node } from './Node';
44
import { getDeepCodeSeverity } from "../utils/analysisUtils";
55
import { DEEPCODE_SEVERITIES } from "../constants/analysis";
66

77
interface ISeverityCounts {
8-
[severity: number]: number,
8+
[severity: number]: number;
99
}
1010

1111
export class IssueProvider extends NodeProvider {
@@ -14,13 +14,13 @@ export class IssueProvider extends NodeProvider {
1414
}
1515

1616
getSuperscriptNumber(n: number): string {
17-
let res: string = "";
17+
let res = "";
1818
const nDigits = Math.round(n).toString().split('');
1919
const digitMap: { [digit: string]: string } = {
2020
'0': '⁰', '1': '¹', '2': '²', '3': '³', '4': '⁴',
2121
'5': '⁵', '6': '⁶', '7': '⁷', '8': '⁸', '9': '⁹',
22-
}
23-
for (let d of nDigits) res += digitMap[d] || "";
22+
};
23+
for (const d of nDigits) res += digitMap[d] || "";
2424
return res;
2525
}
2626

@@ -38,7 +38,7 @@ export class IssueProvider extends NodeProvider {
3838

3939
getFileText(text: string, counts: ISeverityCounts ): string {
4040
let res :string = "";
41-
for (let s of [
41+
for (const s of [
4242
DEEPCODE_SEVERITIES.error,
4343
DEEPCODE_SEVERITIES.warning,
4444
DEEPCODE_SEVERITIES.information,

src/deepcode/view/Node.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ import { Uri, Range, Command, TreeItem, TreeItemCollapsibleState } from 'vscode'
22
import { DEEPCODE_OPEN_BROWSER, DEEPCODE_OPEN_LOCAL } from "../constants/commands";
33

44
export interface INodeOptions {
5-
text: string,
6-
description?: string,
5+
text: string;
6+
description?: string;
77
issue?: {
88
uri: Uri,
99
range?: Range,
10-
},
11-
link?: string,
12-
command?: Command,
13-
collapsed?: TreeItemCollapsibleState,
14-
parent?: Node,
15-
children?: Node[],
10+
};
11+
link?: string;
12+
command?: Command;
13+
collapsed?: TreeItemCollapsibleState;
14+
parent?: Node;
15+
children?: Node[];
1616
}
1717

1818

src/deepcode/view/NodeProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import DeepCode from "../../interfaces/DeepCodeInterfaces";
22
import { TreeDataProvider, ProviderResult } from 'vscode';
3-
import { Node } from './Node'
3+
import { Node } from './Node';
44

55
export abstract class NodeProvider implements TreeDataProvider<Node> {
66
constructor(
77
protected extension: DeepCode.ExtensionInterface
8-
) {};
8+
) {}
99

1010
abstract getRootChildren(): Node[];
1111

src/deepcode/view/ProgressProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { NodeProvider } from './NodeProvider'
2-
import { Node } from './Node'
1+
import { NodeProvider } from './NodeProvider';
2+
import { Node } from './Node';
33

44
export class ProgressProvider extends NodeProvider {
55

0 commit comments

Comments
 (0)