Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 322df9b

Browse files
committed
Fix analyser warnings in LoginManager.
1 parent 5008995 commit 322df9b

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/GitHub.Api/LoginManager.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public async Task<User> Login(
125125
} while (auth == null);
126126

127127
await keychain.Save(userName, auth.Token, hostAddress).ConfigureAwait(false);
128-
return await ReadUserWithRetry(client);
128+
return await ReadUserWithRetry(client).ConfigureAwait(false);
129129
}
130130

131131
/// <inheritdoc/>
@@ -147,12 +147,12 @@ public async Task<User> LoginViaOAuth(
147147

148148
openBrowser(loginUrl);
149149

150-
var code = await listen;
150+
var code = await listen.ConfigureAwait(false);
151151
var request = new OauthTokenRequest(clientId, clientSecret, code);
152-
var token = await oauthClient.CreateAccessToken(request);
152+
var token = await oauthClient.CreateAccessToken(request).ConfigureAwait(false);
153153

154154
await keychain.Save("[oauth]", token.AccessToken, hostAddress).ConfigureAwait(false);
155-
var user = await ReadUserWithRetry(client);
155+
var user = await ReadUserWithRetry(client).ConfigureAwait(false);
156156
await keychain.Save(user.Login, token.AccessToken, hostAddress).ConfigureAwait(false);
157157
return user;
158158
}
@@ -171,13 +171,13 @@ public async Task<User> LoginWithToken(
171171

172172
try
173173
{
174-
var user = await ReadUserWithRetry(client);
174+
var user = await ReadUserWithRetry(client).ConfigureAwait(false);
175175
await keychain.Save(user.Login, token, hostAddress).ConfigureAwait(false);
176176
return user;
177177
}
178178
catch
179179
{
180-
await keychain.Delete(hostAddress);
180+
await keychain.Delete(hostAddress).ConfigureAwait(false);
181181
throw;
182182
}
183183
}
@@ -197,7 +197,7 @@ public async Task Logout(HostAddress hostAddress, IGitHubClient client)
197197
Guard.ArgumentNotNull(hostAddress, nameof(hostAddress));
198198
Guard.ArgumentNotNull(client, nameof(client));
199199

200-
await keychain.Delete(hostAddress);
200+
await keychain.Delete(hostAddress).ConfigureAwait(false);
201201
}
202202

203203
/// <summary>
@@ -260,18 +260,18 @@ async Task<ApplicationAuthorization> CreateAndDeleteExistingApplicationAuthoriza
260260
twoFactorAuthenticationCode).ConfigureAwait(false);
261261
}
262262

263-
if (result.Token == string.Empty)
263+
if (string.IsNullOrEmpty(result.Token))
264264
{
265265
if (twoFactorAuthenticationCode == null)
266266
{
267-
await client.Authorization.Delete(result.Id);
267+
await client.Authorization.Delete(result.Id).ConfigureAwait(false);
268268
}
269269
else
270270
{
271-
await client.Authorization.Delete(result.Id, twoFactorAuthenticationCode);
271+
await client.Authorization.Delete(result.Id, twoFactorAuthenticationCode).ConfigureAwait(false);
272272
}
273273
}
274-
} while (result.Token == string.Empty && retry++ == 0);
274+
} while (string.IsNullOrEmpty(result.Token) && retry++ == 0);
275275

276276
return result;
277277
}
@@ -284,7 +284,7 @@ async Task<ApplicationAuthorization> HandleTwoFactorAuthorization(
284284
{
285285
for (;;)
286286
{
287-
var challengeResult = await twoFactorChallengeHandler.Value.HandleTwoFactorException(exception);
287+
var challengeResult = await twoFactorChallengeHandler.Value.HandleTwoFactorException(exception).ConfigureAwait(false);
288288

289289
if (challengeResult == null)
290290
{
@@ -308,7 +308,7 @@ async Task<ApplicationAuthorization> HandleTwoFactorAuthorization(
308308
}
309309
catch (Exception e)
310310
{
311-
await twoFactorChallengeHandler.Value.ChallengeFailed(e);
311+
await twoFactorChallengeHandler.Value.ChallengeFailed(e).ConfigureAwait(false);
312312
await keychain.Delete(hostAddress).ConfigureAwait(false);
313313
throw;
314314
}
@@ -366,7 +366,7 @@ async Task<User> ReadUserWithRetry(IGitHubClient client)
366366

367367
// It seems that attempting to use a token immediately sometimes fails, retry a few
368368
// times with a delay of of 1s to allow the token to propagate.
369-
await Task.Delay(1000);
369+
await Task.Delay(1000).ConfigureAwait(false);
370370
}
371371
}
372372

0 commit comments

Comments
 (0)