Skip to content

Commit d010046

Browse files
committed
refactor: remove redundant field initialization
1 parent 2b7bd2e commit d010046

File tree

138 files changed

+425
-425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+425
-425
lines changed

src/App.Commands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public Command(Action<object> action)
2222
public bool CanExecute(object parameter) => _action != null;
2323
public void Execute(object parameter) => _action?.Invoke(parameter);
2424

25-
private Action<object> _action = null;
25+
private readonly Action<object> _action;
2626
}
2727

2828
public static bool IsCheckForUpdateCommandVisible

src/App.axaml.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -713,10 +713,10 @@ private string FixFontFamilyName(string input)
713713
[GeneratedRegex(@"^[a-z]+\s+([a-fA-F0-9]{4,40})(\s+.*)?$")]
714714
private static partial Regex REG_REBASE_TODO();
715715

716-
private Models.IpcChannel _ipcChannel = null;
717-
private ViewModels.Launcher _launcher = null;
718-
private ResourceDictionary _activeLocale = null;
719-
private ResourceDictionary _themeOverrides = null;
720-
private ResourceDictionary _fontsOverrides = null;
716+
private Models.IpcChannel _ipcChannel;
717+
private ViewModels.Launcher _launcher;
718+
private ResourceDictionary _activeLocale;
719+
private ResourceDictionary _themeOverrides;
720+
private ResourceDictionary _fontsOverrides;
721721
}
722722
}

src/Commands/Blame.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private void ParseLine(string line)
9292
private readonly StringBuilder _content = new StringBuilder();
9393
private readonly string _dateFormat = Models.DateTimeFormat.Active.DateOnly;
9494
private string _lastSHA = string.Empty;
95-
private bool _needUnifyCommitSHA = false;
95+
private bool _needUnifyCommitSHA;
9696
private int _minSHALen = 64;
9797
}
9898
}

src/Commands/Command.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public partial class Command
1212
{
1313
public class Result
1414
{
15-
public bool IsSuccess { get; set; } = false;
15+
public bool IsSuccess { get; set; }
1616
public string StdOut { get; set; } = string.Empty;
1717
public string StdErr { get; set; } = string.Empty;
1818

src/Commands/Config.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ public async Task<bool> SetAsync(string key, string value, bool allowEmpty = fal
6464
return await ExecAsync().ConfigureAwait(false);
6565
}
6666

67-
private bool _isLocal = false;
67+
private readonly bool _isLocal;
6868
}
6969
}

src/Commands/Diff.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ private void ProcessInlineHighlights()
275275
private readonly Models.DiffResult _result = new Models.DiffResult();
276276
private readonly List<Models.TextDiffLine> _deleted = new List<Models.TextDiffLine>();
277277
private readonly List<Models.TextDiffLine> _added = new List<Models.TextDiffLine>();
278-
private Models.TextDiffLine _last = null;
279-
private int _oldLine = 0;
280-
private int _newLine = 0;
278+
private Models.TextDiffLine _last;
279+
private int _oldLine;
280+
private int _newLine;
281281
}
282282
}

src/Commands/QueryCommits.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ private async Task MarkFirstMergedAsync()
147147
}
148148
}
149149

150-
private List<Models.Commit> _commits = new List<Models.Commit>();
151-
private Models.Commit _current = null;
152-
private bool _findFirstMerged = false;
153-
private bool _isHeadFounded = false;
150+
private readonly List<Models.Commit> _commits = new List<Models.Commit>();
151+
private readonly bool _findFirstMerged;
152+
private Models.Commit _current;
153+
private bool _isHeadFounded;
154154
}
155155
}

src/Commands/QueryCommitsForInteractiveRebase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ private void ParseParent(string data)
8989
_current.Commit.Parents.AddRange(data.Split(separator: ' ', options: StringSplitOptions.RemoveEmptyEntries));
9090
}
9191

92-
private List<Models.InteractiveCommit> _commits = [];
93-
private Models.InteractiveCommit _current = null;
92+
private readonly List<Models.InteractiveCommit> _commits = [];
9493
private readonly string _boundary;
94+
private Models.InteractiveCommit _current;
9595
}
9696
}

src/Models/AvatarManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ public static AvatarManager Instance
3030
}
3131
}
3232

33-
private static AvatarManager _instance = null;
33+
private static AvatarManager _instance;
3434

3535
[GeneratedRegex(@"^(?:(\d+)\+)?(.+?)@.+\.github\.com$")]
3636
private static partial Regex REG_GITHUB_USER_EMAIL();
3737

3838
private readonly Lock _synclock = new();
39+
private readonly List<IAvatarHost> _avatars = new List<IAvatarHost>();
40+
private readonly Dictionary<string, Bitmap> _resources = new Dictionary<string, Bitmap>();
41+
private readonly HashSet<string> _requesting = new HashSet<string>();
42+
private readonly HashSet<string> _defaultAvatars = new HashSet<string>();
3943
private string _storePath;
40-
private List<IAvatarHost> _avatars = new List<IAvatarHost>();
41-
private Dictionary<string, Bitmap> _resources = new Dictionary<string, Bitmap>();
42-
private HashSet<string> _requesting = new HashSet<string>();
43-
private HashSet<string> _defaultAvatars = new HashSet<string>();
4444

4545
public void Start()
4646
{

src/Models/Commit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static double OpacityForNotMerged
4242
public string AuthorTimeShortStr => DateTime.UnixEpoch.AddSeconds(AuthorTime).ToLocalTime().ToString(DateTimeFormat.Active.DateOnly);
4343
public string CommitterTimeShortStr => DateTime.UnixEpoch.AddSeconds(CommitterTime).ToLocalTime().ToString(DateTimeFormat.Active.DateOnly);
4444

45-
public bool IsMerged { get; set; } = false;
45+
public bool IsMerged { get; set; }
4646
public bool IsCommitterVisible => !Author.Equals(Committer) || AuthorTime != CommitterTime;
4747
public bool IsCurrentHead => Decorators.Find(x => x.Type is DecoratorType.CurrentBranchHead or DecoratorType.CurrentCommitHead) != null;
4848

0 commit comments

Comments
 (0)