Browse Source

Fixes a few more LGTM static analysis alerts

main
Eric Amodio 5 years ago
parent
commit
61d9543255
4 changed files with 9 additions and 14 deletions
  1. +1
    -1
      src/avatars.ts
  2. +5
    -10
      src/commands/common.ts
  3. +2
    -2
      src/quickpicks/referencesQuickPick.ts
  4. +1
    -1
      src/views/nodes/commitFileNode.ts

+ 1
- 1
src/avatars.ts View File

@ -11,7 +11,7 @@ const missingGravatarHash = '00000000000000000000000000000000';
const presenceCache = new Map<ContactPresenceStatus, string>();
const gitHubNoReplyAddressRegex = /^(?:(?<userId>\d+)\+)?(?<userName>[a-zA-Z\d-]{1,39})@users.noreply.github.com$/;
const gitHubNoReplyAddressRegex = /^(?:(?<userId>\d+)\+)?(?<userName>[a-zA-Z\d-]{1,39})@users\.noreply\.github\.com$/;
export function clearAvatarCache() {
avatarCache.clear();

+ 5
- 10
src/commands/common.ts View File

@ -352,15 +352,6 @@ function isScmResourceState(state: any): state is SourceControlResourceState {
return (state as SourceControlResourceState).resourceUri != null;
}
function isTextEditor(editor: any | undefined): editor is TextEditor {
if (editor == null) return false;
return (
editor.id !== undefined &&
((editor as TextEditor).edit !== undefined || (editor as TextEditor).document !== undefined)
);
}
export abstract class Command implements Disposable {
static getMarkdownCommandArgsCore<T>(command: Commands, args: T): string {
return `command:${command}?${encodeURIComponent(JSON.stringify(args))}`;
@ -412,7 +403,11 @@ export abstract class Command implements Disposable {
let editor: TextEditor | undefined = undefined;
let firstArg = args[0];
if (options.editor && (firstArg == null || isTextEditor(firstArg))) {
if (
options.editor &&
(firstArg == null || (firstArg.id != null && firstArg.document != null && firstArg.document.uri != null))
) {
editor = firstArg;
args = args.slice(1);
firstArg = args[0];

+ 2
- 2
src/quickpicks/referencesQuickPick.ts View File

@ -156,13 +156,13 @@ export class ReferencesQuickPick {
include & ReferencesQuickPickIncludes.Branches
? Container.git.getBranches(this.repoPath, {
...options,
filter: filterBranches && filterBranches
filter: filterBranches
})
: undefined,
include & ReferencesQuickPickIncludes.Tags
? Container.git.getTags(this.repoPath, {
...options,
filter: filterTags && filterTags,
filter: filterTags,
includeRefs: true
})
: undefined

+ 1
- 1
src/views/nodes/commitFileNode.ts View File

@ -142,7 +142,7 @@ export class CommitFileNode extends ViewRefFileNode {
if (this._tooltip === undefined) {
if (this._options.displayAsCommit) {
// eslint-disable-next-line no-template-curly-in-string
const status = StatusFileFormatter.fromTemplate('${status}${ (originalPath)}', this.file);
const status = StatusFileFormatter.fromTemplate('${status}${ (originalPath)}', this.file); // lgtm [js/template-syntax-in-string-literal]
this._tooltip = CommitFormatter.fromTemplate(
this.commit.isUncommitted
? `\${author} ${GlyphChars.Dash} \${id}\n${status}\n\${ago} (\${date})`

Loading…
Cancel
Save