From 1eaaf40a0a608da02fc35f8d2eae78dc68b985de Mon Sep 17 00:00:00 2001 From: Manfred Brands Date: Thu, 26 Oct 2023 11:41:24 +0800 Subject: [PATCH] UpdateStringFormatToInterpolatableString should be in Assertion category --- documentation/{NUnit1033.md => NUnit2050.md} | 20 +++++++++---------- documentation/index.md | 2 +- src/nunit.analyzers.sln | 2 +- .../nunit.analyzers.tests.csproj | 1 - .../Constants/AnalyzerIdentifiers.cs | 2 +- ...ingFormatToInterpolatableStringAnalyzer.cs | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) rename documentation/{NUnit1033.md => NUnit2050.md} (85%) diff --git a/documentation/NUnit1033.md b/documentation/NUnit2050.md similarity index 85% rename from documentation/NUnit1033.md rename to documentation/NUnit2050.md index 46e9aece..2ec0da35 100644 --- a/documentation/NUnit1033.md +++ b/documentation/NUnit2050.md @@ -1,13 +1,13 @@ -# NUnit1033 +# NUnit2050 ## NUnit 4 no longer supports string.Format specification | Topic | Value | :-- | :-- -| Id | NUnit1033 +| Id | NUnit2050 | Severity | Error | Enabled | True -| Category | Structure +| Category | Assertion | Code | [UpdateStringFormatToInterpolatableStringAnalyzer](https://github.com/nunit/nunit.analyzers/blob/master/src/nunit.analyzers/UpdateStringFormatToInterpolatableString/UpdateStringFormatToInterpolatableStringAnalyzer.cs) ## Description @@ -77,8 +77,8 @@ Configure the severity per project, for more info see [MSDN](https://learn.micro ### Via .editorconfig file ```ini -# NUnit1033: NUnit 4 no longer supports string.Format specification -dotnet_diagnostic.NUnit1033.severity = chosenSeverity +# NUnit2050: NUnit 4 no longer supports string.Format specification +dotnet_diagnostic.NUnit2050.severity = chosenSeverity ``` where `chosenSeverity` can be one of `none`, `silent`, `suggestion`, `warning`, or `error`. @@ -86,22 +86,22 @@ where `chosenSeverity` can be one of `none`, `silent`, `suggestion`, `warning`, ### Via #pragma directive ```csharp -#pragma warning disable NUnit1033 // NUnit 4 no longer supports string.Format specification +#pragma warning disable NUnit2050 // NUnit 4 no longer supports string.Format specification Code violating the rule here -#pragma warning restore NUnit1033 // NUnit 4 no longer supports string.Format specification +#pragma warning restore NUnit2050 // NUnit 4 no longer supports string.Format specification ``` Or put this at the top of the file to disable all instances. ```csharp -#pragma warning disable NUnit1033 // NUnit 4 no longer supports string.Format specification +#pragma warning disable NUnit2050 // NUnit 4 no longer supports string.Format specification ``` ### Via attribute `[SuppressMessage]` ```csharp -[System.Diagnostics.CodeAnalysis.SuppressMessage("Structure", - "NUnit1033:NUnit 4 no longer supports string.Format specification", +[System.Diagnostics.CodeAnalysis.SuppressMessage("Assertion", + "NUnit2050:NUnit 4 no longer supports string.Format specification", Justification = "Reason...")] ``` diff --git a/documentation/index.md b/documentation/index.md index d4983d29..29f975c2 100644 --- a/documentation/index.md +++ b/documentation/index.md @@ -51,7 +51,6 @@ Rules which enforce structural requirements on the test code. | [NUnit1030](https://github.com/nunit/nunit.analyzers/tree/master/documentation/NUnit1030.md) | The type of parameter provided by the TestCaseSource does not match the type of the parameter in the Test method | :white_check_mark: | :exclamation: | :x: | | [NUnit1031](https://github.com/nunit/nunit.analyzers/tree/master/documentation/NUnit1031.md) | The individual arguments provided by a ValuesAttribute must match the type of the corresponding parameter of the method | :white_check_mark: | :exclamation: | :x: | | [NUnit1032](https://github.com/nunit/nunit.analyzers/tree/master/documentation/NUnit1032.md) | An IDisposable field/property should be Disposed in a TearDown method | :white_check_mark: | :exclamation: | :x: | -| [NUnit1033](https://github.com/nunit/nunit.analyzers/tree/master/documentation/NUnit1033.md) | NUnit 4 no longer supports string.Format specification | :white_check_mark: | :exclamation: | :white_check_mark: | ### Assertion Rules (NUnit2001 - ) @@ -108,6 +107,7 @@ Rules which improve assertions in the test code. | [NUnit2047](https://github.com/nunit/nunit.analyzers/tree/master/documentation/NUnit2047.md) | Incompatible types for Within constraint | :white_check_mark: | :warning: | :white_check_mark: | | [NUnit2048](https://github.com/nunit/nunit.analyzers/tree/master/documentation/NUnit2048.md) | Consider using Assert.That(...) instead of StringAssert(...) | :white_check_mark: | :warning: | :white_check_mark: | | [NUnit2049](https://github.com/nunit/nunit.analyzers/tree/master/documentation/NUnit2049.md) | Consider using Assert.That(...) instead of CollectionAssert(...) | :white_check_mark: | :warning: | :white_check_mark: | +| [NUnit2050](https://github.com/nunit/nunit.analyzers/tree/master/documentation/NUnit2050.md) | NUnit 4 no longer supports string.Format specification | :white_check_mark: | :exclamation: | :white_check_mark: | ### Suppressor Rules (NUnit3001 - ) diff --git a/src/nunit.analyzers.sln b/src/nunit.analyzers.sln index 9c0167de..fb6e0c31 100644 --- a/src/nunit.analyzers.sln +++ b/src/nunit.analyzers.sln @@ -44,7 +44,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "documentation", "documentat ..\documentation\NUnit1030.md = ..\documentation\NUnit1030.md ..\documentation\NUnit1031.md = ..\documentation\NUnit1031.md ..\documentation\NUnit1032.md = ..\documentation\NUnit1032.md - ..\documentation\NUnit1033.md = ..\documentation\NUnit1033.md ..\documentation\NUnit2001.md = ..\documentation\NUnit2001.md ..\documentation\NUnit2002.md = ..\documentation\NUnit2002.md ..\documentation\NUnit2003.md = ..\documentation\NUnit2003.md @@ -94,6 +93,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "documentation", "documentat ..\documentation\NUnit2047.md = ..\documentation\NUnit2047.md ..\documentation\NUnit2048.md = ..\documentation\NUnit2048.md ..\documentation\NUnit2049.md = ..\documentation\NUnit2049.md + ..\documentation\NUnit2050.md = ..\documentation\NUnit2050.md ..\documentation\NUnit3001.md = ..\documentation\NUnit3001.md ..\documentation\NUnit3002.md = ..\documentation\NUnit3002.md ..\documentation\NUnit3003.md = ..\documentation\NUnit3003.md diff --git a/src/nunit.analyzers.tests/nunit.analyzers.tests.csproj b/src/nunit.analyzers.tests/nunit.analyzers.tests.csproj index f3dd17e0..15cecccf 100644 --- a/src/nunit.analyzers.tests/nunit.analyzers.tests.csproj +++ b/src/nunit.analyzers.tests/nunit.analyzers.tests.csproj @@ -3,7 +3,6 @@ NUnit.Analyzers.Tests net6.0;net462 3 - $(NoWarn);NUnit1033 diff --git a/src/nunit.analyzers/Constants/AnalyzerIdentifiers.cs b/src/nunit.analyzers/Constants/AnalyzerIdentifiers.cs index 80543773..19f7a29d 100644 --- a/src/nunit.analyzers/Constants/AnalyzerIdentifiers.cs +++ b/src/nunit.analyzers/Constants/AnalyzerIdentifiers.cs @@ -36,7 +36,6 @@ internal static class AnalyzerIdentifiers internal const string TestCaseSourceMismatchWithTestMethodParameterType = "NUnit1030"; internal const string ValuesParameterTypeMismatchUsage = "NUnit1031"; internal const string FieldIsNotDisposedInTearDown = "NUnit1032"; - internal const string UpdateStringFormatToInterpolatableString = "NUnit1033"; #endregion Structure @@ -91,6 +90,7 @@ internal static class AnalyzerIdentifiers internal const string WithinIncompatibleTypes = "NUnit2047"; internal const string StringAssertUsage = "NUnit2048"; internal const string CollectionAssertUsage = "NUnit2049"; + internal const string UpdateStringFormatToInterpolatableString = "NUnit2050"; #endregion Assertion diff --git a/src/nunit.analyzers/UpdateStringFormatToInterpolatableString/UpdateStringFormatToInterpolatableStringAnalyzer.cs b/src/nunit.analyzers/UpdateStringFormatToInterpolatableString/UpdateStringFormatToInterpolatableStringAnalyzer.cs index c22f0059..3f4efa4d 100644 --- a/src/nunit.analyzers/UpdateStringFormatToInterpolatableString/UpdateStringFormatToInterpolatableStringAnalyzer.cs +++ b/src/nunit.analyzers/UpdateStringFormatToInterpolatableString/UpdateStringFormatToInterpolatableStringAnalyzer.cs @@ -28,7 +28,7 @@ public sealed class UpdateStringFormatToInterpolatableStringAnalyzer : BaseAsser id: AnalyzerIdentifiers.UpdateStringFormatToInterpolatableString, title: UpdateStringFormatToInterpolatableStringConstants.UpdateStringFormatToInterpolatableStringTitle, messageFormat: UpdateStringFormatToInterpolatableStringConstants.UpdateStringFormatToInterpolatableStringMessage, - category: Categories.Structure, + category: Categories.Assertion, defaultSeverity: DiagnosticSeverity.Error, description: UpdateStringFormatToInterpolatableStringConstants.UpdateStringFormatToInterpolatableStringDescription);