Skip to content

Commit 3fe72e9

Browse files
committed
code_review: PR #1497
Signed-off-by: leo <[email protected]>
1 parent ec17ea9 commit 3fe72e9

13 files changed

+25
-22
lines changed

src/App.axaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ public static void SendNotification(string context, string message)
161161
public static void SetLocale(string localeKey)
162162
{
163163
var app = Current as App;
164-
165164
var targetLocale = app?.Resources[localeKey] as ResourceDictionary;
166165
if (targetLocale == null || targetLocale == app._activeLocale)
167166
return;

src/Commands/QueryCommits.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ private void MarkFirstMerged()
133133
return;
134134

135135
var set = new HashSet<string>(shas);
136-
137136
foreach (var c in _commits)
138137
{
139138
if (set.Contains(c.SHA))

src/ViewModels/BranchCompare.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public List<Models.Change> SelectedChanges
4949
{
5050
if (SetProperty(ref _selectedChanges, value))
5151
{
52-
if (value?.Count == 1)
52+
if (value is { Count: 1 })
5353
DiffContext = new DiffContext(_repo, new Models.DiffOption(_based.Head, _to.Head, value[0]), _diffContext);
5454
else
5555
DiffContext = null;

src/ViewModels/BranchTreeNode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using Avalonia;
4-
using AvaloniaEdit.Utils;
54
using CommunityToolkit.Mvvm.ComponentModel;
65

76
namespace SourceGit.ViewModels
@@ -87,7 +86,8 @@ public Builder(Models.BranchSortMode localSortMode, Models.BranchSortMode remote
8786

8887
public void SetExpandedNodes(List<string> expanded)
8988
{
90-
_expanded.AddRange(expanded);
89+
foreach (var node in expanded)
90+
_expanded.Add(node);
9191
}
9292

9393
public void Run(List<Models.Branch> branches, List<Models.Remote> remotes, bool bForceExpanded)

src/ViewModels/CheckoutAndFastForward.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public override Task<bool> Sure()
4949
var updateSubmodules = IsRecurseSubmoduleVisible && RecurseSubmodules;
5050
return Task.Run(() =>
5151
{
52-
bool succ;
52+
var succ = false;
5353
var needPopStash = false;
5454

5555
if (!_repo.ConfirmCheckoutBranch())

src/ViewModels/CreateBranch.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ public CreateBranch(Repository repo, Models.Branch branch)
7070
_baseOnRevision = branch.IsDetachedHead ? branch.Head : branch.FullName;
7171

7272
if (!branch.IsLocal && repo.Branches.Find(x => x.IsLocal && x.Name == branch.Name) == null)
73-
{
7473
Name = branch.Name;
75-
}
7674

7775
BasedOn = branch;
7876
DiscardLocalChanges = false;

src/ViewModels/LFSLocks.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Threading.Tasks;
34

45
using Avalonia.Threading;
@@ -86,10 +87,17 @@ private void UpdateVisibleLocks()
8687
{
8788
var visible = new List<Models.LFSLock>();
8889

89-
foreach (var lfsLock in _cachedLocks)
90+
if (!_showOnlyMyLocks)
9091
{
91-
if (!_showOnlyMyLocks || lfsLock.User == _userName)
92-
visible.Add(lfsLock);
92+
visible.AddRange(_cachedLocks);
93+
}
94+
else
95+
{
96+
foreach (var lfsLock in _cachedLocks)
97+
{
98+
if (lfsLock.User.Equals(_userName, StringComparison.Ordinal))
99+
visible.Add(lfsLock);
100+
}
93101
}
94102

95103
VisibleLocks = visible;

src/ViewModels/RevisionCompare.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public List<Models.Change> SelectedChanges
3939
{
4040
if (SetProperty(ref _selectedChanges, value))
4141
{
42-
if (value?.Count == 1)
42+
if (value is { Count: 1 })
4343
{
4444
var option = new Models.DiffOption(GetSHA(_startPoint), GetSHA(_endPoint), value[0]);
4545
DiffContext = new DiffContext(_repo, option, _diffContext);

src/ViewModels/WorkingCopy.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public List<Models.Change> SelectedUnstaged
167167
}
168168
else
169169
{
170-
if (_selectedStaged?.Count > 0)
170+
if (_selectedStaged is { Count: > 0 })
171171
SelectedStaged = [];
172172

173173
if (value.Count == 1)
@@ -193,7 +193,7 @@ public List<Models.Change> SelectedStaged
193193
}
194194
else
195195
{
196-
if (_selectedUnstaged?.Count > 0)
196+
if (_selectedUnstaged is { Count: > 0 })
197197
SelectedUnstaged = [];
198198

199199
if (value.Count == 1)
@@ -269,12 +269,12 @@ public void SetData(List<Models.Change> changes)
269269

270270
var lastSelectedUnstaged = new HashSet<string>();
271271
var lastSelectedStaged = new HashSet<string>();
272-
if (_selectedUnstaged?.Count > 0)
272+
if (_selectedUnstaged is { Count: > 0 })
273273
{
274274
foreach (var c in _selectedUnstaged)
275275
lastSelectedUnstaged.Add(c.Path);
276276
}
277-
else if (_selectedStaged?.Count > 0)
277+
else if (_selectedStaged is { Count: > 0 })
278278
{
279279
foreach (var c in _selectedStaged)
280280
lastSelectedStaged.Add(c.Path);

src/Views/ChangeCollectionView.axaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ private void UpdateDataSource(bool onlyViewModeChange)
380380
else if (selected.Count > 0)
381381
{
382382
var sets = new HashSet<Models.Change>(selected);
383-
384383
var nodes = new List<ViewModels.ChangeTreeNode>();
385384
foreach (var row in tree.Rows)
386385
{

src/Views/CommitRefsPresenter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ protected override Size MeasureOverride(Size availableSize)
179179
return new Size(0, 0);
180180

181181
var refs = commit.Decorators;
182-
if (refs?.Count > 0)
182+
if (refs is { Count: > 0 })
183183
{
184184
var typeface = new Typeface(FontFamily);
185185
var typefaceBold = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Bold);

src/Views/RevisionFileTreeView.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public void ToggleNodeIsExpanded(ViewModels.RevisionFileTreeNode node)
216216
if (node.IsExpanded)
217217
{
218218
var subtree = GetChildrenOfTreeNode(node);
219-
if (subtree?.Count > 0)
219+
if (subtree is { Count: > 0 })
220220
{
221221
var subrows = new List<ViewModels.RevisionFileTreeNode>();
222222
MakeRows(subrows, subtree, depth + 1);

src/Views/TextDiffView.axaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public override void Render(DrawingContext context)
101101

102102
var lines = presenter.GetLines();
103103
var view = TextView;
104-
if (view?.VisualLinesValid ?? false)
104+
if (view is { VisualLinesValid: true })
105105
{
106106
var typeface = view.CreateTypeface();
107107
foreach (var line in view.VisualLines)
@@ -175,7 +175,7 @@ public override void Render(DrawingContext context)
175175

176176
var lines = presenter.GetLines();
177177
var view = TextView;
178-
if (view?.VisualLinesValid ?? false)
178+
if (view is { VisualLinesValid: true })
179179
{
180180
var typeface = view.CreateTypeface();
181181
foreach (var line in view.VisualLines)

0 commit comments

Comments
 (0)