Skip to content

Commit

Permalink
Fixes issues detected by DeepScan
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Nov 2, 2018
1 parent 08e31f1 commit e0df9a8
Show file tree
Hide file tree
Showing 23 changed files with 54 additions and 81 deletions.
6 changes: 3 additions & 3 deletions src/annotations/annotationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export abstract class AnnotationProviderBase implements Disposable {
);
}

async dispose() {
await this.clear();
dispose() {
this.clear();

this.disposable && this.disposable.dispose();
}
Expand Down Expand Up @@ -129,7 +129,7 @@ export abstract class AnnotationProviderBase implements Disposable {
highlightDecoration: TextEditorDecorationType | undefined;
}) {
if (changes !== undefined) {
await this.clear();
this.clear();

this.decoration = changes.decoration;
this.highlightDecoration = changes.highlightDecoration;
Expand Down
2 changes: 1 addition & 1 deletion src/annotations/fileAnnotationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ export class FileAnnotationController implements Disposable {
Logger.log(`${reason}:`, `Clear annotations for ${key}`);

this._annotationProviders.delete(key);
await provider.dispose();
provider.dispose();

if (this._annotationProviders.size === 0 || key === AnnotationProviderBase.getCorrelationKey(this._editor)) {
await setCommandContext(CommandContext.AnnotationStatus, undefined);
Expand Down
21 changes: 10 additions & 11 deletions src/commands/diffWithRevision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,16 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand {
currentCommand: currentCommand,
nextPageCommand: args.nextPageCommand,
previousPageCommand: previousPageCommand,
showAllCommand:
log !== undefined && log.truncated
? new CommandQuickPickItem(
{
label: `$(sync) Show All Commits`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} this may take a while`
},
Commands.DiffWithRevision,
[uri, { ...args, maxCount: 0 } as DiffWithRevisionCommandArgs]
)
: undefined
showAllCommand: log.truncated
? new CommandQuickPickItem(
{
label: `$(sync) Show All Commits`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} this may take a while`
},
Commands.DiffWithRevision,
[uri, { ...args, maxCount: 0 } as DiffWithRevisionCommandArgs]
)
: undefined
});
if (pick === undefined) return undefined;

Expand Down
21 changes: 10 additions & 11 deletions src/commands/openFileRevision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,16 @@ export class OpenFileRevisionCommand extends ActiveEditorCommand {
currentCommand: currentCommand,
nextPageCommand: args.nextPageCommand,
previousPageCommand: previousPageCommand,
showAllCommand:
log !== undefined && log.truncated
? new CommandQuickPickItem(
{
label: `$(sync) Show All Commits`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} this may take a while`
},
Commands.OpenFileRevision,
[uri, { ...args, maxCount: 0 } as OpenFileRevisionCommandArgs]
)
: undefined
showAllCommand: log.truncated
? new CommandQuickPickItem(
{
label: `$(sync) Show All Commits`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} this may take a while`
},
Commands.OpenFileRevision,
[uri, { ...args, maxCount: 0 } as OpenFileRevisionCommandArgs]
)
: undefined
});
if (pick === undefined) return undefined;

Expand Down
2 changes: 1 addition & 1 deletion src/commands/showCommitSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
}

if (args.showInResults) {
Container.resultsView.addSearchResults(
void Container.resultsView.addSearchResults(
repoPath,
Container.git.getLogForSearch(repoPath, args.search!, args.searchBy!, {
maxCount: args.maxCount
Expand Down
4 changes: 2 additions & 2 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
Uri,
workspace
} from 'vscode';
import { CommandContext, extensionId, setCommandContext } from './constants';
import { extensionId } from './constants';
import { Container } from './container';
import { clearGravatarCache } from './git/gitService';
import { Functions } from './system';
import { Config, KeyMap } from './ui/config';
import { Config } from './ui/config';

const emptyConfig: any = new Proxy<any>({} as Config, {
get(target, propKey, receiver) {
Expand Down
12 changes: 1 addition & 11 deletions src/git/formatters/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,7 @@ export abstract class Formatter<TItem = any, TOptions extends IFormatOptions = I

let max = options.truncateTo;
if (max === undefined) {
if (this.collapsableWhitespace !== 0) {
const width = Strings.getWidth(s);

// If we have left over whitespace make sure it gets re-added
const diff = this.collapsableWhitespace - width;
this.collapsableWhitespace = 0;

if (diff > 0 && options.truncateTo !== undefined) {
s = Strings.padLeft(s, diff, undefined, width);
}
}
this.collapsableWhitespace = 0;
}
else {
max += this.collapsableWhitespace;
Expand Down
2 changes: 1 addition & 1 deletion src/git/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ export class Git {
return data === '' ? undefined : data.trim();
}

static async revparse_currentBranch(repoPath: string): Promise<[string, string?] | undefined> {
static async revparse_currentBranch(repoPath: string): Promise<[string, string | undefined] | undefined> {
const params = ['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@', '@{u}'];

const opts = {
Expand Down
2 changes: 1 addition & 1 deletion src/git/gitService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ export class GitService implements Disposable {
}

Logger.error(ex);
Messages.showGenericErrorMessage(`Unable to apply changes`);
void Messages.showGenericErrorMessage(`Unable to apply changes`);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/git/models/branch.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';
import { Git } from '../git';
import { GitStatus } from './status';

'use strict';

export class GitBranch {
readonly detached: boolean;
readonly name: string;
Expand Down
4 changes: 1 addition & 3 deletions src/git/models/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ export abstract class GitCommit {
}

get previousUri(): Uri {
return this.previousFileName
? Uri.file(paths.resolve(this.repoPath, (this.previousFileName || this.originalFileName)!))
: this.uri;
return this.previousFileName ? Uri.file(paths.resolve(this.repoPath, this.previousFileName)) : this.uri;
}

get uri(): Uri {
Expand Down
12 changes: 3 additions & 9 deletions src/git/parsers/stashParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ export class GitStashParser {
}
}

let commit = commits.get(entry.ref!);
commit = GitStashParser.parseEntry(entry, commit, repoPath, commits);
GitStashParser.parseEntry(entry, repoPath, commits);
}
}

Expand All @@ -132,12 +131,8 @@ export class GitStashParser {
} as GitStash;
}

private static parseEntry(
entry: StashEntry,
commit: GitStashCommit | undefined,
repoPath: string,
commits: Map<string, GitStashCommit>
): GitStashCommit | undefined {
private static parseEntry(entry: StashEntry, repoPath: string, commits: Map<string, GitStashCommit>) {
let commit = commits.get(entry.ref!);
if (commit === undefined) {
commit = new GitStashCommit(
GitCommitType.Stash,
Expand All @@ -153,6 +148,5 @@ export class GitStashParser {
}

commits.set(entry.ref!, commit);
return commit;
}
}
12 changes: 3 additions & 9 deletions src/quickpicks/commonQuickPicks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ export class ChooseFromBranchesAndTagsQuickPickItem extends CommandQuickPickItem
super(item, undefined, undefined);
}

async execute(
options: TextDocumentShowOptions = { preserveFocus: false, preview: false }
): Promise<CommandQuickPickItem | BranchOrTagQuickPickItem | undefined> {
async execute(): Promise<CommandQuickPickItem | BranchOrTagQuickPickItem | undefined> {
const progressCancellation = BranchesAndTagsQuickPick.showProgress(this.placeHolder);

try {
Expand Down Expand Up @@ -244,9 +242,7 @@ export class ShowCommitInResultsQuickPickItem extends CommandQuickPickItem {
super(item, undefined, undefined);
}

async execute(
options: TextDocumentShowOptions = { preserveFocus: false, preview: false }
): Promise<{} | undefined> {
async execute(): Promise<{} | undefined> {
await Container.resultsView.addCommit(this.commit);
return undefined;
}
Expand All @@ -264,9 +260,7 @@ export class ShowCommitsInResultsQuickPickItem extends CommandQuickPickItem {
super(item, undefined, undefined);
}

async execute(
options: TextDocumentShowOptions = { preserveFocus: false, preview: false }
): Promise<{} | undefined> {
async execute(): Promise<{} | undefined> {
await Container.resultsView.addSearchResults(this.results.repoPath, this.results, this.resultsLabel);
return undefined;
}
Expand Down
4 changes: 2 additions & 2 deletions src/system/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ export function log<T>(
if (Logger.level === LogLevel.Debug || (Logger.level === LogLevel.Verbose && !options.debug)) {
let instanceName: string;
if (this != null) {
instanceName = this.constructor.name;
instanceName = this.constructor != null ? this.constructor.name : '';
// Strip webpack module name (since I never name classes with an _)
const index = instanceName.indexOf('_');
if (index !== -1) {
instanceName = instanceName.substr(index + 1);
}

if (this.constructor && this.constructor[LogInstanceNameFn]) {
if (this.constructor != null && this.constructor[LogInstanceNameFn]) {
instanceName = target.constructor[LogInstanceNameFn](this, instanceName);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/system/function.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
import { Disposable } from 'vscode';

'use strict';
const _debounce = require('lodash.debounce');
const _once = require('lodash.once');

Expand Down
4 changes: 2 additions & 2 deletions src/trackers/documentTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class DocumentTracker<T> implements Disposable {
}

private onTextDocumentSaved(document: TextDocument) {
let doc = this._documentMap.get(document);
const doc = this._documentMap.get(document);
if (doc !== undefined) {
void doc.update({ forceBlameChange: true });

Expand All @@ -179,7 +179,7 @@ export class DocumentTracker<T> implements Disposable {

// If we are saving the active document make sure we are tracking it
if (isActiveDocument(document)) {
doc = this.addCore(document);
void this.addCore(document);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/views/fileHistoryView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class FileHistoryView extends ViewBase<FileHistoryTrackerNode> {
}

protected registerCommands() {
Container.viewCommands;
void Container.viewCommands;
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(), this);
commands.registerCommand(
this.getQualifiedCommand('refreshNode'),
Expand Down
2 changes: 1 addition & 1 deletion src/views/lineHistoryView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class LineHistoryView extends ViewBase<LineHistoryTrackerNode> {
}

protected registerCommands() {
Container.viewCommands;
void Container.viewCommands;
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(), this);
commands.registerCommand(
this.getQualifiedCommand('refreshNode'),
Expand Down
4 changes: 2 additions & 2 deletions src/views/nodes/repositoriesNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class RepositoriesNode extends SubscribeableViewNode<RepositoriesView> {
const child = (this._children as RepositoryNode[]).find(c => c.repo.normalizedPath === normalizedPath);
if (child !== undefined) {
children.push(child);
child.refresh();
void child.refresh();
}
else {
children.push(new RepositoryNode(GitUri.fromRepoPath(repo.path), repo, this, this.view));
Expand Down Expand Up @@ -133,7 +133,7 @@ export class RepositoriesNode extends SubscribeableViewNode<RepositoriesView> {
parent = parent.getParent();
}

this.view.reveal(node);
void this.view.reveal(node);
}
catch (ex) {
Logger.error(ex);
Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/viewNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export abstract class SubscribeableViewNode<TView extends View> extends ViewNode

@debug()
dispose() {
this.unsubscribe();
void this.unsubscribe();

if (this._disposable !== undefined) {
this._disposable.dispose();
Expand Down
2 changes: 1 addition & 1 deletion src/views/repositoriesView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class RepositoriesView extends ViewBase<RepositoriesNode> {
}

protected registerCommands() {
Container.viewCommands;
void Container.viewCommands;

commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(), this);
commands.registerCommand(
Expand Down
2 changes: 1 addition & 1 deletion src/views/resultsView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class ResultsView extends ViewBase<ResultsNode> {
}

protected registerCommands() {
Container.viewCommands;
void Container.viewCommands;
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(), this);
commands.registerCommand(
this.getQualifiedCommand('refreshNode'),
Expand Down
8 changes: 4 additions & 4 deletions src/views/viewCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,16 @@ export class ViewCommands implements Disposable {
} as OpenFileInRemoteCommandArgs);
}

stageFile(node: CommitFileNode | StatusFileNode) {
private async stageFile(node: CommitFileNode | StatusFileNode) {
if (!(node instanceof CommitFileNode) && !(node instanceof StatusFileNode)) return;

Container.git.stageFile(node.repoPath, node.file.fileName);
void (await Container.git.stageFile(node.repoPath, node.file.fileName));
}

unstageFile(node: CommitFileNode | StatusFileNode) {
private async unstageFile(node: CommitFileNode | StatusFileNode) {
if (!(node instanceof CommitFileNode) && !(node instanceof StatusFileNode)) return;

Container.git.unStageFile(node.repoPath, node.file.fileName);
void (await Container.git.unStageFile(node.repoPath, node.file.fileName));
}

async terminalCheckoutBranch(node: ViewNode) {
Expand Down

0 comments on commit e0df9a8

Please sign in to comment.