Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Additional changes for linter (#167)
Browse files Browse the repository at this point in the history
* Additional changes for linter

* Initial values of Git and Wit should be '-' and not '0'

* Ensure at least 1 change for UndoAll
  • Loading branch information
Jeff Young authored Apr 7, 2017
1 parent a27d387 commit 6fe4578
Show file tree
Hide file tree
Showing 36 changed files with 129 additions and 105 deletions.
19 changes: 10 additions & 9 deletions src/clients/gitclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class GitClient extends BaseClient {
let requests: BaseQuickPickItem[] = await this.getMyPullRequests();
this._statusBarItem.tooltip = Strings.BrowseYourPullRequests;
//Remove the default Strings.BrowseYourPullRequests item from the calculation
this._statusBarItem.text = GitClient.GetPullRequestStatusText(requests.length - 1);
this._statusBarItem.text = GitClient.GetPullRequestStatusText((requests.length - 1).toString());
} catch (err) {
this.handleError(err, GitClient.GetOfflinePullRequestStatusText(), true, "Attempting to poll my pull requests");
}
Expand All @@ -135,7 +135,7 @@ export class GitClient extends BaseClient {
let label: string = `$(icon ${icon}) `;
requestItems.push({ label: label + Strings.BrowseYourPullRequests, description: undefined, id: undefined });

myPullRequests.forEach(pr => {
myPullRequests.forEach((pr) => {
let score: PullRequestScore = GitVcService.GetPullRequestScore(pr);
requestItems.push(this.getPullRequestLabel(pr.createdBy.displayName, pr.title, pr.description, pr.pullRequestId.toString(), score));
requestIds.push(pr.pullRequestId);
Expand All @@ -145,7 +145,7 @@ export class GitClient extends BaseClient {
Logger.LogInfo("Getting pull requests for which I'm a reviewer...");
//Go get the active pull requests that I'm a reviewer for
let myReviewPullRequests: GitPullRequest[] = await svc.GetPullRequests(this._serverContext.RepoInfo.RepositoryId, undefined, this._serverContext.UserInfo.Id, PullRequestStatus.Active);
myReviewPullRequests.forEach(pr => {
myReviewPullRequests.forEach((pr) => {
let score: PullRequestScore = GitVcService.GetPullRequestScore(pr);
if (requestIds.indexOf(pr.pullRequestId) < 0) {
requestItems.push(this.getPullRequestLabel(pr.createdBy.displayName, pr.title, pr.description, pr.pullRequestId.toString(), score));
Expand All @@ -154,7 +154,7 @@ export class GitClient extends BaseClient {
Logger.LogInfo("Retrieved " + myReviewPullRequests.length + " pull requests that I'm the reviewer");

//Remove the default Strings.BrowseYourPullRequests item from the calculation
this._statusBarItem.text = GitClient.GetPullRequestStatusText(requestItems.length - 1);
this._statusBarItem.text = GitClient.GetPullRequestStatusText((requestItems.length - 1).toString());
this._statusBarItem.tooltip = Strings.BrowseYourPullRequests;
this._statusBarItem.command = CommandNames.GetPullRequests;

Expand All @@ -178,14 +178,15 @@ export class GitClient extends BaseClient {
}

public static GetOfflinePullRequestStatusText() : string {
return `$(icon octicon-git-pull-request) ` + `???`;
return `$(icon octicon-git-pull-request) ???`;
}

//Sets the text on the pull request status bar
public static GetPullRequestStatusText(total: number) : string {
let octipullrequest: string = "octicon-git-pull-request";

return `$(icon ${octipullrequest}) ` + total.toString();
public static GetPullRequestStatusText(total?: string) : string {
if (!total) {
return `$(icon octicon-git-pull-request) $(icon octicon-dash)`;
}
return `$(icon octicon-git-pull-request) ${total.toString()}`;
}

//Ensure that we don't accidentally send non-Git (e.g., TFVC) contexts to the Git client
Expand Down
4 changes: 2 additions & 2 deletions src/clients/teamservicesclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class TeamServicesApi extends basem.ClientApiBase {
//Create an instance of Promise since we're calling a function with the callback pattern but want to return a Promise
let promise: Promise<any> = new Promise<any>((resolve, reject) => {
/* tslint:disable:no-null-keyword */
this.restClient.getJson(this.vsoClient.resolveUrl("/vsts/info"), "", null, null, function(err: any, statusCode: number, obj: any) {
this.restClient.getJson(this.vsoClient.resolveUrl("/vsts/info"), "", null, null, (err: any, statusCode: number, obj: any) => {
/* tslint:enable:no-null-keyword */
if (err) {
err.statusCode = statusCode;
Expand All @@ -34,7 +34,7 @@ export class TeamServicesApi extends basem.ClientApiBase {
//Create an instance of Promise since we're calling a function with the callback pattern but want to return a Promise
let promise: Promise<any> = new Promise<any>((resolve, reject) => {
/* tslint:disable:no-null-keyword */
this.restClient.getJson(this.vsoClient.resolveUrl("_apis/tfvc/branches"), "", null, null, function(err: any, statusCode: number, obj: any) {
this.restClient.getJson(this.vsoClient.resolveUrl("_apis/tfvc/branches"), "", null, null, (err: any, statusCode: number, obj: any) => {
/* tslint:enable:no-null-keyword */
if (err) {
err.statusCode = statusCode;
Expand Down
21 changes: 11 additions & 10 deletions src/clients/witclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class WitClient extends BaseClient {
Logger.LogInfo("Getting my work item queries (" + this._serverContext.RepoInfo.TeamProject + ")...");
let hierarchyItems: QueryHierarchyItem[] = await svc.GetWorkItemHierarchyItems(this._serverContext.RepoInfo.TeamProject);
Logger.LogInfo("Retrieved " + hierarchyItems.length + " hierarchyItems");
hierarchyItems.forEach(folder => {
hierarchyItems.forEach((folder) => {
if (folder && folder.isFolder === true && folder.isPublic === false) {
// Because "My Queries" is localized and there is no API to get the name of the localized
// folder, we need to save off the localized name when constructing URLs.
Expand All @@ -199,7 +199,7 @@ export class WitClient extends BaseClient {
Logger.LogInfo("Getting my work items (" + this._serverContext.RepoInfo.TeamProject + ")...");
let simpleWorkItems: SimpleWorkItem[] = await svc.GetWorkItems(teamProject, wiql);
Logger.LogInfo("Retrieved " + simpleWorkItems.length + " work items");
simpleWorkItems.forEach(wi => {
simpleWorkItems.forEach((wi) => {
workItems.push({ label: wi.label, description: wi.description, id: wi.id});
});
if (simpleWorkItems.length === WorkItemTrackingService.MaxResults) {
Expand Down Expand Up @@ -229,7 +229,7 @@ export class WitClient extends BaseClient {
let svc: WorkItemTrackingService = new WorkItemTrackingService(this._serverContext);
let types: WorkItemType[] = await svc.GetWorkItemTypes(this._serverContext.RepoInfo.TeamProject);
let workItemTypes: BaseQuickPickItem[] = [];
types.forEach(type => {
types.forEach((type) => {
workItemTypes.push({ label: type.name, description: type.description, id: undefined });
});
workItemTypes.sort((t1, t2) => {
Expand All @@ -252,21 +252,22 @@ export class WitClient extends BaseClient {
}

public PollPinnedQuery(): void {
this.GetPinnedQueryResultCount().then((items) => {
this.GetPinnedQueryResultCount().then((numberOfItems) => {
this._statusBarItem.tooltip = Strings.ViewYourPinnedQuery;
this._statusBarItem.text = WitClient.GetPinnedQueryStatusText(items);
this._statusBarItem.text = WitClient.GetPinnedQueryStatusText(numberOfItems.toString());
}).catch((err) => {
this.handleError(err, WitClient.GetOfflinePinnedQueryStatusText(), true, "Failed to get pinned query count during polling");
});
}

public static GetOfflinePinnedQueryStatusText() : string {
return `$(icon octicon-bug) ` + `???`;
return `$(icon octicon-bug) ???`;
}

public static GetPinnedQueryStatusText(total: number) : string {
let octibug: string = "octicon-bug";

return `$(icon ${octibug}) ` + total.toString();
public static GetPinnedQueryStatusText(total?: string) : string {
if (!total) {
return `$(icon octicon-bug) $(icon octicon-dash)`;
}
return `$(icon octicon-bug) ${total.toString()}`;
}
}
1 change: 1 addition & 0 deletions src/helpers/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class Strings {
static TfNoPendingChanges: string = "There are no matching pending changes.";
static UndoChanges: string = "Undo Changes";
static NoChangesToCheckin: string = "There are no changes to check in. Changes must be added to the 'Included' section to be checked in.";
static NoChangesToUndo: string = "There are no changes to undo.";
static AllFilesUpToDate: string = "All files are up to date.";
static CommandRequiresFileContext: string = "This command requires a file context and can only be executed from the TFVC viewlet window.";
static CommandRequiresExplorerContext: string = "This command requires a file context and can only be executed from the Explorer window.";
Expand Down
6 changes: 3 additions & 3 deletions src/services/gitvc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ export class GitVcService {
this._gitApi = new WebApi(context.RepoInfo.CollectionUrl, CredentialManager.GetCredentialHandler()).getGitApi();
}

//Returns a Q.Promise containing an array of GitPullRequest objectss for the creator and repository
//Returns a Promise containing an array of GitPullRequest objectss for the creator and repository
//If creatorId is undefined, all pull requests will be returned
public async GetPullRequests(repositoryId: string, creatorId?: string, reviewerId?: string, status?: PullRequestStatus) : Promise<GitPullRequest[]> {
let criteria: GitPullRequestSearchCriteria = { creatorId: creatorId, includeLinks: false, repositoryId: repositoryId, reviewerId: reviewerId,
sourceRefName: undefined, status: status, targetRefName: undefined };
return await this._gitApi.getPullRequests(repositoryId, criteria);
}

//Returns a Q.Promise containing an array of GitRepository objects for the project
//Returns a Promise containing an array of GitRepository objects for the project
public async GetRepositories(project: string): Promise<GitRepository[]> {
return await this._gitApi.getRepositories(project, false);
}
Expand Down Expand Up @@ -96,7 +96,7 @@ export class GitVcService {
let lowestVote: number = 0;
let highestVote: number = 0;
if (pullRequest.reviewers !== undefined && pullRequest.reviewers.length > 0) {
pullRequest.reviewers.forEach(reviewer => {
pullRequest.reviewers.forEach((reviewer) => {
let vote: number = reviewer.vote;
if (vote < lowestVote) {
lowestVote = vote;
Expand Down
6 changes: 3 additions & 3 deletions src/services/workitemtracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export class WorkItemTrackingService {
let types: WorkItemType[] = await this._witApi.getWorkItemTypes(teamProject);
let workItemTypes: WorkItemType[] = [];
let hiddenTypes: WorkItemTypeReference[] = [];
types.forEach(type => {
types.forEach((type) => {
workItemTypes.push(type);
});
let category: WorkItemTypeCategory = await this._witApi.getWorkItemTypeCategory(teamProject, "Microsoft.HiddenCategory");
category.workItemTypes.forEach(hiddenType => {
category.workItemTypes.forEach((hiddenType) => {
hiddenTypes.push(hiddenType);
});
let filteredTypes: WorkItemType[] = workItemTypes.filter(function (el) {
Expand Down Expand Up @@ -111,7 +111,7 @@ export class WorkItemTrackingService {

//Keep original sort order that wiql specified
for (let index = 0; index < workItemIds.length; index++) {
let item: WorkItem = workItems.find(i => i.id === workItemIds[index]);
let item: WorkItem = workItems.find((i) => i.id === workItemIds[index]);
results.push({
id: item.fields[WorkItemFields.Id],
label: item.fields[WorkItemFields.Id] + " [" + item.fields[WorkItemFields.WorkItemType] + "]",
Expand Down
6 changes: 3 additions & 3 deletions src/team-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export class TeamExtension {
if (!this._pullRequestStatusBarItem) {
this._pullRequestStatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left, 99);
this._pullRequestStatusBarItem.command = CommandNames.GetPullRequests;
this._pullRequestStatusBarItem.text = GitClient.GetPullRequestStatusText(0);
this._pullRequestStatusBarItem.text = GitClient.GetPullRequestStatusText();
this._pullRequestStatusBarItem.tooltip = Strings.BrowseYourPullRequests;
this._pullRequestStatusBarItem.show();
}
Expand All @@ -327,15 +327,15 @@ export class TeamExtension {
if (!this._buildStatusBarItem) {
this._buildStatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left, 98);
this._buildStatusBarItem.command = CommandNames.OpenBuildSummaryPage;
this._buildStatusBarItem.text = `$(icon octicon-package) ` + `$(icon octicon-dash)`;
this._buildStatusBarItem.text = `$(icon octicon-package) $(icon octicon-dash)`;
this._buildStatusBarItem.tooltip = Strings.NoBuildsFound;
this._buildStatusBarItem.show();
}

if (!this._pinnedQueryStatusBarItem) {
this._pinnedQueryStatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left, 97);
this._pinnedQueryStatusBarItem.command = CommandNames.ViewPinnedQueryWorkItems;
this._pinnedQueryStatusBarItem.text = WitClient.GetPinnedQueryStatusText(0);
this._pinnedQueryStatusBarItem.text = WitClient.GetPinnedQueryStatusText();
this._pinnedQueryStatusBarItem.tooltip = Strings.ViewYourPinnedQuery;
this._pinnedQueryStatusBarItem.show();
}
Expand Down
4 changes: 2 additions & 2 deletions src/tfvc/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export class Add implements ITfvcCommand<string[]> {
let lines: string[] = CommandHelper.SplitIntoLines(executionResult.stdout, false, true /*filterEmptyLines*/);

//Remove any lines indicating that there were no files to add (e.g., calling add on files that don't exist)
lines = lines.filter(e => !e.startsWith("No arguments matched any files to add.")); //CLC
lines = lines.filter((e) => !e.startsWith("No arguments matched any files to add.")); //CLC
//Ex. /usr/alias/repos/Tfvc.L2VSCodeExtension.RC/file-does-not-exist.md: No file matches.
lines = lines.filter(e => !e.endsWith(" No file matches.")); //tf.exe
lines = lines.filter((e) => !e.endsWith(" No file matches.")); //tf.exe

let filesAdded: string[] = [];
let path: string = "";
Expand Down
2 changes: 1 addition & 1 deletion src/tfvc/commands/commandhelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class CommandHelper {
lines = lines.splice(index);
}
if (filterEmptyLines) {
lines = lines.filter(e => e.trim() !== "");
lines = lines.filter((e) => e.trim() !== "");
}
return lines;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tfvc/commands/getinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class GetInfo implements ITfvcCommand<IItemInfo[]> {

// If all of the info objects are "empty" let's report an error
if (itemInfos.length > 0 &&
itemInfos.length === itemInfos.filter(info => info.localItem === undefined).length) {
itemInfos.length === itemInfos.filter((info) => info.localItem === undefined).length) {
throw new TfvcError({
message: Strings.NoMatchesFound,
tfvcErrorCode: TfvcErrorCodes.TfvcNoItemsMatch,
Expand Down
4 changes: 2 additions & 2 deletions src/tfvc/commands/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ export class Sync implements ITfvcCommand<ISyncResults> {
const itemResults: ISyncItemResult[] = this.getItemResults(executionResult.stdout);
const errorMessages: ISyncItemResult[] = this.getErrorMessages(executionResult.stderr);
return {
hasConflicts: errorMessages.filter(err => err.syncType === SyncType.Conflict).length > 0,
hasErrors: errorMessages.filter(err => err.syncType !== SyncType.Conflict).length > 0,
hasConflicts: errorMessages.filter((err) => err.syncType === SyncType.Conflict).length > 0,
hasErrors: errorMessages.filter((err) => err.syncType !== SyncType.Conflict).length > 0,
itemResults: itemResults.concat(errorMessages)
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/tfvc/commands/undo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class Undo implements ITfvcCommand<string[]> {
//Otherwise, we assume some error occurred so let that be thrown.
if (executionResult.exitCode !== 0) {
//Remove any entries for which there were no pending changes
lines = lines.filter(e => !e.startsWith("No pending changes "));
lines = lines.filter((e) => !e.startsWith("No pending changes "));
if (executionResult.exitCode === 100 && lines.length === 0) {
//All of the files had no pending changes, return []
return [];
Expand Down
10 changes: 5 additions & 5 deletions src/tfvc/scm/commithoverprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class CommitHoverProvider implements HoverProvider {
}

private onVisibleTextEditors(editors: TextEditor[]): void {
const [editor] = editors.filter(e => isSCMInput(e.document.uri));
const [editor] = editors.filter((e) => isSCMInput(e.document.uri));

if (!editor) {
return;
Expand All @@ -71,7 +71,7 @@ export class CommitHoverProvider implements HoverProvider {
this.visibleTextEditorsDisposable.dispose();
this.editor = editor;

const onDidChange = filterEvent(workspace.onDidChangeTextDocument, e => e.document && isSCMInput(e.document.uri));
const onDidChange = filterEvent(workspace.onDidChangeTextDocument, (e) => e.document && isSCMInput(e.document.uri));
onDidChange(this.update, this, this.disposables);

workspace.onDidChangeConfiguration(this.update, this, this.disposables);
Expand All @@ -81,12 +81,12 @@ export class CommitHoverProvider implements HoverProvider {
private update(): void {
this.diagnostics = [];
//TODO provide any diagnostic info based on the message here (see git commitcontroller)
this.editor.setDecorations(this.decorationType, this.diagnostics.map(d => d.range));
this.editor.setDecorations(this.decorationType, this.diagnostics.map((d) => d.range));
}

/* Implement HoverProvider */
provideHover(document: TextDocument, position: Position): Hover | undefined {
const [decoration] = this.diagnostics.filter(d => d.range.contains(position));
const [decoration] = this.diagnostics.filter((d) => d.range.contains(position));

if (!decoration || !document) {
return;
Expand All @@ -96,6 +96,6 @@ export class CommitHoverProvider implements HoverProvider {
}

dispose(): void {
this.disposables.forEach(d => d.dispose());
this.disposables.forEach((d) => d.dispose());
}
}
Loading

0 comments on commit 6fe4578

Please sign in to comment.