Skip to content

Commit

Permalink
UpdateStringFormatToInterpolatableString should be in Assertion category
Browse files Browse the repository at this point in the history
  • Loading branch information
manfred-brands committed Oct 26, 2023
1 parent 9721d03 commit e90ff7e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
20 changes: 10 additions & 10 deletions documentation/NUnit1033.md → documentation/NUnit2050.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -77,31 +77,31 @@ 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`.

### 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...")]
```
<!-- end generated config severity -->
2 changes: 1 addition & 1 deletion documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 - )

Expand Down Expand Up @@ -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 - )

Expand Down
2 changes: 1 addition & 1 deletion src/nunit.analyzers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/nunit.analyzers.tests/nunit.analyzers.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<RootNamespace>NUnit.Analyzers.Tests</RootNamespace>
<TargetFrameworks>net6.0;net462</TargetFrameworks>
<NUnitVersion Condition="'$(NUnitVersion)'==''">3</NUnitVersion>
<NoWarn>$(NoWarn);NUnit1033</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(NUnitVersion)' == '4'">
Expand Down
2 changes: 1 addition & 1 deletion src/nunit.analyzers/Constants/AnalyzerIdentifiers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit e90ff7e

Please sign in to comment.