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

Commit a3f61e7

Browse files
committed
Fix code analysis
1 parent 2c96ea4 commit a3f61e7

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/GitHub.App/ViewModels/PullRequestCreationViewModel.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@
66
using ReactiveUI;
77
using GitHub.Services;
88
using System.Reactive.Linq;
9-
using System.Collections.ObjectModel;
109
using GitHub.Extensions.Reactive;
1110
using GitHub.UI;
1211
using System.Linq;
13-
using System.Windows.Input;
1412
using GitHub.Validation;
1513
using GitHub.Extensions;
1614
using NullGuard;
17-
using System.Reactive.Disposables;
1815

1916
namespace GitHub.ViewModels
2017
{
@@ -24,7 +21,6 @@ public class PullRequestCreationViewModel : BaseViewModel, IPullRequestCreationV
2421
{
2522
readonly IRepositoryHost repositoryHost;
2623
readonly ISimpleRepositoryModel activeRepo;
27-
readonly CompositeDisposable disposables = new CompositeDisposable();
2824

2925
[ImportingConstructor]
3026
PullRequestCreationViewModel(
@@ -52,7 +48,6 @@ public PullRequestCreationViewModel(IRepositoryHost repositoryHost, ISimpleRepos
5248
var titleObs = this.WhenAny(x => x.PRTitle, x => x.Value);
5349
TitleValidator = ReactivePropertyValidator.ForObservable(titleObs)
5450
.IfNullOrEmpty("Please enter a title for the Pull Request");
55-
disposables.Add(TitleValidator);
5651

5752
var branchObs = this.WhenAny(
5853
x => x.SourceBranch,
@@ -61,18 +56,16 @@ public PullRequestCreationViewModel(IRepositoryHost repositoryHost, ISimpleRepos
6156
BranchValidator = ReactivePropertyValidator.ForObservable(branchObs)
6257
.IfTrue(x => x == null, "Source branch doesn't exist remotely, have you pushed it?")
6358
.IfTrue(x => x.Name == TargetBranch.Name, "Source and target branch cannot be the same");
64-
disposables.Add(BranchValidator);
6559

6660
var whenAnyValidationResultChanges = this.WhenAny(
6761
x => x.TitleValidator.ValidationResult,
6862
x => x.BranchValidator.ValidationResult,
6963
(x, y) => (x.Value?.IsValid ?? false) && (y.Value?.IsValid ?? false));
7064

71-
disposables.Add(
72-
this.WhenAny(x => x.BranchValidator.ValidationResult, x => x.GetValue())
73-
.WhereNotNull()
74-
.Where(x => !x.IsValid && x.DisplayValidationError)
75-
.Subscribe(x => notifications.ShowError(BranchValidator.ValidationResult.Message)));
65+
this.WhenAny(x => x.BranchValidator.ValidationResult, x => x.GetValue())
66+
.WhereNotNull()
67+
.Where(x => !x.IsValid && x.DisplayValidationError)
68+
.Subscribe(x => notifications.ShowError(BranchValidator.ValidationResult.Message));
7669

7770
createPullRequest = ReactiveCommand.CreateAsyncObservable(whenAnyValidationResultChanges,
7871
_ => service.CreatePullRequest(repositoryHost, activeRepo, PRTitle, SourceBranch, TargetBranch)
@@ -83,7 +76,6 @@ public PullRequestCreationViewModel(IRepositoryHost repositoryHost, ISimpleRepos
8376
{
8477
}
8578
});
86-
disposables.Add(createPullRequest);
8779
}
8880

8981
public override void Initialize([AllowNull] ViewWithData data)

0 commit comments

Comments
 (0)