Enable CA1820 and fix noncompliance
"Test for empty strings using string length"
This commit is contained in:
parent
04949a10b3
commit
2b587f2061
|
@ -76,6 +76,8 @@ dotnet_diagnostic.CA1310.severity = silent # SpecifyStringComparisonAnalyzer ver
|
|||
|
||||
# Do not initialize unnecessarily
|
||||
dotnet_diagnostic.CA1805.severity = silent
|
||||
# Test for empty strings using string length
|
||||
dotnet_diagnostic.CA1820.severity = warning
|
||||
# Mark members as static
|
||||
dotnet_diagnostic.CA1822.severity = silent
|
||||
# Use property instead of Linq Enumerable method
|
||||
|
|
|
@ -105,9 +105,9 @@ namespace BizHawk.Client.Common.movie.import
|
|||
while (reader.ReadLine() is string line)
|
||||
{
|
||||
string author = line.Trim();
|
||||
if (author != "")
|
||||
if (author.Length is not 0)
|
||||
{
|
||||
if (authorLast != "")
|
||||
if (authorLast.Length is not 0)
|
||||
{
|
||||
authorList += $"{authorLast}, ";
|
||||
}
|
||||
|
@ -117,12 +117,12 @@ namespace BizHawk.Client.Common.movie.import
|
|||
}
|
||||
}
|
||||
|
||||
if (authorList != "")
|
||||
if (authorList.Length is not 0)
|
||||
{
|
||||
authorList += "and ";
|
||||
}
|
||||
|
||||
if (authorLast != "")
|
||||
if (authorLast.Length is not 0)
|
||||
{
|
||||
authorList += authorLast;
|
||||
}
|
||||
|
|
|
@ -631,7 +631,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
catch
|
||||
{
|
||||
if (errors != "")
|
||||
if (errors.Length is not 0)
|
||||
{
|
||||
errors += "\n";
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
try
|
||||
{
|
||||
if (t.Text != "")
|
||||
if (t.Text.Length is not 0)
|
||||
{
|
||||
Core.SetCpuRegister(t.Name, int.Parse(t.Text, System.Globalization.NumberStyles.HexNumber));
|
||||
}
|
||||
|
|
|
@ -1373,7 +1373,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (_axisTypedValue.Length is 0)
|
||||
{
|
||||
if (prevTyped != "")
|
||||
if (prevTyped.Length is not 0)
|
||||
{
|
||||
value = ControllerType.Axes[_axisEditColumn].Neutral;
|
||||
CurrentTasMovie.SetAxisState(_axisEditRow, _axisEditColumn, value);
|
||||
|
|
|
@ -217,7 +217,7 @@ namespace BizHawk.Emulation.Common
|
|||
}
|
||||
|
||||
// last chance. use the possible value
|
||||
if (IdentifiedSystem == VSystemID.Raw.AppleII && _possibleIdent != "")
|
||||
if (IdentifiedSystem == VSystemID.Raw.AppleII && _possibleIdent.Length is not 0) // wait but it's not being used for the assignment?
|
||||
{
|
||||
IdentifiedSystem = VSystemID.Raw.ZXSpectrum;
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
|
|||
|
||||
foreach (var ROM in ROMs)
|
||||
{
|
||||
if (ROM != string.Empty)
|
||||
if (ROM.Length is not 0)
|
||||
{
|
||||
var substrings = ROM.Split('~');
|
||||
var name = substrings[0];
|
||||
|
@ -200,7 +200,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
|
|||
|
||||
foreach (var View in Views)
|
||||
{
|
||||
if (View != string.Empty)
|
||||
if (View.Length is not 0)
|
||||
{
|
||||
var substrings = View.Split('@');
|
||||
setting.Options.Add(substrings[0], substrings[1]);
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
|
|||
StartMAME(lp.Roms);
|
||||
}
|
||||
|
||||
if (_loadFailure != string.Empty)
|
||||
if (_loadFailure.Length is not 0)
|
||||
{
|
||||
Dispose();
|
||||
throw new Exception("\n\n" + _loadFailure);
|
||||
|
|
Loading…
Reference in New Issue