From 864194cebbb9868b95da400c1180e211446b6c8d Mon Sep 17 00:00:00 2001 From: martin-strecker-sonarsource Date: Thu, 9 Mar 2023 08:38:08 +0000 Subject: [PATCH 1/9] Create rule S6513 --- rules/S6513/csharp/metadata.json | 2 ++ rules/S6513/csharp/rule.adoc | 22 ++++++++++++++++++++++ rules/S6513/metadata.json | 19 +++++++++++++++++++ rules/S6513/vbnet/metadata.json | 2 ++ rules/S6513/vbnet/rule.adoc | 22 ++++++++++++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 rules/S6513/csharp/metadata.json create mode 100644 rules/S6513/csharp/rule.adoc create mode 100644 rules/S6513/metadata.json create mode 100644 rules/S6513/vbnet/metadata.json create mode 100644 rules/S6513/vbnet/rule.adoc diff --git a/rules/S6513/csharp/metadata.json b/rules/S6513/csharp/metadata.json new file mode 100644 index 00000000000..7a73a41bfdf --- /dev/null +++ b/rules/S6513/csharp/metadata.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/rules/S6513/csharp/rule.adoc b/rules/S6513/csharp/rule.adoc new file mode 100644 index 00000000000..52f820374d1 --- /dev/null +++ b/rules/S6513/csharp/rule.adoc @@ -0,0 +1,22 @@ +FIXME: add a description + +// If you want to factorize the description uncomment the following line and create the file. +//include::../description.adoc[] + +== Noncompliant Code Example + +[source,csharp] +---- +FIXME +---- + +== Compliant Solution + +[source,csharp] +---- +FIXME +---- + +== See + +FIXME: A list of links \ No newline at end of file diff --git a/rules/S6513/metadata.json b/rules/S6513/metadata.json new file mode 100644 index 00000000000..a07eabe8ca2 --- /dev/null +++ b/rules/S6513/metadata.json @@ -0,0 +1,19 @@ +{ + "title": "FIXME", + "type": "CODE_SMELL", + "status": "ready", + "remediation": { + "func": "Constant\/Issue", + "constantCost": "5min" + }, + "tags": [ + ], + "extra": { + }, + "defaultSeverity": "Major", + "ruleSpecification": "RSPEC-6513", + "sqKey": "S6513", + "scope": "All", + "defaultQualityProfiles": ["Sonar way"], + "quickfix": "unknown" +} diff --git a/rules/S6513/vbnet/metadata.json b/rules/S6513/vbnet/metadata.json new file mode 100644 index 00000000000..7a73a41bfdf --- /dev/null +++ b/rules/S6513/vbnet/metadata.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/rules/S6513/vbnet/rule.adoc b/rules/S6513/vbnet/rule.adoc new file mode 100644 index 00000000000..b4daa3e17b7 --- /dev/null +++ b/rules/S6513/vbnet/rule.adoc @@ -0,0 +1,22 @@ +FIXME: add a description + +// If you want to factorize the description uncomment the following line and create the file. +//include::../description.adoc[] + +== Noncompliant Code Example + +[source,vbnet] +---- +FIXME +---- + +== Compliant Solution + +[source,vbnet] +---- +FIXME +---- + +== See + +FIXME: A list of links \ No newline at end of file From 648c119863c962ceaa95d02cc7e2a73d68a5350d Mon Sep 17 00:00:00 2001 From: Martin Strecker Date: Thu, 9 Mar 2023 12:37:37 +0100 Subject: [PATCH 2/9] Add description, links, and solutions --- rules/S6513/csharp/rule.adoc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/rules/S6513/csharp/rule.adoc b/rules/S6513/csharp/rule.adoc index 52f820374d1..db00d4d0984 100644 --- a/rules/S6513/csharp/rule.adoc +++ b/rules/S6513/csharp/rule.adoc @@ -1,22 +1,29 @@ -FIXME: add a description - -// If you want to factorize the description uncomment the following line and create the file. -//include::../description.adoc[] +include::../description.adoc[] == Noncompliant Code Example [source,csharp] ---- -FIXME +[ExcludeFromCodeCoverage] +public struct HashCode +{ + public static int Combine(T1 value1, T2 value2) + { + } +} ---- == Compliant Solution [source,csharp] ---- -FIXME +[ExcludeFromCodeCoverage(Justification = "Copy of https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/HashCode.cs for the .Net 4.8. Unit tests are in the upstream repo.")] +public struct HashCode +{ + public static int Combine(T1 value1, T2 value2) + { + } +} ---- -== See - -FIXME: A list of links \ No newline at end of file +include::../see.adoc[] \ No newline at end of file From 293e410dbfdd3d864148a8f5af13926eefe801f7 Mon Sep 17 00:00:00 2001 From: Martin Strecker Date: Thu, 9 Mar 2023 12:38:01 +0100 Subject: [PATCH 3/9] Add description, links and solutions --- rules/S6513/description.adoc | 1 + rules/S6513/metadata.json | 5 +++-- rules/S6513/see.adoc | 4 ++++ rules/S6513/vbnet/rule.adoc | 28 +++++++++++++++++++--------- 4 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 rules/S6513/description.adoc create mode 100644 rules/S6513/see.adoc diff --git a/rules/S6513/description.adoc b/rules/S6513/description.adoc new file mode 100644 index 00000000000..4bd8571b90e --- /dev/null +++ b/rules/S6513/description.adoc @@ -0,0 +1 @@ +The https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.excludefromcodecoverageattribute[ExcludeFromCodeCoverageAttribute] is used to exclude portions of code from https://learn.microsoft.com/dotnet/core/testing/unit-testing-code-coverage[code coverage reporting]. Code uncovered by unit tests is bad practice and needs a justification. \ No newline at end of file diff --git a/rules/S6513/metadata.json b/rules/S6513/metadata.json index a07eabe8ca2..84777f17541 100644 --- a/rules/S6513/metadata.json +++ b/rules/S6513/metadata.json @@ -1,5 +1,5 @@ { - "title": "FIXME", + "title": "\"ExcludeFromCodeCoverage\" attributes should include a justification", "type": "CODE_SMELL", "status": "ready", "remediation": { @@ -7,6 +7,7 @@ "constantCost": "5min" }, "tags": [ + "bad-practice" ], "extra": { }, @@ -14,6 +15,6 @@ "ruleSpecification": "RSPEC-6513", "sqKey": "S6513", "scope": "All", - "defaultQualityProfiles": ["Sonar way"], + "defaultQualityProfiles": [], "quickfix": "unknown" } diff --git a/rules/S6513/see.adoc b/rules/S6513/see.adoc new file mode 100644 index 00000000000..7c9140294a7 --- /dev/null +++ b/rules/S6513/see.adoc @@ -0,0 +1,4 @@ +== See + +* https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.excludefromcodecoverageattribute[API browser] - ExcludeFromCodeCoverageAttribute +* https://learn.microsoft.com/dotnet/core/testing/unit-testing-code-coverage[DevOps and testing] - Code coverage reporting \ No newline at end of file diff --git a/rules/S6513/vbnet/rule.adoc b/rules/S6513/vbnet/rule.adoc index b4daa3e17b7..003e6b2ed10 100644 --- a/rules/S6513/vbnet/rule.adoc +++ b/rules/S6513/vbnet/rule.adoc @@ -1,22 +1,32 @@ -FIXME: add a description - -// If you want to factorize the description uncomment the following line and create the file. -//include::../description.adoc[] +include::../description.adoc[] == Noncompliant Code Example [source,vbnet] ---- -FIXME + +Public Structure HashCode + Public Shared Function Combine(Of T1, T2)(value1 As T1, value2 As T2) As Integer + Dim hashCode = -1394996599 + hashCode = hashCode * -1521134295 + EqualityComparer(Of T1).[Default].GetHashCode(value1) + hashCode = hashCode * -1521134295 + EqualityComparer(Of T2).[Default].GetHashCode(value2) + Return hashCode + End Function +End Structure ---- == Compliant Solution [source,vbnet] ---- -FIXME + +Public Structure HashCode + Public Shared Function Combine(Of T1, T2)(value1 As T1, value2 As T2) As Integer + Dim hashCode = -1394996599 + hashCode = hashCode * -1521134295 + EqualityComparer(Of T1).[Default].GetHashCode(value1) + hashCode = hashCode * -1521134295 + EqualityComparer(Of T2).[Default].GetHashCode(value2) + Return hashCode +End Structure ---- -== See - -FIXME: A list of links \ No newline at end of file +include::../see.adoc[] \ No newline at end of file From d994986429e8c14787bbd5d6564ee151822ab1ba Mon Sep 17 00:00:00 2001 From: Martin Strecker Date: Thu, 9 Mar 2023 13:31:28 +0100 Subject: [PATCH 4/9] Change the(non) compliant samples --- rules/S6513/csharp/rule.adoc | 44 +++++++++++++++++++++---- rules/S6513/vbnet/rule.adoc | 63 +++++++++++++++++++++++++++++------- 2 files changed, 89 insertions(+), 18 deletions(-) diff --git a/rules/S6513/csharp/rule.adoc b/rules/S6513/csharp/rule.adoc index db00d4d0984..4f1d0153dd6 100644 --- a/rules/S6513/csharp/rule.adoc +++ b/rules/S6513/csharp/rule.adoc @@ -4,11 +4,27 @@ include::../description.adoc[] [source,csharp] ---- -[ExcludeFromCodeCoverage] -public struct HashCode +public struct Coordinates { - public static int Combine(T1 value1, T2 value2) + public Coordinates(int x, int y) { + X = x; + Y = y; + } + + public int X { get; } + public int Y { get; } + + [ExcludeFromCodeCoverage] + public override bool Equals(object obj) => obj is Coordinates coordinates && X == coordinates.X && Y == coordinates.Y; + + [ExcludeFromCodeCoverage] + public override int GetHashCode() + { + var hashCode = 1861411795; + hashCode = hashCode * -1521134295 + X.GetHashCode(); + hashCode = hashCode * -1521134295 + Y.GetHashCode(); + return hashCode; } } ---- @@ -17,11 +33,27 @@ public struct HashCode [source,csharp] ---- -[ExcludeFromCodeCoverage(Justification = "Copy of https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/HashCode.cs for the .Net 4.8. Unit tests are in the upstream repo.")] -public struct HashCode +public struct Coordinates { - public static int Combine(T1 value1, T2 value2) + public Coordinates(int x, int y) + { + X = x; + Y = y; + } + + public int X { get; } + public int Y { get; } + + [ExcludeFromCodeCoverage(Justification = "Code generated by the Visual Studio refactoring")] + public override bool Equals(object obj) => obj is Coordinates coordinates && X == coordinates.X && Y == coordinates.Y; + + [ExcludeFromCodeCoverage(Justification = "Code generated by the Visual Studio refactoring")] + public override int GetHashCode() { + var hashCode = 1861411795; + hashCode = hashCode * -1521134295 + X.GetHashCode(); + hashCode = hashCode * -1521134295 + Y.GetHashCode(); + return hashCode; } } ---- diff --git a/rules/S6513/vbnet/rule.adoc b/rules/S6513/vbnet/rule.adoc index 003e6b2ed10..cf9901200ed 100644 --- a/rules/S6513/vbnet/rule.adoc +++ b/rules/S6513/vbnet/rule.adoc @@ -4,12 +4,31 @@ include::../description.adoc[] [source,vbnet] ---- - -Public Structure HashCode - Public Shared Function Combine(Of T1, T2)(value1 As T1, value2 As T2) As Integer - Dim hashCode = -1394996599 - hashCode = hashCode * -1521134295 + EqualityComparer(Of T1).[Default].GetHashCode(value1) - hashCode = hashCode * -1521134295 + EqualityComparer(Of T2).[Default].GetHashCode(value2) +Public Structure Coordinates + Public Sub New(x As Integer, y As Integer) + Me.X = x + Me.Y = y + End Sub + + Public ReadOnly Property X As Integer + Public ReadOnly Property Y As Integer + + + Public Overrides Function Equals(obj As Object) As Boolean + If Not (TypeOf obj Is Coordinates) Then + Return False + End If + + Dim coordinates = DirectCast(obj, Coordinates) + Return X = coordinates.X AndAlso + Y = coordinates.Y + End Function + + + Public Overrides Function GetHashCode() As Integer + Dim hashCode As Long = 1861411795 + hashCode = (hashCode * -1521134295 + X.GetHashCode()).GetHashCode() + hashCode = (hashCode * -1521134295 + Y.GetHashCode()).GetHashCode() Return hashCode End Function End Structure @@ -19,13 +38,33 @@ End Structure [source,vbnet] ---- - -Public Structure HashCode - Public Shared Function Combine(Of T1, T2)(value1 As T1, value2 As T2) As Integer - Dim hashCode = -1394996599 - hashCode = hashCode * -1521134295 + EqualityComparer(Of T1).[Default].GetHashCode(value1) - hashCode = hashCode * -1521134295 + EqualityComparer(Of T2).[Default].GetHashCode(value2) +Public Structure Coordinates + Public Sub New(x As Integer, y As Integer) + Me.X = x + Me.Y = y + End Sub + + Public ReadOnly Property X As Integer + Public ReadOnly Property Y As Integer + + + Public Overrides Function Equals(obj As Object) As Boolean + If Not (TypeOf obj Is Coordinates) Then + Return False + End If + + Dim coordinates = DirectCast(obj, Coordinates) + Return X = coordinates.X AndAlso + Y = coordinates.Y + End Function + + + Public Overrides Function GetHashCode() As Integer + Dim hashCode As Long = 1861411795 + hashCode = (hashCode * -1521134295 + X.GetHashCode()).GetHashCode() + hashCode = (hashCode * -1521134295 + Y.GetHashCode()).GetHashCode() Return hashCode + End Function End Structure ---- From 1866207648be6dcf91ef7c9b7bc2946c16ac0401 Mon Sep 17 00:00:00 2001 From: Martin Strecker Date: Thu, 9 Mar 2023 16:39:19 +0100 Subject: [PATCH 5/9] Code review and added markers for Compliant/Noncompliant code --- rules/S6513/csharp/rule.adoc | 8 ++++---- rules/S6513/description.adoc | 2 +- rules/S6513/vbnet/rule.adoc | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/rules/S6513/csharp/rule.adoc b/rules/S6513/csharp/rule.adoc index 4f1d0153dd6..8127fa3468f 100644 --- a/rules/S6513/csharp/rule.adoc +++ b/rules/S6513/csharp/rule.adoc @@ -15,10 +15,10 @@ public struct Coordinates public int X { get; } public int Y { get; } - [ExcludeFromCodeCoverage] + [ExcludeFromCodeCoverage] // Noncompliant public override bool Equals(object obj) => obj is Coordinates coordinates && X == coordinates.X && Y == coordinates.Y; - [ExcludeFromCodeCoverage] + [ExcludeFromCodeCoverage] // Noncompliant public override int GetHashCode() { var hashCode = 1861411795; @@ -44,10 +44,10 @@ public struct Coordinates public int X { get; } public int Y { get; } - [ExcludeFromCodeCoverage(Justification = "Code generated by the Visual Studio refactoring")] + [ExcludeFromCodeCoverage(Justification = "Code generated by Visual Studio refactoring")] // Compliant public override bool Equals(object obj) => obj is Coordinates coordinates && X == coordinates.X && Y == coordinates.Y; - [ExcludeFromCodeCoverage(Justification = "Code generated by the Visual Studio refactoring")] + [ExcludeFromCodeCoverage(Justification = "Code generated by Visual Studio refactoring")] // Compliant public override int GetHashCode() { var hashCode = 1861411795; diff --git a/rules/S6513/description.adoc b/rules/S6513/description.adoc index 4bd8571b90e..c5a26411d15 100644 --- a/rules/S6513/description.adoc +++ b/rules/S6513/description.adoc @@ -1 +1 @@ -The https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.excludefromcodecoverageattribute[ExcludeFromCodeCoverageAttribute] is used to exclude portions of code from https://learn.microsoft.com/dotnet/core/testing/unit-testing-code-coverage[code coverage reporting]. Code uncovered by unit tests is bad practice and needs a justification. \ No newline at end of file +The https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.excludefromcodecoverageattribute[ExcludeFromCodeCoverageAttribute] is used to exclude portions of code from https://learn.microsoft.com/dotnet/core/testing/unit-testing-code-coverage[code coverage reporting]. Code not covered by unit tests is a bad practice and needs a justification. \ No newline at end of file diff --git a/rules/S6513/vbnet/rule.adoc b/rules/S6513/vbnet/rule.adoc index cf9901200ed..5bf1db53e0f 100644 --- a/rules/S6513/vbnet/rule.adoc +++ b/rules/S6513/vbnet/rule.adoc @@ -13,7 +13,7 @@ Public Structure Coordinates Public ReadOnly Property X As Integer Public ReadOnly Property Y As Integer - + ' Noncompliant Public Overrides Function Equals(obj As Object) As Boolean If Not (TypeOf obj Is Coordinates) Then Return False @@ -24,7 +24,7 @@ Public Structure Coordinates Y = coordinates.Y End Function - + ' Noncompliant Public Overrides Function GetHashCode() As Integer Dim hashCode As Long = 1861411795 hashCode = (hashCode * -1521134295 + X.GetHashCode()).GetHashCode() @@ -47,7 +47,7 @@ Public Structure Coordinates Public ReadOnly Property X As Integer Public ReadOnly Property Y As Integer - + ' Compliant Public Overrides Function Equals(obj As Object) As Boolean If Not (TypeOf obj Is Coordinates) Then Return False @@ -58,7 +58,7 @@ Public Structure Coordinates Y = coordinates.Y End Function - + ' Compliant Public Overrides Function GetHashCode() As Integer Dim hashCode As Long = 1861411795 hashCode = (hashCode * -1521134295 + X.GetHashCode()).GetHashCode() From 868c4087ffc4fdc3ef701ab51861f0e526c4a7f5 Mon Sep 17 00:00:00 2001 From: Martin Strecker Date: Mon, 13 Mar 2023 17:16:40 +0100 Subject: [PATCH 6/9] Code review. --- rules/S6513/csharp/rule.adoc | 12 ------------ rules/S6513/description.adoc | 2 +- rules/S6513/vbnet/rule.adoc | 12 ++---------- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/rules/S6513/csharp/rule.adoc b/rules/S6513/csharp/rule.adoc index 8127fa3468f..0a613d1d42e 100644 --- a/rules/S6513/csharp/rule.adoc +++ b/rules/S6513/csharp/rule.adoc @@ -6,12 +6,6 @@ include::../description.adoc[] ---- public struct Coordinates { - public Coordinates(int x, int y) - { - X = x; - Y = y; - } - public int X { get; } public int Y { get; } @@ -35,12 +29,6 @@ public struct Coordinates ---- public struct Coordinates { - public Coordinates(int x, int y) - { - X = x; - Y = y; - } - public int X { get; } public int Y { get; } diff --git a/rules/S6513/description.adoc b/rules/S6513/description.adoc index c5a26411d15..2a7e90e6327 100644 --- a/rules/S6513/description.adoc +++ b/rules/S6513/description.adoc @@ -1 +1 @@ -The https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.excludefromcodecoverageattribute[ExcludeFromCodeCoverageAttribute] is used to exclude portions of code from https://learn.microsoft.com/dotnet/core/testing/unit-testing-code-coverage[code coverage reporting]. Code not covered by unit tests is a bad practice and needs a justification. \ No newline at end of file +The https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.excludefromcodecoverageattribute[ExcludeFromCodeCoverageAttribute] is used to exclude portions of code from https://learn.microsoft.com/dotnet/core/testing/unit-testing-code-coverage[code coverage reporting]. Code that is not covered by unit tests is a bad practice. In .Net 5, the `Justification` property was added to the `ExcludeFromCodeCoverageAttribute` as an opportunity to document the rationale for the exclusion. An issue is raised when no such justification is given. \ No newline at end of file diff --git a/rules/S6513/vbnet/rule.adoc b/rules/S6513/vbnet/rule.adoc index 5bf1db53e0f..f6d5b3f24b1 100644 --- a/rules/S6513/vbnet/rule.adoc +++ b/rules/S6513/vbnet/rule.adoc @@ -5,10 +5,6 @@ include::../description.adoc[] [source,vbnet] ---- Public Structure Coordinates - Public Sub New(x As Integer, y As Integer) - Me.X = x - Me.Y = y - End Sub Public ReadOnly Property X As Integer Public ReadOnly Property Y As Integer @@ -39,15 +35,11 @@ End Structure [source,vbnet] ---- Public Structure Coordinates - Public Sub New(x As Integer, y As Integer) - Me.X = x - Me.Y = y - End Sub Public ReadOnly Property X As Integer Public ReadOnly Property Y As Integer - ' Compliant + ' Compliant Public Overrides Function Equals(obj As Object) As Boolean If Not (TypeOf obj Is Coordinates) Then Return False @@ -58,7 +50,7 @@ Public Structure Coordinates Y = coordinates.Y End Function - ' Compliant + ' Compliant Public Overrides Function GetHashCode() As Integer Dim hashCode As Long = 1861411795 hashCode = (hashCode * -1521134295 + X.GetHashCode()).GetHashCode() From 4eb7153ad6cddb9d13fe0691f567d48991f4467b Mon Sep 17 00:00:00 2001 From: Martin Strecker Date: Mon, 13 Mar 2023 17:27:29 +0100 Subject: [PATCH 7/9] Fix scope and defaultSeverity --- rules/S6513/metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/S6513/metadata.json b/rules/S6513/metadata.json index 84777f17541..4ae918700cd 100644 --- a/rules/S6513/metadata.json +++ b/rules/S6513/metadata.json @@ -11,10 +11,10 @@ ], "extra": { }, - "defaultSeverity": "Major", + "defaultSeverity": "Minor", "ruleSpecification": "RSPEC-6513", "sqKey": "S6513", - "scope": "All", + "scope": "Main", "defaultQualityProfiles": [], "quickfix": "unknown" } From c07809044247a0c3d9899cbf01ef2844b1fed7f7 Mon Sep 17 00:00:00 2001 From: Martin Strecker Date: Mon, 13 Mar 2023 17:31:50 +0100 Subject: [PATCH 8/9] Adopt description to the guideline. --- rules/S6513/description.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/S6513/description.adoc b/rules/S6513/description.adoc index 2a7e90e6327..ddad6e391d2 100644 --- a/rules/S6513/description.adoc +++ b/rules/S6513/description.adoc @@ -1 +1 @@ -The https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.excludefromcodecoverageattribute[ExcludeFromCodeCoverageAttribute] is used to exclude portions of code from https://learn.microsoft.com/dotnet/core/testing/unit-testing-code-coverage[code coverage reporting]. Code that is not covered by unit tests is a bad practice. In .Net 5, the `Justification` property was added to the `ExcludeFromCodeCoverageAttribute` as an opportunity to document the rationale for the exclusion. An issue is raised when no such justification is given. \ No newline at end of file +The https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.excludefromcodecoverageattribute[ExcludeFromCodeCoverageAttribute] is used to exclude portions of code from https://learn.microsoft.com/dotnet/core/testing/unit-testing-code-coverage[code coverage reporting]. Code that is not covered by unit tests is a bad practice. In .Net 5, the `Justification` property was added to the `ExcludeFromCodeCoverageAttribute` as an opportunity to document the rationale for the exclusion. This rule raises an issue when no such justification is given. \ No newline at end of file From 83942dd2f9e6bf841df7fa95831ec6205c6a33e2 Mon Sep 17 00:00:00 2001 From: Martin Strecker Date: Tue, 14 Mar 2023 12:00:45 +0100 Subject: [PATCH 9/9] Change wording --- rules/S6513/description.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/S6513/description.adoc b/rules/S6513/description.adoc index ddad6e391d2..e2eed157422 100644 --- a/rules/S6513/description.adoc +++ b/rules/S6513/description.adoc @@ -1 +1 @@ -The https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.excludefromcodecoverageattribute[ExcludeFromCodeCoverageAttribute] is used to exclude portions of code from https://learn.microsoft.com/dotnet/core/testing/unit-testing-code-coverage[code coverage reporting]. Code that is not covered by unit tests is a bad practice. In .Net 5, the `Justification` property was added to the `ExcludeFromCodeCoverageAttribute` as an opportunity to document the rationale for the exclusion. This rule raises an issue when no such justification is given. \ No newline at end of file +The https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.excludefromcodecoverageattribute[ExcludeFromCodeCoverageAttribute] is used to exclude portions of code from https://learn.microsoft.com/dotnet/core/testing/unit-testing-code-coverage[code coverage reporting]. It is a bad practice to retain code that is not covered by unit tests. In .Net 5, the `Justification` property was added to the `ExcludeFromCodeCoverageAttribute` as an opportunity to document the rationale for the exclusion. This rule raises an issue when no such justification is given. \ No newline at end of file