Remove TODO from root .editorconfig and add temporary/permanent overrides. Fix the few instances in tests and a few random files in the other sources related to these analyzers.
This commit is contained in:
Jeremy Kuhne 2024-11-24 23:00:58 -08:00 коммит произвёл GitHub
Родитель a3ea647d91
Коммит d32d194d44
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
9 изменённых файлов: 52 добавлений и 40 удалений

Просмотреть файл

@ -264,7 +264,7 @@ dotnet_diagnostic.IDE0057.severity = suggestion
dotnet_diagnostic.IDE0058.severity = silent
# IDE0059: Unnecessary assignment of a value
dotnet_diagnostic.IDE0059.severity = none # TODO: warning
dotnet_diagnostic.IDE0059.severity = warning
# IDE0060: Remove unused parameter
dotnet_diagnostic.IDE0060.severity = silent
@ -707,7 +707,7 @@ dotnet_diagnostic.CA1819.severity = none
dotnet_diagnostic.CA1820.severity = none
# CA1821: Remove empty Finalizers
dotnet_diagnostic.CA1821.severity = none # TODO: warning
dotnet_diagnostic.CA1821.severity = warning
# CA1822: Mark members as static
dotnet_diagnostic.CA1822.severity = warning
@ -1276,7 +1276,7 @@ dotnet_diagnostic.CA5405.severity = error
dotnet_diagnostic.CS1573.severity = none
# IL3000: Avoid using accessing Assembly file path when publishing as a single-file
dotnet_diagnostic.IL3000.severity = none # TODO: warning
dotnet_diagnostic.IL3000.severity = warning
# IL3001: Avoid using accessing Assembly file path when publishing as a single-file
dotnet_diagnostic.IL3001.severity = warning
@ -1522,8 +1522,8 @@ dotnet_diagnostic.SA1204.severity = none
# SA1205: Partial elements should declare an access modifier
dotnet_diagnostic.SA1205.severity = warning
# SA1206: Keyword ordering - TODO Re-enable as warning after https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3527
dotnet_diagnostic.SA1206.severity = suggestion
# SA1206: Keyword ordering
dotnet_diagnostic.SA1206.severity = warning
# SA1207: Protected should come before internal
dotnet_diagnostic.SA1207.severity = none
@ -1562,7 +1562,7 @@ dotnet_diagnostic.SA1300.severity = none
dotnet_diagnostic.SA1301.severity = none
# SA1302: Interface names should begin with I
dotnet_diagnostic.SA1302.severity = none # TODO: warning
dotnet_diagnostic.SA1302.severity = warning
# SA1303: Const field names should begin with upper-case letter
dotnet_diagnostic.SA1303.severity = none
@ -1616,7 +1616,7 @@ dotnet_diagnostic.SA1402.severity = none
dotnet_diagnostic.SA1403.severity = none
# SA1404: Code analysis suppression should have justification
dotnet_diagnostic.SA1404.severity = none # TODO: warning
dotnet_diagnostic.SA1404.severity = warning
# SA1405: Debug.Assert should provide message text
dotnet_diagnostic.SA1405.severity = none

Просмотреть файл

@ -14,6 +14,9 @@ dotnet_diagnostic.CA1066.severity = none
# CA1725: Parameter names should match base declaration
dotnet_diagnostic.CA1725.severity = none
# CA1812: Remove empty finalizers
dotnet_diagnostic.CA1821.severity = none
# CA1822: Mark members as static
dotnet_diagnostic.CA1822.severity = none
@ -37,3 +40,6 @@ dotnet_diagnostic.IDE0251.severity = none
# IDE1006: Naming Styles
dotnet_diagnostic.IDE1006.severity = suggestion
# SA1206: Keyword ordering
dotnet_diagnostic.SA1206.severity = suggestion

Просмотреть файл

@ -87,7 +87,7 @@ dotnet_diagnostic.CA1810.severity = suggestion
# in the GlobalSuppressions file.
# CA1815: Override equals and operator equals on value types
dotnet_diagnostic.CA1815.severity = none
dotnet_diagnostic.CA1815.severity = suggestion
# CA1822: Mark members as static
dotnet_diagnostic.CA1822.severity = suggestion
@ -233,6 +233,9 @@ dotnet_diagnostic.IDE0052.severity = suggestion
# IDE0057: Use range operator
dotnet_diagnostic.IDE0057.severity = suggestion
# IDE0059: Unnecessary assignment of a value
dotnet_diagnostic.IDE0059.severity = suggestion
# IDE0060: Remove unused parameter
dotnet_diagnostic.IDE0060.severity = suggestion
@ -317,9 +320,15 @@ dotnet_diagnostic.SA1129.severity = suggestion
# SA1131: Constant values should appear on the right-hand side of comparisons
dotnet_diagnostic.SA1131.severity = suggestion
# SA1206: Keyword ordering
dotnet_diagnostic.SA1206.severity = suggestion
# SA1400: Member should declare an access modifier
dotnet_diagnostic.SA1400.severity = suggestion
# SA1404: Code analysis suppression should have justification
dotnet_diagnostic.SA1404.severity = suggestion
# SA1408: Conditional expressions should declare precedence
dotnet_diagnostic.SA1408.severity = suggestion
@ -342,4 +351,12 @@ dotnet_diagnostic.SA1513.severity = suggestion
dotnet_diagnostic.SA1518.severity = suggestion
# SYSLIB1045: Convert to 'GeneratedRegexAttribute'.
dotnet_diagnostic.SYSLIB1045.severity = suggestion
dotnet_diagnostic.SYSLIB1045.severity = suggestion
# ---------------------
# Ref specific C# files
# ---------------------
[*/ref/*.cs]
# CA1812: Remove empty finalizers
dotnet_diagnostic.CA1821.severity = none

Просмотреть файл

@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@ -121,9 +121,9 @@ namespace MS.Internal
//
public Stream GetContent(string srcFile)
{
Stream fileStream = null;
Stream fileStream;
if (String.IsNullOrEmpty(srcFile))
if (string.IsNullOrEmpty(srcFile))
{
throw new ArgumentNullException(nameof(srcFile));
}
@ -213,9 +213,9 @@ namespace MS.Internal
//
public DateTime GetLastChangeTime(string srcFile)
{
DateTime lastChangeDT = new DateTime(0);
DateTime lastChangeDT;
if (String.IsNullOrEmpty(srcFile))
if (string.IsNullOrEmpty(srcFile))
{
throw new ArgumentNullException(nameof(srcFile));
}
@ -239,7 +239,7 @@ namespace MS.Internal
//
public bool Exists(string fileName)
{
bool fileExists = false;
bool fileExists;
if (fileName == null)
{
@ -285,7 +285,7 @@ namespace MS.Internal
//
public void WriteFile(byte[] contentArray, string destinationFile)
{
if (String.IsNullOrEmpty(destinationFile))
if (string.IsNullOrEmpty(destinationFile))
{
throw new ArgumentNullException(nameof(destinationFile));
}
@ -329,7 +329,7 @@ namespace MS.Internal
public void WriteGeneratedCodeFile(byte[] contentArray, string destinationFileBaseName,
string generatedExtension, string intellisenseGeneratedExtension, string languageSourceExtension)
{
if (String.IsNullOrEmpty(destinationFileBaseName))
if (string.IsNullOrEmpty(destinationFileBaseName))
{
throw new ArgumentNullException(nameof(destinationFileBaseName));
}
@ -434,7 +434,7 @@ namespace MS.Internal
private Task _buildTask;
private IVsMSBuildTaskFileManager _hostFileManager;
private Nullable<bool> _isRealBuild;
private bool? _isRealBuild;
private static Guid s_hashSHA256Guid = new Guid(0x8829d00f, 0x11b8, 0x4213, 0x87, 0x8b, 0x77, 0x0e, 0x85, 0x97, 0xac, 0x16);
private static Guid s_hashSHA1Guid = new Guid(0xff1816ec, 0xaa5e, 0x4d10, 0x87, 0xf7, 0x6f, 0x49, 0x63, 0x83, 0x34, 0x60);
private static Guid s_hashMD5Guid = new Guid(0x406ea660, 0x64cf, 0x4c82, 0xb6, 0xf0, 0x42, 0xd4, 0x81, 0x72, 0xa7, 0x99);

Просмотреть файл

@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@ -344,7 +344,7 @@ namespace Microsoft.Build.Tasks.Windows
string sourceDir,
bool requestExtensionChange)
{
string relPath = String.Empty;
string relPath;
// Please note the subtle distinction between <Link /> and <LogicalName />.
// <Link /> is treated as a fully resolvable path and is put through the same
@ -356,7 +356,7 @@ namespace Microsoft.Build.Tasks.Windows
// said in most of the regular scenarios using <Link /> or <Logical /> will result in
// the same resourceId being picked.
if (!String.IsNullOrEmpty(logicalName))
if (!string.IsNullOrEmpty(logicalName))
{
// Use the LogicalName when there is one
logicalName = ReplaceXAMLWithBAML(filePath, logicalName, requestExtensionChange);

Просмотреть файл

@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
@ -102,29 +102,18 @@ namespace System.Windows.Markup
{
Debug.Assert(null != memberInfo, "Null passed for memberInfo to GetConverterType");
Type converterType = null;
// Try looking for the TypeConverter for the type using reflection.
string converterName = ReflectionHelper.GetTypeConverterAttributeData(memberInfo, out converterType);
if (converterType == null)
{
converterType = GetConverterTypeFromName(converterName);
}
return converterType;
string converterName = ReflectionHelper.GetTypeConverterAttributeData(memberInfo, out Type converterType);
return converterType ?? GetConverterTypeFromName(converterName);
}
#endif
internal static Type? GetConverterType(Type type)
{
Debug.Assert(null != type, "Null passed for type to GetConverterType");
Debug.Assert(type is not null, "Null passed for type to GetConverterType");
// Try looking for the TypeConverter for the type using reflection.
string? converterName = ReflectionHelper.GetTypeConverterAttributeData(type, out Type? converterType);
converterType ??= GetConverterTypeFromName(converterName);
return converterType;
return converterType ?? GetConverterTypeFromName(converterName);
}
private static Type? GetConverterTypeFromName(string? converterName)

Просмотреть файл

@ -8,6 +8,6 @@ public class ButtonTests
[WpfFact]
public void Button_Create()
{
Button button = new();
Button _ = new();
}
}

Просмотреть файл

@ -223,7 +223,7 @@ public class StaticExtensionTests
{
var extension = new StaticExtension("member");
TypeConverter converter = TypeDescriptor.GetConverter(extension);
InstanceDescriptor descriptor = Assert.IsType<InstanceDescriptor>(converter.ConvertTo(extension, typeof(InstanceDescriptor)));
Assert.IsType<InstanceDescriptor>(converter.ConvertTo(extension, typeof(InstanceDescriptor)));
Assert.Equal(extension.ToString(), converter.ConvertTo(extension, typeof(string)));
}

Просмотреть файл

@ -184,7 +184,7 @@ public class TypeExtensionTests
{
var extension = new TypeExtension("member");
TypeConverter converter = TypeDescriptor.GetConverter(extension);
InstanceDescriptor descriptor = Assert.IsType<InstanceDescriptor>(converter.ConvertTo(extension, typeof(InstanceDescriptor)));
Assert.IsType<InstanceDescriptor>(converter.ConvertTo(extension, typeof(InstanceDescriptor)));
Assert.Equal(extension.ToString(), converter.ConvertTo(extension, typeof(string)));
}