Skip to content

Commit 39ab3cb

Browse files
committed
refactor: remove redundant field initialization
1 parent d3d1377 commit 39ab3cb

File tree

150 files changed

+497
-498
lines changed

Some content is hidden

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

150 files changed

+497
-498
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
@@ -703,10 +703,10 @@ private string FixFontFamilyName(string input)
703703
[GeneratedRegex(@"^[a-z]+\s+([a-fA-F0-9]{4,40})(\s+.*)?$")]
704704
private static partial Regex REG_REBASE_TODO();
705705

706-
private Models.IpcChannel _ipcChannel = null;
707-
private ViewModels.Launcher _launcher = null;
708-
private ResourceDictionary _activeLocale = null;
709-
private ResourceDictionary _themeOverrides = null;
710-
private ResourceDictionary _fontsOverrides = null;
706+
private Models.IpcChannel _ipcChannel;
707+
private ViewModels.Launcher _launcher;
708+
private ResourceDictionary _activeLocale;
709+
private ResourceDictionary _themeOverrides;
710+
private ResourceDictionary _fontsOverrides;
711711
}
712712
}

src/Commands/Blame.cs

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

src/Commands/Command.cs

Lines changed: 3 additions & 3 deletions
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

@@ -27,15 +27,15 @@ public enum EditorType
2727
}
2828

2929
public string Context { get; set; } = string.Empty;
30-
public string WorkingDirectory { get; set; } = null;
30+
public string WorkingDirectory { get; set; }
3131
public EditorType Editor { get; set; } = EditorType.CoreEditor;
3232
public string SSHKey { get; set; } = string.Empty;
3333
public string Args { get; set; } = string.Empty;
3434

3535
// Only used in `ExecAsync` mode.
3636
public CancellationToken CancellationToken { get; set; } = CancellationToken.None;
3737
public bool RaiseError { get; set; } = true;
38-
public Models.ICommandLog Log { get; set; } = null;
38+
public Models.ICommandLog Log { get; set; }
3939

4040
public void Exec()
4141
{

src/Commands/Config.cs

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

63-
private bool _isLocal = false;
63+
private readonly bool _isLocal;
6464
}
6565
}

src/Commands/Diff.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ private void ProcessInlineHighlights()
262262
private readonly Models.DiffResult _result = new Models.DiffResult();
263263
private readonly List<Models.TextDiffLine> _deleted = new List<Models.TextDiffLine>();
264264
private readonly List<Models.TextDiffLine> _added = new List<Models.TextDiffLine>();
265-
private Models.TextDiffLine _last = null;
266-
private int _oldLine = 0;
267-
private int _newLine = 0;
265+
private Models.TextDiffLine _last;
266+
private int _oldLine;
267+
private int _newLine;
268268
}
269269
}

src/Commands/QueryCommits.cs

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

148-
private List<Models.Commit> _commits = new List<Models.Commit>();
149-
private Models.Commit _current = null;
150-
private bool _findFirstMerged = false;
151-
private bool _isHeadFound = false;
148+
private readonly List<Models.Commit> _commits = new List<Models.Commit>();
149+
private readonly bool _findFirstMerged;
150+
private Models.Commit _current;
151+
private bool _isHeadFound;
152152
}
153153
}

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(' ', 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/Blame.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace SourceGit.Models
44
{
55
public class BlameLineInfo
66
{
7-
public bool IsFirstInGroup { get; set; } = false;
7+
public bool IsFirstInGroup { get; set; }
88
public string CommitSHA { get; set; } = string.Empty;
99
public string Author { get; set; } = string.Empty;
1010
public string Time { get; set; } = string.Empty;
@@ -15,6 +15,6 @@ public class BlameData
1515
public string File { get; set; } = string.Empty;
1616
public List<BlameLineInfo> LineInfos { get; set; } = new List<BlameLineInfo>();
1717
public string Content { get; set; } = string.Empty;
18-
public bool IsBinary { get; set; } = false;
18+
public bool IsBinary { get; set; }
1919
}
2020
}

0 commit comments

Comments
 (0)