Преглед на файлове

Fixes static analysis issues

main
Eric Amodio преди 5 години
родител
ревизия
4d9ed4e445
променени са 18 файла, в които са добавени 44 реда и са изтрити 51 реда
  1. +4
    -5
      src/commands/closeUnchangedFiles.ts
  2. +1
    -1
      src/commands/common.ts
  3. +4
    -5
      src/commands/openChangedFiles.ts
  4. +7
    -9
      src/git/gitService.ts
  5. +1
    -1
      src/git/parsers/blameParser.ts
  6. +2
    -2
      src/git/parsers/branchParser.ts
  7. +3
    -3
      src/git/parsers/diffParser.ts
  8. +4
    -4
      src/git/parsers/logParser.ts
  9. +2
    -2
      src/git/parsers/reflogParser.ts
  10. +2
    -2
      src/git/parsers/remoteParser.ts
  11. +2
    -2
      src/git/parsers/shortlogParser.ts
  12. +3
    -3
      src/git/parsers/tagParser.ts
  13. +2
    -2
      src/git/parsers/treeParser.ts
  14. +1
    -5
      src/logger.ts
  15. +1
    -1
      src/system/decorators/memoize.ts
  16. +4
    -2
      src/system/string.ts
  17. +1
    -1
      src/views/nodes/statusFileNode.ts
  18. +0
    -1
      webpack.config.js

+ 4
- 5
src/commands/closeUnchangedFiles.ts Целия файл

@ -6,22 +6,21 @@ import { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Functions } from '../system';
import { ActiveEditorCommand, command, Commands, getCommandUri, getRepoPathOrPrompt } from './common';
import { Command, command, Commands, getRepoPathOrPrompt } from './common';
export interface CloseUnchangedFilesCommandArgs {
uris?: Uri[];
}
@command()
export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
export class CloseUnchangedFilesCommand extends Command {
private _onEditorChangedFn: ((editor: TextEditor | undefined) => void) | undefined;
constructor() {
super(Commands.CloseUnchangedFiles);
}
async execute(editor?: TextEditor, uri?: Uri, args?: CloseUnchangedFilesCommandArgs) {
uri = getCommandUri(uri, editor);
async execute(args?: CloseUnchangedFilesCommandArgs) {
args = { ...args };
try {
@ -46,7 +45,7 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
)
);
editor = window.activeTextEditor;
let editor = window.activeTextEditor;
let count = 0;
let loopCount = 0;

+ 1
- 1
src/commands/common.ts Целия файл

@ -352,7 +352,7 @@ function isScmResourceState(state: any): state is SourceControlResourceState {
return (state as SourceControlResourceState).resourceUri != null;
}
function isTextEditor(editor: any): editor is TextEditor {
function isTextEditor(editor: any | undefined): editor is TextEditor {
if (editor == null) return false;
return (

+ 4
- 5
src/commands/openChangedFiles.ts Целия файл

@ -1,24 +1,23 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { Uri, window } from 'vscode';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Arrays } from '../system';
import { ActiveEditorCommand, command, Commands, getCommandUri, getRepoPathOrPrompt, openEditor } from './common';
import { Command, command, Commands, getRepoPathOrPrompt, openEditor } from './common';
export interface OpenChangedFilesCommandArgs {
uris?: Uri[];
}
@command()
export class OpenChangedFilesCommand extends ActiveEditorCommand {
export class OpenChangedFilesCommand extends Command {
constructor() {
super(Commands.OpenChangedFiles);
}
async execute(editor?: TextEditor, uri?: Uri, args?: OpenChangedFilesCommandArgs) {
uri = getCommandUri(uri, editor);
async execute(args?: OpenChangedFilesCommandArgs) {
args = { ...args };
try {

+ 7
- 9
src/git/gitService.ts Целия файл

@ -225,11 +225,10 @@ export class GitService implements Disposable {
}
private onAnyRepositoryChanged(repo: Repository, reason: RepositoryChange) {
this._trackedCache.clear();
this._branchesCache.delete(repo.path);
this._tagsCache.delete(repo.path);
this._tagsWithRefsCache.clear();
this._trackedCache.clear();
if (reason === RepositoryChange.Config) {
this._userMapCache.delete(repo.path);
@ -1150,13 +1149,13 @@ export class GitService implements Disposable {
include === 'all' || include === 'branches'
? this.getBranches(repoPath, {
...options,
filter: filterBranches && filterBranches
filter: filterBranches
})
: undefined,
include === 'all' || include === 'tags'
? this.getTags(repoPath, {
...options,
filter: filterTags && filterTags
filter: filterTags
})
: undefined
]);
@ -1266,7 +1265,7 @@ export class GitService implements Disposable {
let key: string;
let value: string;
let match: RegExpExecArray | null;
let match;
do {
match = userConfigRegex.exec(data);
if (match == null) break;
@ -1274,7 +1273,7 @@ export class GitService implements Disposable {
[, key, value] = match;
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
user[key as 'name' | 'email'] = ` ${value}`.substr(1);
} while (match != null);
} while (true);
const author = `${user.name} <${user.email}>`;
// Check if there is a mailmap for the current user
@ -2594,7 +2593,6 @@ export class GitService implements Disposable {
return GitUri.resolveToUri(fileName, repoPath);
}
ref = renamedRef;
fileName = renamedFile;
} while (true);
}
@ -2923,7 +2921,7 @@ export class GitService implements Disposable {
}
}
}
} while (match != null);
} while (true);
return operations;
}
@ -2956,6 +2954,6 @@ export class GitService implements Disposable {
} else {
values.push(value);
}
} while (match != null);
} while (true);
}
}

+ 1
- 1
src/git/parsers/blameParser.ts Целия файл

@ -43,7 +43,7 @@ export class GitBlameParser {
const commits: Map<string, GitBlameCommit> = new Map();
const lines: GitCommitLine[] = [];
let relativeFileName = repoPath && fileName;
let relativeFileName;
let entry: BlameEntry | undefined = undefined;
let line: string;

+ 2
- 2
src/git/parsers/branchParser.ts Целия файл

@ -34,7 +34,7 @@ export class GitBranchParser {
let remote;
let match: RegExpExecArray | null;
let match;
do {
match = branchWithTrackingRegex.exec(data);
if (match == null) break;
@ -66,7 +66,7 @@ export class GitBranchParser {
Number(behind) || 0
)
);
} while (match != null);
} while (true);
return branches;
}

+ 3
- 3
src/git/parsers/diffParser.ts Целия файл

@ -19,7 +19,7 @@ export class GitDiffParser {
let currentCount;
let hunk;
let match: RegExpExecArray | null;
let match;
do {
match = unifiedDiffRegex.exec(`${data}\n@@`);
if (match == null) break;
@ -43,7 +43,7 @@ export class GitDiffParser {
}
)
);
} while (match != null);
} while (true);
if (!hunks.length) return undefined;
@ -147,7 +147,7 @@ export class GitDiffParser {
? undefined
: ` ${originalFileName}`.substr(1)
});
} while (match != null);
} while (true);
return files;
}

+ 4
- 4
src/git/parsers/logParser.ts Целия файл

@ -221,8 +221,8 @@ export class GitLogParser {
entry.status = 'R';
}
next = lines.next();
next = lines.next();
void lines.next();
void lines.next();
next = lines.next();
match = diffRangeRegex.exec(next.value);
@ -463,7 +463,7 @@ export class GitLogParser {
let file;
let renamed;
let match: RegExpExecArray | null;
let match;
do {
match = logFileSimpleRegex.exec(data);
if (match == null) break;
@ -518,7 +518,7 @@ export class GitLogParser {
status = status == null || status.length === 0 ? undefined : ` ${status}`.substr(1);
break;
} while (match != null);
} while (true);
// Ensure the regex state is reset
logFileSimpleRenamedFilesRegex.lastIndex = 0;

+ 2
- 2
src/git/parsers/reflogParser.ts Целия файл

@ -40,7 +40,7 @@ export class GitReflogParser {
let record: GitReflogRecord | undefined;
let truncated = false;
let match: RegExpExecArray | null;
let match;
do {
match = reflogRegex.exec(data);
if (match == null) break;
@ -105,7 +105,7 @@ export class GitReflogParser {
);
recordDate = date;
}
} while (match != null);
} while (true);
// Ensure the regex state is reset
reflogRegex.lastIndex = 0;

+ 2
- 2
src/git/parsers/remoteParser.ts Целия файл

@ -70,7 +70,7 @@ export class GitRemoteParser {
let uniqueness;
let remote: GitRemote | undefined;
let match: RegExpExecArray | null;
let match;
do {
match = remoteRegex.exec(data);
if (match == null) break;
@ -105,7 +105,7 @@ export class GitRemoteParser {
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
remote.types.push({ url: url, type: ` ${type}`.substr(1) as GitRemoteType });
}
} while (match != null);
} while (true);
return remotes;
}

+ 2
- 2
src/git/parsers/shortlogParser.ts Целия файл

@ -15,7 +15,7 @@ export class GitShortLogParser {
let name;
let email;
let match: RegExpExecArray | null;
let match;
do {
match = shortlogRegex.exec(data);
if (match == null) break;
@ -32,7 +32,7 @@ export class GitShortLogParser {
Number(count) || 0
)
);
} while (match != null);
} while (true);
return { repoPath: repoPath, contributors: contributors };
}

+ 3
- 3
src/git/parsers/tagParser.ts Целия файл

@ -15,7 +15,7 @@ export class GitTagParser {
let name;
let annotation;
let match: RegExpExecArray | null;
let match;
do {
match = tagWithAnnotationRegex.exec(data);
if (match == null) break;
@ -32,7 +32,7 @@ export class GitTagParser {
annotation == null || annotation.length === 0 ? undefined : ` ${annotation}`.substr(1)
)
);
} while (match != null);
} while (true);
return tags;
}
@ -61,7 +61,7 @@ export class GitTagParser {
` ${sha}`.substr(1)
)
);
} while (match != null);
} while (true);
return tags;
}

+ 2
- 2
src/git/parsers/treeParser.ts Целия файл

@ -17,7 +17,7 @@ export class GitTreeParser {
let size;
let filePath;
let match: RegExpExecArray | null;
let match;
do {
match = treeRegex.exec(data);
if (match == null) break;
@ -33,7 +33,7 @@ export class GitTreeParser {
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
type: (type == null || type.length === 0 ? emptyStr : ` ${type}`.substr(1)) as 'blob' | 'tree'
});
} while (match != null);
} while (true);
return trees;
}

+ 1
- 5
src/logger.ts Целия файл

@ -83,11 +83,7 @@ export class Logger {
if (contextOrMessage === undefined || typeof contextOrMessage === 'string') {
message = contextOrMessage;
} else {
message = params.shift();
if (contextOrMessage !== undefined) {
message = `${contextOrMessage.prefix} ${message || emptyStr}`;
}
message = `${contextOrMessage.prefix} ${params.shift() || emptyStr}`;
}
if (message === undefined) {

+ 1
- 1
src/system/decorators/memoize.ts Целия файл

@ -32,7 +32,7 @@ export function memoize any>(resolver?: (...args: Par
throw new Error('Not supported');
}
if (!fn || !fnKey) throw new Error('Not supported');
if (fn == null) throw new Error('Not supported');
const memoizeKey = `$memoize$${key}`;

+ 4
- 2
src/system/string.ts Целия файл

@ -87,7 +87,7 @@ export namespace Strings {
truncateTo: truncateTo == null ? undefined : parseInt(truncateTo, 10)
}
});
} while (match != null);
} while (true);
return tokens;
}
@ -250,7 +250,9 @@ export namespace Strings {
return `${s.substring(0, chars)}${ellipsis}`;
}
const ansiRegex = /[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))/g;
// Lifted from https://github.com/chalk/ansi-regex
// eslint-disable-next-line no-control-regex
const ansiRegex = /[\u001B\u009B][[\]()#;?]*(?:(?:(?:[a-zA-Z\d]*(?:;[-a-zA-Z\d/#&.:=?%@~_]*)*)?\u0007)|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-ntqry=><~]))/g;
const containsNonAsciiRegex = /[^\x20-\x7F\u00a0\u2026]/;
export function getWidth(s: string): number {

+ 1
- 1
src/views/nodes/statusFileNode.ts Целия файл

@ -34,7 +34,7 @@ export class StatusFileNode extends ViewNode {
ref = undefined;
hasUnstagedChanges = true;
}
} else if (hasUnstagedChanges || hasStagedChanges) {
} else if (hasUnstagedChanges) {
break;
} else {
ref = c.sha;

+ 0
- 1
webpack.config.js Целия файл

@ -3,7 +3,6 @@
const fs = require('fs');
const path = require('path');
const glob = require('glob');
const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const { CleanWebpackPlugin: CleanPlugin } = require('clean-webpack-plugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');

Зареждане…
Отказ
Запис