Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always Be Auditing Your Awaits #1248

Merged
merged 11 commits into from
Apr 7, 2016
3 changes: 1 addition & 2 deletions Octokit/Clients/AssigneesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public async Task<bool> CheckAssignee(string owner, string name, string assignee

try
{
var response = await Connection.Get<object>(ApiUrls.CheckAssignee(owner, name, assignee), null, null)
.ConfigureAwait(false);
var response = await Connection.Get<object>(ApiUrls.CheckAssignee(owner, name, assignee), null, null).ConfigureAwait(false);
return response.HttpResponse.IsTrue();
}
catch (NotFoundException)
Expand Down
16 changes: 5 additions & 11 deletions Octokit/Clients/AuthorizationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,7 @@ public async Task<ApplicationAuthorization> GetOrCreateApplicationAuthentication
{
var endpoint = ApiUrls.AuthorizationsForClient(clientId);

return await ApiConnection.Put<ApplicationAuthorization>(
endpoint,
requestData,
twoFactorAuthenticationCode);
return await ApiConnection.Put<ApplicationAuthorization>(endpoint, requestData, twoFactorAuthenticationCode).ConfigureAwait(false);
}
catch (AuthorizationException e)
{
Expand All @@ -341,15 +338,13 @@ public async Task<ApplicationAuthorization> GetOrCreateApplicationAuthentication
/// <param name="clientId">Client ID of the OAuth application for the token</param>
/// <param name="accessToken">The OAuth token to check</param>
/// <returns>The valid <see cref="ApplicationAuthorization"/>.</returns>
public async Task<ApplicationAuthorization> CheckApplicationAuthentication(string clientId, string accessToken)
public Task<ApplicationAuthorization> CheckApplicationAuthentication(string clientId, string accessToken)
{
Ensure.ArgumentNotNullOrEmptyString(clientId, "clientId");
Ensure.ArgumentNotNullOrEmptyString(accessToken, "accessToken");

var endpoint = ApiUrls.ApplicationAuthorization(clientId, accessToken);
return await ApiConnection.Get<ApplicationAuthorization>(
endpoint,
null);
return ApiConnection.Get<ApplicationAuthorization>(endpoint, null);
}

/// <summary>
Expand All @@ -362,15 +357,14 @@ public async Task<ApplicationAuthorization> CheckApplicationAuthentication(strin
/// <param name="clientId">ClientID of the OAuth application for the token</param>
/// <param name="accessToken">The OAuth token to reset</param>
/// <returns>The valid <see cref="ApplicationAuthorization"/> with a new OAuth token</returns>
public async Task<ApplicationAuthorization> ResetApplicationAuthentication(string clientId, string accessToken)
public Task<ApplicationAuthorization> ResetApplicationAuthentication(string clientId, string accessToken)
{
Ensure.ArgumentNotNullOrEmptyString(clientId, "clientId");
Ensure.ArgumentNotNullOrEmptyString(accessToken, "accessToken");

var requestData = new { };

return await ApiConnection.Post<ApplicationAuthorization>(
ApiUrls.ApplicationAuthorization(clientId, accessToken), requestData);
return ApiConnection.Post<ApplicationAuthorization>(ApiUrls.ApplicationAuthorization(clientId, accessToken), requestData);
}

/// <summary>
Expand Down
55 changes: 22 additions & 33 deletions Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ public EnterpriseAdminStatsClient(IApiConnection apiConnection)
/// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics
/// </remarks>
/// <returns>The <see cref="AdminStatsIssues"/> statistics.</returns>
public async Task<AdminStatsIssues> GetStatisticsIssues()
public Task<AdminStatsIssues> GetStatisticsIssues()
{
var endpoint = ApiUrls.EnterpriseAdminStatsIssues();

return await ApiConnection.Get<AdminStatsIssues>(endpoint)
.ConfigureAwait(false);
return ApiConnection.Get<AdminStatsIssues>(endpoint);
}

/// <summary>
Expand All @@ -36,12 +35,11 @@ public async Task<AdminStatsIssues> GetStatisticsIssues()
/// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics
/// </remarks>
/// <returns>The <see cref="AdminStatsHooks"/> statistics.</returns>
public async Task<AdminStatsHooks> GetStatisticsHooks()
public Task<AdminStatsHooks> GetStatisticsHooks()
{
var endpoint = ApiUrls.EnterpriseAdminStatsHooks();

return await ApiConnection.Get<AdminStatsHooks>(endpoint)
.ConfigureAwait(false);
return ApiConnection.Get<AdminStatsHooks>(endpoint);
}

/// <summary>
Expand All @@ -51,12 +49,11 @@ public async Task<AdminStatsHooks> GetStatisticsHooks()
/// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics
/// </remarks>
/// <returns>The <see cref="AdminStatsMilestones"/> statistics.</returns>
public async Task<AdminStatsMilestones> GetStatisticsMilestones()
public Task<AdminStatsMilestones> GetStatisticsMilestones()
{
var endpoint = ApiUrls.EnterpriseAdminStatsMilestones();

return await ApiConnection.Get<AdminStatsMilestones>(endpoint)
.ConfigureAwait(false);
return ApiConnection.Get<AdminStatsMilestones>(endpoint);
}

/// <summary>
Expand All @@ -66,12 +63,11 @@ public async Task<AdminStatsMilestones> GetStatisticsMilestones()
/// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics
/// </remarks>
/// <returns>The <see cref="AdminStatsOrgs"/> statistics.</returns>
public async Task<AdminStatsOrgs> GetStatisticsOrgs()
public Task<AdminStatsOrgs> GetStatisticsOrgs()
{
var endpoint = ApiUrls.EnterpriseAdminStatsOrgs();

return await ApiConnection.Get<AdminStatsOrgs>(endpoint)
.ConfigureAwait(false);
return ApiConnection.Get<AdminStatsOrgs>(endpoint);
}

/// <summary>
Expand All @@ -81,12 +77,11 @@ public async Task<AdminStatsOrgs> GetStatisticsOrgs()
/// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics
/// </remarks>
/// <returns>The <see cref="AdminStatsComments"/> statistics.</returns>
public async Task<AdminStatsComments> GetStatisticsComments()
public Task<AdminStatsComments> GetStatisticsComments()
{
var endpoint = ApiUrls.EnterpriseAdminStatsComments();

return await ApiConnection.Get<AdminStatsComments>(endpoint)
.ConfigureAwait(false);
return ApiConnection.Get<AdminStatsComments>(endpoint);
}

/// <summary>
Expand All @@ -96,12 +91,11 @@ public async Task<AdminStatsComments> GetStatisticsComments()
/// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics
/// </remarks>
/// <returns>The <see cref="AdminStatsPages"/> statistics.</returns>
public async Task<AdminStatsPages> GetStatisticsPages()
public Task<AdminStatsPages> GetStatisticsPages()
{
var endpoint = ApiUrls.EnterpriseAdminStatsPages();

return await ApiConnection.Get<AdminStatsPages>(endpoint)
.ConfigureAwait(false);
return ApiConnection.Get<AdminStatsPages>(endpoint);
}

/// <summary>
Expand All @@ -111,12 +105,11 @@ public async Task<AdminStatsPages> GetStatisticsPages()
/// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics
/// </remarks>
/// <returns>The <see cref="AdminStatsUsers"/> statistics.</returns>
public async Task<AdminStatsUsers> GetStatisticsUsers()
public Task<AdminStatsUsers> GetStatisticsUsers()
{
var endpoint = ApiUrls.EnterpriseAdminStatsUsers();

return await ApiConnection.Get<AdminStatsUsers>(endpoint)
.ConfigureAwait(false);
return ApiConnection.Get<AdminStatsUsers>(endpoint);
}

/// <summary>
Expand All @@ -126,12 +119,11 @@ public async Task<AdminStatsUsers> GetStatisticsUsers()
/// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics
/// </remarks>
/// <returns>The <see cref="AdminStatsGists"/> statistics.</returns>
public async Task<AdminStatsGists> GetStatisticsGists()
public Task<AdminStatsGists> GetStatisticsGists()
{
var endpoint = ApiUrls.EnterpriseAdminStatsGists();

return await ApiConnection.Get<AdminStatsGists>(endpoint)
.ConfigureAwait(false);
return ApiConnection.Get<AdminStatsGists>(endpoint);
}

/// <summary>
Expand All @@ -141,12 +133,11 @@ public async Task<AdminStatsGists> GetStatisticsGists()
/// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics
/// </remarks>
/// <returns>The <see cref="AdminStatsPulls"/> statistics.</returns>
public async Task<AdminStatsPulls> GetStatisticsPulls()
public Task<AdminStatsPulls> GetStatisticsPulls()
{
var endpoint = ApiUrls.EnterpriseAdminStatsPulls();

return await ApiConnection.Get<AdminStatsPulls>(endpoint)
.ConfigureAwait(false);
return ApiConnection.Get<AdminStatsPulls>(endpoint);
}

/// <summary>
Expand All @@ -156,12 +147,11 @@ public async Task<AdminStatsPulls> GetStatisticsPulls()
/// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics
/// </remarks>
/// <returns>The <see cref="AdminStatsRepos"/> statistics.</returns>
public async Task<AdminStatsRepos> GetStatisticsRepos()
public Task<AdminStatsRepos> GetStatisticsRepos()
{
var endpoint = ApiUrls.EnterpriseAdminStatsRepos();

return await ApiConnection.Get<AdminStatsRepos>(endpoint)
.ConfigureAwait(false);
return ApiConnection.Get<AdminStatsRepos>(endpoint);
}

/// <summary>
Expand All @@ -171,12 +161,11 @@ public async Task<AdminStatsRepos> GetStatisticsRepos()
/// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics
/// </remarks>
/// <returns>The <see cref="AdminStats"/> collection of statistics.</returns>
public async Task<AdminStats> GetStatisticsAll()
public Task<AdminStats> GetStatisticsAll()
{
var endpoint = ApiUrls.EnterpriseAdminStatsAll();

return await ApiConnection.Get<AdminStats>(endpoint)
.ConfigureAwait(false);
return ApiConnection.Get<AdminStats>(endpoint);
}
}
}
4 changes: 2 additions & 2 deletions Octokit/Clients/Enterprise/EnterpriseLdapClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task<LdapSyncResponse> QueueSyncUserMapping(string userName)

var endpoint = ApiUrls.EnterpriseLdapUserSync(userName);

var response = await Connection.Post<LdapSyncResponse>(endpoint);
var response = await Connection.Post<LdapSyncResponse>(endpoint).ConfigureAwait(false);
if (response.HttpResponse.StatusCode != HttpStatusCode.Created)
{
throw new ApiException("Invalid Status Code returned. Expected a 201", response.HttpResponse.StatusCode);
Expand Down Expand Up @@ -90,7 +90,7 @@ public async Task<LdapSyncResponse> QueueSyncTeamMapping(int teamId)

var endpoint = ApiUrls.EnterpriseLdapTeamSync(teamId);

var response = await Connection.Post<LdapSyncResponse>(endpoint);
var response = await Connection.Post<LdapSyncResponse>(endpoint).ConfigureAwait(false);
if (response.HttpResponse.StatusCode != HttpStatusCode.Created)
{
throw new ApiException("Invalid Status Code returned. Expected a 201", response.HttpResponse.StatusCode);
Expand Down
5 changes: 2 additions & 3 deletions Octokit/Clients/Enterprise/EnterpriseLicenseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ public EnterpriseLicenseClient(IApiConnection apiConnection)
/// https://developer.github.com/v3/enterprise/license/#get-license-information
/// </remarks>
/// <returns>The <see cref="LicenseInfo"/> statistics.</returns>
public async Task<LicenseInfo> Get()
public Task<LicenseInfo> Get()
{
var endpoint = ApiUrls.EnterpriseLicense();

return await ApiConnection.Get<LicenseInfo>(endpoint)
.ConfigureAwait(false);
return ApiConnection.Get<LicenseInfo>(endpoint);
}
}
}
4 changes: 2 additions & 2 deletions Octokit/Clients/Enterprise/EnterpriseOrganizationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public EnterpriseOrganizationClient(IApiConnection apiConnection)
/// </remarks>
/// <param name="newOrganization">A <see cref="NewOrganization"/> instance describing the organization to be created</param>
/// <returns>The <see cref="Organization"/> created.</returns>
public async Task<Organization> Create(NewOrganization newOrganization)
public Task<Organization> Create(NewOrganization newOrganization)
{
Ensure.ArgumentNotNull(newOrganization, "newOrganization");

var endpoint = ApiUrls.EnterpriseOrganization();

return await ApiConnection.Post<Organization>(endpoint, newOrganization);
return ApiConnection.Post<Organization>(endpoint, newOrganization);
}
}
}
Loading