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

Commit 56511e5

Browse files
committed
Merge pull request #60 from github/haacked/minor-fixups
🎨 Remove rendundant null check
2 parents 8096a8e + c0acbe2 commit 56511e5

File tree

6 files changed

+8
-15
lines changed

6 files changed

+8
-15
lines changed

src/GitHub.App/Controllers/UIController.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,7 @@ protected virtual void Dispose(bool disposing)
272272

273273
Debug.WriteLine("Disposing ({0})", GetHashCode());
274274
disposables.Dispose();
275-
if (transition != null)
276-
transition.Dispose();
275+
transition?.Dispose();
277276
disposed = true;
278277
}
279278
}

src/GitHub.App/Models/RepositoryHost.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public IObservable<AuthenticationResult> LogIn(string usernameOrEmail, string pa
104104
// in multiple places in the chain below:
105105
var saveAuthorizationToken = new Func<ApplicationAuthorization, IObservable<Unit>>(authorization =>
106106
{
107-
var token = authorization != null ? authorization.Token : null;
107+
var token = authorization?.Token;
108108
if (string.IsNullOrWhiteSpace(token))
109109
return Observable.Return(Unit.Default);
110110

src/GitHub.App/Services/AvatarProvider.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public IObservable<BitmapSource> GetAvatar(IAvatarContainer apiAccount)
6767

6868
public IObservable<Unit> InvalidateAvatar([AllowNull] IAvatarContainer apiAccount)
6969
{
70-
return apiAccount == null || String.IsNullOrWhiteSpace(apiAccount.Login)
70+
return String.IsNullOrWhiteSpace(apiAccount?.Login)
7171
? Observable.Return(Unit.Default)
7272
: cache.Invalidate(apiAccount.Login);
7373
}

src/GitHub.App/Services/GitClient.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ public IObservable<Unit> Push(IRepository repository, string branchName, string
1818

1919
return Observable.Defer(() =>
2020
{
21-
if (repository.Head != null
22-
&& repository.Head != null
23-
&& repository.Head.Commits != null
24-
&& repository.Head.Commits.Any())
21+
if (repository.Head?.Commits != null && repository.Head.Commits.Any())
2522
{
2623
var remote = repository.Network.Remotes[remoteName];
2724
repository.Network.Push(remote, "HEAD", @"refs/heads/" + branchName);

src/GitHub.App/Services/Translation.cs

+3-6
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,9 @@ protected virtual Tuple<Translation, string> Match(Exception exception)
6767
string exceptionMessage = exception.Message;
6868

6969
var apiException = exception as ApiValidationException;
70-
if (apiException != null && apiException.ApiError != null && apiException.ApiError.Errors != null)
71-
{
72-
var error = apiException.ApiError.Errors.FirstOrDefault();
73-
if (error != null)
74-
exceptionMessage = error.Message ?? exceptionMessage;
75-
}
70+
var error = apiException?.ApiError?.Errors?.FirstOrDefault();
71+
if (error != null)
72+
exceptionMessage = error.Message ?? exceptionMessage;
7673

7774
if (Original == exceptionMessage) return new Tuple<Translation, string>(this, null);
7875

src/GitHub.App/ViewModels/RepositoryPublishViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void InitializeValidation()
191191

192192
this.WhenAny(x => x.SafeRepositoryNameWarningValidator.ValidationResult, x => x.Value)
193193
.WhereNotNull() // When this is instantiated, it sends a null result.
194-
.Select(result => result == null ? null : result.Message)
194+
.Select(result => result?.Message)
195195
.Subscribe(message =>
196196
{
197197
if (!string.IsNullOrEmpty(message))

0 commit comments

Comments
 (0)