refactor: Enable unused locals/parameters and implicit returns (#371)

This commit is contained in:
Qinzhou Xu 2020-11-24 09:59:11 +08:00 коммит произвёл GitHub
Родитель 321cfd1ca8
Коммит 3e41544eeb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
20 изменённых файлов: 29 добавлений и 22 удалений

Просмотреть файл

@ -5,13 +5,12 @@ import * as fse from "fs-extra";
import * as _ from "lodash";
import * as minimatch from "minimatch";
import * as path from "path";
import { commands, Disposable, ExtensionContext, Uri, window, workspace, WorkspaceFolder } from "vscode";
import { Disposable, ExtensionContext, Uri, window, workspace, WorkspaceFolder } from "vscode";
import { instrumentOperationAsVsCodeCommand } from "vscode-extension-telemetry-wrapper";
import { Commands } from "../commands";
import { Jdtls } from "../java/jdtls";
import { Settings } from "../settings";
import { Utility } from "../utility";
import { ContainerNode } from "../views/containerNode";
import { DataNode } from "../views/dataNode";
export class LibraryController implements Disposable {

Просмотреть файл

@ -4,7 +4,7 @@
import { Uri, window, workspace } from "vscode";
import { DataNode } from "../views/dataNode";
import { ExplorerNode } from "../views/explorerNode";
import { isMutable } from "./utils";
import { isMutable } from "./utility";
const confirmMessage = "Move to Recycle Bin";

Просмотреть файл

@ -6,7 +6,7 @@ import * as path from "path";
import { QuickPickItem, Uri, window, workspace, WorkspaceEdit } from "vscode";
import { NodeKind } from "../java/nodeData";
import { DataNode } from "../views/dataNode";
import { checkJavaQualifiedName } from "./utils";
import { checkJavaQualifiedName } from "./utility";
export async function newJavaClass(node: DataNode): Promise<void> {
const packageFsPath: string = await getPackageFsPath(node);

Просмотреть файл

@ -7,7 +7,7 @@ import { Uri, window, workspace, WorkspaceEdit } from "vscode";
import { NodeKind } from "../java/nodeData";
import { DataNode } from "../views/dataNode";
import { ExplorerNode } from "../views/explorerNode";
import { checkJavaQualifiedName, isMutable } from "./utils";
import { checkJavaQualifiedName, isMutable } from "./utility";
export async function renameFile(node: DataNode, selectedNode: ExplorerNode): Promise<void> {
// if command not invoked by context menu, use selected node in explorer

Просмотреть файл

Просмотреть файл

@ -62,7 +62,7 @@ export class GenerateJarExecutor implements IExportJarStepExecutor {
location: ProgressLocation.Window,
title: "Exporting Jar : Generating jar...",
cancellable: true,
}, (progress, token) => {
}, (_progress, token) => {
return new Promise<boolean>(async (resolve, reject) => {
token.onCancellationRequested(() => {
return reject();
@ -84,7 +84,7 @@ export class GenerateJarExecutor implements IExportJarStepExecutor {
location: ProgressLocation.Window,
title: "Exporting Jar : Resolving classpaths...",
cancellable: true,
}, (progress, token) => {
}, (_progress, token) => {
return new Promise<IJarQuickPickItem[]>(async (resolve, reject) => {
token.onCancellationRequested(() => {
return reject();

Просмотреть файл

@ -35,7 +35,7 @@ export class ResolveMainClassExecutor implements IExportJarStepExecutor {
location: ProgressLocation.Window,
title: "Exporting Jar : Resolving main classes...",
cancellable: true,
}, (progress, token) => {
}, (_progress, token) => {
return new Promise<IMainClassInfo[] | undefined>(async (resolve, reject) => {
token.onCancellationRequested(() => {
return reject();

Просмотреть файл

@ -59,6 +59,7 @@ function getContainerType(containerPath: string | undefined): string {
} else if (containerPath.startsWith(ContainerPath.ReferencedLibrary)) {
return "referencedLibrary";
}
return "";
}
const enum ContainerPath {

Просмотреть файл

@ -27,6 +27,7 @@ export abstract class DataNode extends ExplorerNode {
item.contextValue = this.computeContextValue();
return item;
}
return undefined;
}
public get nodeData(): INodeData {

Просмотреть файл

@ -4,7 +4,7 @@
import * as _ from "lodash";
import {
commands, Event, EventEmitter, ExtensionContext, extensions, ProviderResult,
Range, TreeDataProvider, TreeItem, Uri, window, workspace,
TreeDataProvider, TreeItem, Uri, window, workspace,
} from "vscode";
import { instrumentOperation, instrumentOperationAsVsCodeCommand } from "vscode-extension-telemetry-wrapper";
import { Commands } from "../commands";

Просмотреть файл

@ -31,6 +31,7 @@ export class DocumentSymbolNode extends BaseSymbolNode {
item.command = this.command;
return item;
}
return undefined;
}
protected get range(): Range {

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import { Command, ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
import { Command, ThemeIcon } from "vscode";
import { Commands } from "../commands";
import { Explorer } from "../constants";
import { INodeData } from "../java/nodeData";

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import { ProviderResult, TreeItem, TreeItemCollapsibleState } from "vscode";
import { TreeItem, TreeItemCollapsibleState } from "vscode";
import { HierarchicalPackageNodeData } from "../java/hierarchicalPackageNodeData";
import { INodeData, NodeKind } from "../java/nodeData";
import { DataNode } from "./dataNode";
@ -23,6 +23,7 @@ export class HierarchicalPackageNode extends PackageNode {
this.hasChildren() ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None);
return { ...super.getTreeItem(), ...item };
}
return undefined;
}
public async getChildren(): Promise<ExplorerNode[]> {

Просмотреть файл

@ -8,7 +8,7 @@ export class Trie<T extends IUriData> {
private _root: TrieNode<T>;
constructor() {
this._root = new TrieNode(null, null);
this._root = new TrieNode(null);
}
public insert(input: T): void {
@ -21,7 +21,7 @@ export class Trie<T extends IUriData> {
continue;
}
if (!currentNode.children[segment]) {
currentNode.children[segment] = new TrieNode(segment, null);
currentNode.children[segment] = new TrieNode(null);
}
currentNode = currentNode.children[segment];
}
@ -83,12 +83,10 @@ export interface IUriData {
}
export class TrieNode<T> {
private _key: string;
private _value: T;
private _children: INodeChildren<T>;
constructor(key: string, value: T) {
this._key = key;
constructor(value: T) {
this._value = value;
this._children = {};
}

Просмотреть файл

@ -53,5 +53,6 @@ export class PackageNode extends DataNode {
} else if (parentData.entryKind === PackageRootKind.K_BINARY) {
return `${Explorer.ContextValueType.Package}+binary`;
}
return undefined;
}
}

Просмотреть файл

@ -52,7 +52,7 @@ export class ProjectNode extends DataNode {
let result: INodeData[] = [];
return Jdtls.getPackageData({ kind: NodeKind.Project, projectUri: this.nodeData.uri }).then((res) => {
if (!res) {
return;
return undefined;
}
const sourceContainer: IContainerNodeData[] = [];
res.forEach((node) => {
@ -67,7 +67,7 @@ export class ProjectNode extends DataNode {
return Promise.all(sourceContainer.map((c) => Jdtls.getPackageData({ kind: NodeKind.Container, projectUri: this.uri, path: c.path })))
.then((rootPackages) => {
if (!rootPackages) {
return;
return undefined;
}
result = result.concat(...rootPackages);
return result;

Просмотреть файл

@ -36,6 +36,7 @@ export class SymbolNode extends BaseSymbolNode {
item.command = this.command;
return item;
}
return undefined;
}
protected get range(): Range {

Просмотреть файл

@ -2,7 +2,7 @@
// Licensed under the MIT license.
import * as path from "path";
import { commands, Event, extensions, Uri } from "vscode";
import { commands, extensions, Uri } from "vscode";
import { Commands, DataNode, LanguageServerMode } from "../extension.bundle";
export namespace Uris {

Просмотреть файл

@ -13,7 +13,7 @@ suite("Extension Tests", () => {
});
test("should activate", async function() {
const _api = await vscode.extensions.getExtension("vscjava.vscode-java-dependency")!.activate();
await vscode.extensions.getExtension("vscjava.vscode-java-dependency")!.activate();
assert.ok(true);
});
});

Просмотреть файл

@ -3,12 +3,16 @@
"module": "commonjs",
"target": "es6",
"outDir": "out",
"alwaysStrict": true,
"lib": [
"es6"
],
"sourceMap": true,
"rootDir": "."
"rootDir": ".",
"noUnusedLocals": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noUnusedParameters": true,
"alwaysStrict": true
},
"exclude": [
"node_modules",