Просмотр исходного кода

Fixes issues detected by DeepScan

main
Eric Amodio 6 лет назад
Родитель
Сommit
e0df9a8c30
23 измененных файлов: 54 добавлений и 81 удалений
  1. +3
    -3
      src/annotations/annotationProvider.ts
  2. +1
    -1
      src/annotations/fileAnnotationController.ts
  3. +10
    -11
      src/commands/diffWithRevision.ts
  4. +10
    -11
      src/commands/openFileRevision.ts
  5. +1
    -1
      src/commands/showCommitSearch.ts
  6. +2
    -2
      src/configuration.ts
  7. +1
    -11
      src/git/formatters/formatter.ts
  8. +1
    -1
      src/git/git.ts
  9. +1
    -1
      src/git/gitService.ts
  10. +1
    -2
      src/git/models/branch.ts
  11. +1
    -3
      src/git/models/commit.ts
  12. +3
    -9
      src/git/parsers/stashParser.ts
  13. +3
    -9
      src/quickpicks/commonQuickPicks.ts
  14. +2
    -2
      src/system/decorators.ts
  15. +1
    -1
      src/system/function.ts
  16. +2
    -2
      src/trackers/documentTracker.ts
  17. +1
    -1
      src/views/fileHistoryView.ts
  18. +1
    -1
      src/views/lineHistoryView.ts
  19. +2
    -2
      src/views/nodes/repositoriesNode.ts
  20. +1
    -1
      src/views/nodes/viewNode.ts
  21. +1
    -1
      src/views/repositoriesView.ts
  22. +1
    -1
      src/views/resultsView.ts
  23. +4
    -4
      src/views/viewCommands.ts

+ 3
- 3
src/annotations/annotationProvider.ts Просмотреть файл

@ -50,8 +50,8 @@ export abstract class AnnotationProviderBase implements Disposable {
);
}
async dispose() {
await this.clear();
dispose() {
this.clear();
this.disposable && this.disposable.dispose();
}
@ -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;

+ 1
- 1
src/annotations/fileAnnotationController.ts Просмотреть файл

@ -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);

+ 10
- 11
src/commands/diffWithRevision.ts Просмотреть файл

@ -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;

+ 10
- 11
src/commands/openFileRevision.ts Просмотреть файл

@ -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;

+ 1
- 1
src/commands/showCommitSearch.ts Просмотреть файл

@ -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

+ 2
- 2
src/configuration.ts Просмотреть файл

@ -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) {

+ 1
- 11
src/git/formatters/formatter.ts Просмотреть файл

@ -56,17 +56,7 @@ export abstract class Formatter
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;

+ 1
- 1
src/git/git.ts Просмотреть файл

@ -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 = {

+ 1
- 1
src/git/gitService.ts Просмотреть файл

@ -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`);
}
}

+ 1
- 2
src/git/models/branch.ts Просмотреть файл

@ -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;

+ 1
- 3
src/git/models/commit.ts Просмотреть файл

@ -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 {

+ 3
- 9
src/git/parsers/stashParser.ts Просмотреть файл

@ -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);
}
}
@ -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,
@ -153,6 +148,5 @@ export class GitStashParser {
}
commits.set(entry.ref!, commit);
return commit;
}
}

+ 3
- 9
src/quickpicks/commonQuickPicks.ts Просмотреть файл

@ -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 {
@ -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;
}
@ -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;
}

+ 2
- 2
src/system/decorators.ts Просмотреть файл

@ -85,14 +85,14 @@ export function log(
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);
}
}

+ 1
- 1
src/system/function.ts Просмотреть файл

@ -1,6 +1,6 @@
'use strict';
import { Disposable } from 'vscode';
'use strict';
const _debounce = require('lodash.debounce');
const _once = require('lodash.once');

+ 2
- 2
src/trackers/documentTracker.ts Просмотреть файл

@ -170,7 +170,7 @@ export class DocumentTracker 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 });
@ -179,7 +179,7 @@ export class DocumentTracker 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);
}
}

+ 1
- 1
src/views/fileHistoryView.ts Просмотреть файл

@ -21,7 +21,7 @@ export class FileHistoryView extends ViewBase {
}
protected registerCommands() {
Container.viewCommands;
void Container.viewCommands;
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(), this);
commands.registerCommand(
this.getQualifiedCommand('refreshNode'),

+ 1
- 1
src/views/lineHistoryView.ts Просмотреть файл

@ -21,7 +21,7 @@ export class LineHistoryView extends ViewBase {
}
protected registerCommands() {
Container.viewCommands;
void Container.viewCommands;
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(), this);
commands.registerCommand(
this.getQualifiedCommand('refreshNode'),

+ 2
- 2
src/views/nodes/repositoriesNode.ts Просмотреть файл

@ -76,7 +76,7 @@ export class RepositoriesNode extends SubscribeableViewNode {
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));
@ -133,7 +133,7 @@ export class RepositoriesNode extends SubscribeableViewNode {
parent = parent.getParent();
}
this.view.reveal(node);
void this.view.reveal(node);
}
catch (ex) {
Logger.error(ex);

+ 1
- 1
src/views/nodes/viewNode.ts Просмотреть файл

@ -143,7 +143,7 @@ export abstract class SubscribeableViewNode extends ViewNode
@debug()
dispose() {
this.unsubscribe();
void this.unsubscribe();
if (this._disposable !== undefined) {
this._disposable.dispose();

+ 1
- 1
src/views/repositoriesView.ts Просмотреть файл

@ -27,7 +27,7 @@ export class RepositoriesView extends ViewBase {
}
protected registerCommands() {
Container.viewCommands;
void Container.viewCommands;
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(), this);
commands.registerCommand(

+ 1
- 1
src/views/resultsView.ts Просмотреть файл

@ -33,7 +33,7 @@ export class ResultsView extends ViewBase {
}
protected registerCommands() {
Container.viewCommands;
void Container.viewCommands;
commands.registerCommand(this.getQualifiedCommand('refresh'), () => this.refresh(), this);
commands.registerCommand(
this.getQualifiedCommand('refreshNode'),

+ 4
- 4
src/views/viewCommands.ts Просмотреть файл

@ -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) {

Загрузка…
Отмена
Сохранить