Skip to content

Commit e9dd1ce

Browse files
committed
more undefined
1 parent e092610 commit e9dd1ce

File tree

8 files changed

+24
-32
lines changed

8 files changed

+24
-32
lines changed

src/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function registerCommands(context: vscode.ExtensionContext, prManager: Pu
9999
// Reset HEAD and then apply reverse diff
100100
await vscode.commands.executeCommand('git.unstageAll');
101101

102-
if (vscode.workspace.rootPath === undefined) {
102+
if (!vscode.workspace.rootPath) {
103103
throw new Error('Current workspace root path is undefined.');
104104
}
105105

src/common/diffPositionMapping.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ export function getPositionInDiff(comment: Comment, fileDiffHunks: DiffHunk[], i
7272
return commentAbsolutePosition;
7373
}
7474

75-
export function getLastDiffLine(prPatch: string): DiffLine | null {
76-
let lastDiffLine = null;
75+
export function getLastDiffLine(prPatch: string): DiffLine | undefined {
76+
let lastDiffLine = undefined;
7777
let prDiffReader = parseDiffHunk(prPatch);
7878
let prDiffIter = prDiffReader.next();
7979

@@ -87,7 +87,7 @@ export function getLastDiffLine(prPatch: string): DiffLine | null {
8787
return lastDiffLine;
8888
}
8989

90-
export function getDiffLineByPosition(diffHunks: DiffHunk[], diffLineNumber: number): DiffLine | null {
90+
export function getDiffLineByPosition(diffHunks: DiffHunk[], diffLineNumber: number): DiffLine | undefined {
9191
for (let i = 0; i < diffHunks.length; i++) {
9292
let diffHunk = diffHunks[i];
9393
for (let j = 0; j < diffHunk.diffLines.length; j++) {
@@ -97,7 +97,7 @@ export function getDiffLineByPosition(diffHunks: DiffHunk[], diffLineNumber: num
9797
}
9898
}
9999

100-
return null;
100+
return undefined;
101101
}
102102

103103
export function mapHeadLineToDiffHunkPosition(diffHunks: DiffHunk[], localDiff: string, line: number, isBase: boolean = false): number {

src/common/protocol.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class Protocol {
9797
let lastIndex = normalized.lastIndexOf('/');
9898
let lastSegment = normalized.substr(lastIndex + 1);
9999
if (lastSegment === '' || lastSegment === '/') {
100-
return null;
100+
return;
101101
}
102102

103103
return lastSegment.replace(/\/$/, '').replace(/\.git$/, '');
@@ -114,12 +114,12 @@ export class Protocol {
114114
return fragments[fragments.length - 2];
115115
}
116116

117-
return null;
117+
return;
118118
}
119119

120-
normalizeUri(): vscode.Uri | null {
120+
normalizeUri(): vscode.Uri | undefined {
121121
if (this.type === ProtocolType.OTHER && !this.url) {
122-
return null;
122+
return;
123123
}
124124

125125
if (this.type === ProtocolType.Local) {
@@ -134,11 +134,11 @@ export class Protocol {
134134
try {
135135
return vscode.Uri.parse(`${scheme}://${this.host.toLocaleLowerCase()}/${this.nameWithOwner.toLocaleLowerCase()}`);
136136
} catch (e) {
137-
return null;
137+
return;
138138
}
139139
}
140140

141-
toString(): string | null {
141+
toString(): string | undefined {
142142
// based on Uri scheme for SSH https://tools.ietf.org/id/draft-salowey-secsh-uri-00.html#anchor1 and heuristics of how GitHub handles ssh url
143143
// sshUri = `ssh:`
144144
// - omitted
@@ -163,7 +163,7 @@ export class Protocol {
163163
return normalizedUri.toString();
164164
}
165165

166-
return null;
166+
return;
167167
}
168168

169169
update(change: { type?: ProtocolType; host?: string; owner?: string; repositoryName?: string; }): Protocol {

src/common/ssh.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,18 @@ export class Resolvers {
6868
static current = Resolvers.default;
6969
}
7070

71-
const parse = (url: string): Config | null => {
71+
const parse = (url: string): Config | undefined => {
7272
const urlMatch = URL_SCHEME_RE.exec(url);
7373
if (urlMatch) {
7474
const [fullSchemePrefix, scheme] = urlMatch;
7575
if (scheme === 'ssh') {
7676
url = url.slice(fullSchemePrefix.length);
7777
} else {
78-
return null;
78+
return;
7979
}
8080
}
8181
const match = SSH_URL_RE.exec(url);
82-
if (!match) { return null; }
82+
if (!match) { return; }
8383
const [, User, Host, path] = match;
8484
return {User, Host, path};
8585
};

src/github/githubRepository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class GitHubRepository implements IGitHubRepository {
3030
private _metadata: any;
3131

3232
public get hub(): GitHub {
33-
if (this._hub === undefined) {
33+
if (!this._hub) {
3434
if (!this._initialized) {
3535
throw new Error('Call ensure() before accessing this property.');
3636
} else {

src/github/pullRequestOverview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ export class PullRequestOverviewPanel {
262262
const comment = message.args.comment;
263263
const regex = /```diff\n([\s\S]*)\n```/g;
264264
const matches = regex.exec(comment.body);
265-
if (vscode.workspace.rootPath === undefined) {
265+
if (!vscode.workspace.rootPath) {
266266
throw new Error('Current workspace rootpath is undefined.');
267267
}
268268
const tempFilePath = path.resolve(vscode.workspace.rootPath, '.git', `${comment.id}.diff`);

src/view/prChangesTreeDataProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class PullRequestChangesTreeDataProvider extends vscode.Disposable implem
101101

102102
if (fileChange) {
103103
await this.reveal(fileChange, { focus: true, expand: 2 });
104-
if (fileChange.command.arguments === undefined) {
104+
if (!fileChange.command.arguments) {
105105
return;
106106
}
107107
if (fileChange instanceof GitFileChangeNode) {

src/view/treeNodes/pullRequestNode.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,14 @@ export function providePRDocumentComments(
2828
inDraftMode: boolean) {
2929
const params = fromPRUri(document.uri);
3030

31-
if (!params) {
32-
return undefined;
33-
}
34-
35-
if (params.prNumber !== prNumber) {
36-
return undefined;
31+
if (!params || params.prNumber !== prNumber) {
32+
return;
3733
}
3834

3935
const isBase = params.isBase;
4036
const fileChange = fileChanges.find(change => change.fileName === params.fileName);
41-
if (!fileChange) {
42-
return undefined;
43-
}
44-
45-
if (fileChange instanceof RemoteFileChangeNode) {
46-
return undefined;
37+
if (!fileChange || fileChange instanceof RemoteFileChangeNode) {
38+
return;
4739
}
4840

4941
let commentingRanges: vscode.Range[] = [];
@@ -245,7 +237,7 @@ export class PRNode extends TreeNode {
245237
const comments = await this._prManager.getPullRequestComments(this.pullRequestModel);
246238
const data = await this._prManager.getPullRequestFileChangesInfo(this.pullRequestModel);
247239
const mergeBase = this.pullRequestModel.mergeBase;
248-
if (mergeBase === undefined) {
240+
if (!mergeBase) {
249241
return [];
250242
}
251243

@@ -334,7 +326,7 @@ export class PRNode extends TreeNode {
334326

335327
if (fileChange) {
336328
await this.reveal(fileChange, { focus: true });
337-
if (fileChange.command.arguments === undefined) {
329+
if (!fileChange.command.arguments) {
338330
return;
339331
}
340332
if (fileChange instanceof InMemFileChangeNode) {

0 commit comments

Comments
 (0)