Remove unnecessary assignments to default type value

The .NET runtime initializes all fields of reference types to their default values before running the constructor. In most cases, explicitly initializing a field to its default value in a constructor is redundant, adding maintenance costs and potentially degrading performance
This commit is contained in:
Qstick 2023-02-18 12:23:08 -06:00
parent b41cb80e33
commit 5bb3ea0806
7 changed files with 15 additions and 16 deletions

View file

@ -179,7 +179,6 @@ dotnet_diagnostic.CA1720.severity = suggestion
dotnet_diagnostic.CA1721.severity = suggestion
dotnet_diagnostic.CA1724.severity = suggestion
dotnet_diagnostic.CA1725.severity = suggestion
dotnet_diagnostic.CA1805.severity = suggestion
dotnet_diagnostic.CA1806.severity = suggestion
dotnet_diagnostic.CA1810.severity = suggestion
dotnet_diagnostic.CA1812.severity = suggestion

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@ -19,7 +19,7 @@ public class LimitedConcurrencyLevelTaskScheduler : TaskScheduler
private readonly int _maxDegreeOfParallelism;
/// <summary>Whether the scheduler is currently processing work items.</summary>
private int _delegatesQueuedOrRunning = 0;
private int _delegatesQueuedOrRunning;
/// <summary>
/// Initializes an instance of the LimitedConcurrencyLevelTaskScheduler class with the

View file

@ -15,9 +15,9 @@ public class WhereBuilderPostgres : WhereBuilder
private const DbType EnumerableMultiParameter = (DbType)(-1);
private readonly string _paramNamePrefix;
private readonly bool _requireConcreteValue = false;
private int _paramCount = 0;
private bool _gotConcreteValue = false;
private readonly bool _requireConcreteValue;
private int _paramCount;
private bool _gotConcreteValue;
public WhereBuilderPostgres(Expression filter, bool requireConcreteValue, int seq)
{

View file

@ -15,9 +15,9 @@ public class WhereBuilderSqlite : WhereBuilder
private const DbType EnumerableMultiParameter = (DbType)(-1);
private readonly string _paramNamePrefix;
private readonly bool _requireConcreteValue = false;
private int _paramCount = 0;
private bool _gotConcreteValue = false;
private readonly bool _requireConcreteValue;
private int _paramCount;
private bool _gotConcreteValue;
public WhereBuilderSqlite(Expression filter, bool requireConcreteValue, int seq)
{

View file

@ -34,8 +34,8 @@ public class HealthCheckService : IHealthCheckService,
private readonly ICached<HealthCheck> _healthCheckResults;
private bool _hasRunHealthChecksAfterGracePeriod = false;
private bool _isRunningHealthChecksAfterGracePeriod = false;
private bool _hasRunHealthChecksAfterGracePeriod;
private bool _isRunningHealthChecksAfterGracePeriod;
public HealthCheckService(IEnumerable<IProvideHealthCheck> healthChecks,
IServerSideNotificationService serverSideNotificationService,

View file

@ -44,7 +44,7 @@ public CardigannDefinition()
public double? RequestDelay { get; set; }
public List<string> Links { get; set; }
public List<string> Legacylinks { get; set; }
public bool Followredirect { get; set; } = false;
public bool Followredirect { get; set; }
public bool TestLinkTorrent { get; set; } = true;
public List<string> Certificates { get; set; }
public CapabilitiesBlock Caps { get; set; }
@ -95,7 +95,7 @@ public class LoginBlock
public List<string> Cookies { get; set; }
public string Method { get; set; }
public string Form { get; set; }
public bool Selectors { get; set; } = false;
public bool Selectors { get; set; }
public Dictionary<string, string> Inputs { get; set; }
public Dictionary<string, SelectorBlock> Selectorinputs { get; set; }
public Dictionary<string, SelectorBlock> Getselectorinputs { get; set; }
@ -114,7 +114,7 @@ public class ErrorBlock
public class SelectorBlock
{
public string Selector { get; set; }
public bool Optional { get; set; } = false;
public bool Optional { get; set; }
public string Text { get; set; }
public string Attribute { get; set; }
public string Remove { get; set; }
@ -157,7 +157,7 @@ public class RowsBlock : SelectorBlock
public int After { get; set; }
public SelectorBlock Dateheaders { get; set; }
public SelectorBlock Count { get; set; }
public bool Multiple { get; set; } = false;
public bool Multiple { get; set; }
}
public class SearchPathBlock : RequestBlock

View file

@ -27,7 +27,7 @@ public class ProcMountProvider : IProcMountProvider
private static Dictionary<string, bool> _fileSystems;
private bool _hasLoggedProcMountFailure = false;
private bool _hasLoggedProcMountFailure;
public ProcMountProvider(Logger logger)
{