From 014ac5050dbd0e8af3ce8c60dc5a9ab956607a26 Mon Sep 17 00:00:00 2001 From: mary-georgiou-sonarsource Date: Fri, 22 Sep 2023 16:08:22 +0200 Subject: [PATCH 01/10] delete implementations --- .../Rules/ConsoleLogging.cs | 33 -------- .../Rules/ConsoleLoggingTest.cs | 46 ----------- .../TestCases/ConsoleLogging.cs | 78 ------------------- .../TestCases/ConsoleLogging_Conditionals1.cs | 38 --------- .../TestCases/ConsoleLogging_Conditionals2.cs | 21 ----- 5 files changed, 216 deletions(-) delete mode 100644 analyzers/src/SonarAnalyzer.CSharp/Rules/ConsoleLogging.cs delete mode 100644 analyzers/tests/SonarAnalyzer.UnitTest/Rules/ConsoleLoggingTest.cs delete mode 100644 analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging.cs delete mode 100644 analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals1.cs delete mode 100644 analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals2.cs diff --git a/analyzers/src/SonarAnalyzer.CSharp/Rules/ConsoleLogging.cs b/analyzers/src/SonarAnalyzer.CSharp/Rules/ConsoleLogging.cs deleted file mode 100644 index e50233adebb..00000000000 --- a/analyzers/src/SonarAnalyzer.CSharp/Rules/ConsoleLogging.cs +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarAnalyzer for .NET - * Copyright (C) 2015-2023 SonarSource SA - * mailto: contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -namespace SonarAnalyzer.Rules.CSharp -{ - [Obsolete("This rule is superseded by S106.")] - [DiagnosticAnalyzer(LanguageNames.CSharp)] - public sealed class ConsoleLogging : DoNotWriteToStandardOutputBase - { - private const string DiagnosticId = "S2228"; - private const string MessageFormat = "Remove this logging statement."; - - protected override DiagnosticDescriptor Rule => - DescriptorFactory.Create(DiagnosticId, MessageFormat); - } -} diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/ConsoleLoggingTest.cs b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/ConsoleLoggingTest.cs deleted file mode 100644 index d35f91fa6a0..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/ConsoleLoggingTest.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarAnalyzer for .NET - * Copyright (C) 2015-2023 SonarSource SA - * mailto: contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -using SonarAnalyzer.Rules.CSharp; - -namespace SonarAnalyzer.UnitTest.Rules -{ - [TestClass] - public class ConsoleLoggingTest - { - private readonly VerifierBuilder builder = new VerifierBuilder(); - - [TestMethod] - public void ConsoleLogging() => - builder.AddPaths("ConsoleLogging.cs").Verify(); - - [TestMethod] - public void ConsoleLogging_ConditionalDirectives1() => - builder.AddPaths("ConsoleLogging_Conditionals1.cs") - .WithConcurrentAnalysis(false) - .Verify(); - - [TestMethod] - public void ConsoleLogging_ConditionalDirectives2() => - builder.AddPaths("ConsoleLogging_Conditionals2.cs") - .WithConcurrentAnalysis(false) - .Verify(); - } -} diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging.cs deleted file mode 100644 index c6a7fdd8379..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; - -namespace Tests.Diagnostics -{ - public class ConsoleLogging - { - private static byte[] GenerateKey(byte[] key) - { - Console.WriteLine("debug key = {0}", BitConverter.ToString(key)); //Noncompliant {{Remove this logging statement.}} -// ^^^^^^^^^^^^^^^^^ - - Console.WriteLine(); //Noncompliant -// ^^^^^^^^^^^^^^^^^ - - Console.Write("debug key = {0}", BitConverter.ToString(key)); //Noncompliant -// ^^^^^^^^^^^^^ - - Console.Write(true); //Noncompliant -// ^^^^^^^^^^^^^ - - Console.ReadKey(); - System.Diagnostics.Debug.WriteLine("debug key = {0}", BitConverter.ToString(key)); - return key; - } - - public static void LogDebug(string message) => - Console.WriteLine(message); // Noncompliant - - private static void NestedMethod() - { - var s = GetData(); - string GetData() - { - Console.Write(true); // Noncompliant - return "data"; - } - } - - private string property1; - public string Property1 - { - get - { - Console.WriteLine("Property1 read"); // Noncompliant - return property1; - } - set - { - Console.WriteLine("Property1 written"); // Noncompliant - property1 = value; - } - } - } - - internal class Exceptions_MethodLevelConditionals - { - [System.Diagnostics.Conditional("Wrong conditional")] // Error [CS0633] - public static void LogDebugA(string message) - { - Console.WriteLine(); // Noncompliant - wrong conditional -// ^^^^^^^^^^^^^^^^^ - } - - [System.Diagnostics.Conditional("DEBUG")] - public static void LogDebugB(string message) - { - Console.WriteLine(); // compliant - in debug-only method - } - - [System.Diagnostics.Conditional("debug")] // wrong case - public static void LogDebugC(string message) - { - Console.WriteLine(); // Noncompliant - wrong case - } - } -} diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals1.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals1.cs deleted file mode 100644 index a046ee509b8..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals1.cs +++ /dev/null @@ -1,38 +0,0 @@ -#define DEBUG -#define debug -#define BLOCK1 - -using System; - -namespace Rules2015 -{ - class S2228_ConsoleWriteLineInDebugBlock - { - -#if DEBUG - public void Method1() - { - Console.WriteLine("Hello World"); // compliant - in a debug section - } -#else - public void DoStuff() - { - Console.WriteLine("Hello World"); // won't be processed - nodes aren't active - } -#endif - -#if debug - public void DoStuff() - { - Console.WriteLine("Hello World"); // Noncompliant - } -#endif - -#if BLOCK1 - public void Method2() - { - Console.WriteLine("Hello World"); // Noncompliant - } -#endif - } -} diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals2.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals2.cs deleted file mode 100644 index c666cc3d14e..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals2.cs +++ /dev/null @@ -1,21 +0,0 @@ -#define DEBUG -using System; - -namespace Rules2015 -{ - class S2228_ConsoleWriteLineInDebugBlock - { - -#if !DEBUG - public void Method1() - { - Console.WriteLine("Hello World"); // won't be processed - nodes aren't active - } -#else - public void DoStuff() - { - Console.WriteLine("Hello World"); // Noncompliant: false-positive (we don't handle logical operators in debug blocks) - } -#endif - } -} From 73a205a10d1d8846d26cf51572a1fe9c6af548bb Mon Sep 17 00:00:00 2001 From: mary-georgiou-sonarsource Date: Fri, 22 Sep 2023 16:09:01 +0200 Subject: [PATCH 02/10] remove from ruletypemapping --- .../SonarAnalyzer.UnitTest/PackagingTests/RuleTypeMappingCS.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/PackagingTests/RuleTypeMappingCS.cs b/analyzers/tests/SonarAnalyzer.UnitTest/PackagingTests/RuleTypeMappingCS.cs index 2897f98cd01..837ecfe7d87 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/PackagingTests/RuleTypeMappingCS.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/PackagingTests/RuleTypeMappingCS.cs @@ -2152,7 +2152,7 @@ internal static class RuleTypeMappingCS ["S2225"] = "BUG", // ["S2226"], // ["S2227"], - ["S2228"] = "VULNERABILITY", + // ["S2228"], // ["S2229"], // ["S2230"], // ["S2231"], From 69594edc160c56f9d608acd49bb201b7ea897486 Mon Sep 17 00:00:00 2001 From: mary-georgiou-sonarsource Date: Fri, 22 Sep 2023 16:12:43 +0200 Subject: [PATCH 03/10] delete rspec --- analyzers/rspec/cs/S2228.html | 26 -------------------------- analyzers/rspec/cs/S2228.json | 21 --------------------- 2 files changed, 47 deletions(-) delete mode 100644 analyzers/rspec/cs/S2228.html delete mode 100644 analyzers/rspec/cs/S2228.json diff --git a/analyzers/rspec/cs/S2228.html b/analyzers/rspec/cs/S2228.html deleted file mode 100644 index 1abffc5998f..00000000000 --- a/analyzers/rspec/cs/S2228.html +++ /dev/null @@ -1,26 +0,0 @@ -

This rule is deprecated; use {rule:csharpsquid:S106} instead.

-

Why is this an issue?

-

Debug statements are always useful during development. But include them in production code - particularly in code that runs client-side - and you -run the risk of inadvertently exposing sensitive information.

-

Noncompliant code example

-
-private void DoSomething()
-{
-    // ...
-    Console.WriteLine("so far, so good..."); // Noncompliant
-    // ...
-}
-
-

Exceptions

-

The following are ignored by this rule:

-
    -
  • Console Applications
  • -
  • Calls in methods decorated with [Conditional ("DEBUG")]
  • -
  • Calls included in DEBUG preprocessor branches (#if DEBUG)
  • -
-

Resources

- - diff --git a/analyzers/rspec/cs/S2228.json b/analyzers/rspec/cs/S2228.json deleted file mode 100644 index 3eb77bb1564..00000000000 --- a/analyzers/rspec/cs/S2228.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "title": "Console logging should not be used", - "type": "VULNERABILITY", - "code": { - "impacts": { - "SECURITY": "LOW" - }, - "attribute": "CONVENTIONAL" - }, - "status": "deprecated", - "remediation": { - "func": "Constant\/Issue", - "constantCost": "5min" - }, - "tags": [], - "defaultSeverity": "Minor", - "ruleSpecification": "RSPEC-2228", - "sqKey": "S2228", - "scope": "Main", - "quickfix": "unknown" -} From b38e8d372f387504da04fff0bac49ae829aa1f98 Mon Sep 17 00:00:00 2001 From: mary-georgiou-sonarsource Date: Fri, 22 Sep 2023 16:44:12 +0200 Subject: [PATCH 04/10] update ITs --- ...4a4-59fd-497b-bb52-4414b1320d29-S2228.json | 251 -------- ...leReferenceTypesExample--net6.0-S2228.json | 17 - ...4a4-59fd-497b-bb52-4414b1320d29-S2228.json | 43 -- .../akka.net/Akka--netstandard2.0-S2228.json | 121 ---- ...stRunner.Shared--netstandard2.0-S2228.json | 199 ------- ....Remote.TestKit--netstandard2.0-S2228.json | 17 - .../Akka.Streams--netstandard2.0-S2228.json | 550 ------------------ 7 files changed, 1198 deletions(-) delete mode 100644 analyzers/its/expected/AnalyzeGenerated.CS/AnalyzeGeneratedFiles-6389f4a4-59fd-497b-bb52-4414b1320d29-S2228.json delete mode 100644 analyzers/its/expected/Net6/NullableReferenceTypesExample--net6.0-S2228.json delete mode 100644 analyzers/its/expected/SkipGenerated.CS/SkipGeneratedFiles-6389f4a4-59fd-497b-bb52-4414b1320d29-S2228.json delete mode 100644 analyzers/its/expected/akka.net/Akka--netstandard2.0-S2228.json delete mode 100644 analyzers/its/expected/akka.net/Akka.MultiNodeTestRunner.Shared--netstandard2.0-S2228.json delete mode 100644 analyzers/its/expected/akka.net/Akka.Remote.TestKit--netstandard2.0-S2228.json delete mode 100644 analyzers/its/expected/akka.net/Akka.Streams--netstandard2.0-S2228.json diff --git a/analyzers/its/expected/AnalyzeGenerated.CS/AnalyzeGeneratedFiles-6389f4a4-59fd-497b-bb52-4414b1320d29-S2228.json b/analyzers/its/expected/AnalyzeGenerated.CS/AnalyzeGeneratedFiles-6389f4a4-59fd-497b-bb52-4414b1320d29-S2228.json deleted file mode 100644 index d9c3f4dae66..00000000000 --- a/analyzers/its/expected/AnalyzeGenerated.CS/AnalyzeGeneratedFiles-6389f4a4-59fd-497b-bb52-4414b1320d29-S2228.json +++ /dev/null @@ -1,251 +0,0 @@ -{ -"issues": [ -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/autogenerated_comment.cs#L11", -"region": { -"startLine": 11, -"startColumn": 13, -"endLine": 11, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/autogenerated_comment2.cs#L12", -"region": { -"startLine": 12, -"startColumn": 13, -"endLine": 12, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/autogenerated_comment3.cs#L12", -"region": { -"startLine": 12, -"startColumn": 13, -"endLine": 12, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/autogenerated_comment4.cs#L18", -"region": { -"startLine": 18, -"startColumn": 13, -"endLine": 18, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/class.designer.cs#L10", -"region": { -"startLine": 10, -"startColumn": 13, -"endLine": 10, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/class.g.cs#L10", -"region": { -"startLine": 10, -"startColumn": 13, -"endLine": 10, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/class.g.something.cs#L10", -"region": { -"startLine": 10, -"startColumn": 13, -"endLine": 10, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/class.generated.cs#L10", -"region": { -"startLine": 10, -"startColumn": 13, -"endLine": 10, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/class_generated.cs#L10", -"region": { -"startLine": 10, -"startColumn": 13, -"endLine": 10, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/compiler_generated.cs#L11", -"region": { -"startLine": 11, -"startColumn": 13, -"endLine": 11, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/compiler_generated_attr.cs#L11", -"region": { -"startLine": 11, -"startColumn": 13, -"endLine": 11, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/debugger_non_user_code.cs#L11", -"region": { -"startLine": 11, -"startColumn": 13, -"endLine": 11, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/debugger_non_user_code_attr.cs#L11", -"region": { -"startLine": 11, -"startColumn": 13, -"endLine": 11, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/generated_code_attr.cs#L11", -"region": { -"startLine": 11, -"startColumn": 13, -"endLine": 11, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/generated_code_attr2.cs#L11", -"region": { -"startLine": 11, -"startColumn": 13, -"endLine": 11, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/generated_region.cs#L10", -"region": { -"startLine": 10, -"startColumn": 13, -"endLine": 10, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/generated_region_2.cs#L10", -"region": { -"startLine": 10, -"startColumn": 13, -"endLine": 10, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/handwritten.cs#L11", -"region": { -"startLine": 11, -"startColumn": 13, -"endLine": 11, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/TEMPORARYGENERATEDFILE_class.cs#L10", -"region": { -"startLine": 10, -"startColumn": 13, -"endLine": 10, -"endColumn": 30 -} -} -} -] -} diff --git a/analyzers/its/expected/Net6/NullableReferenceTypesExample--net6.0-S2228.json b/analyzers/its/expected/Net6/NullableReferenceTypesExample--net6.0-S2228.json deleted file mode 100644 index c75147e28fc..00000000000 --- a/analyzers/its/expected/Net6/NullableReferenceTypesExample--net6.0-S2228.json +++ /dev/null @@ -1,17 +0,0 @@ -{ -"issues": [ -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/Net6/NullableReferenceTypesExample/NullableReferenceTypesExample.cs#L20", -"region": { -"startLine": 20, -"startColumn": 13, -"endLine": 20, -"endColumn": 30 -} -} -} -] -} diff --git a/analyzers/its/expected/SkipGenerated.CS/SkipGeneratedFiles-6389f4a4-59fd-497b-bb52-4414b1320d29-S2228.json b/analyzers/its/expected/SkipGenerated.CS/SkipGeneratedFiles-6389f4a4-59fd-497b-bb52-4414b1320d29-S2228.json deleted file mode 100644 index d270594c5cd..00000000000 --- a/analyzers/its/expected/SkipGenerated.CS/SkipGeneratedFiles-6389f4a4-59fd-497b-bb52-4414b1320d29-S2228.json +++ /dev/null @@ -1,43 +0,0 @@ -{ -"issues": [ -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/generated_region.cs#L10", -"region": { -"startLine": 10, -"startColumn": 13, -"endLine": 10, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/generated_region_2.cs#L10", -"region": { -"startLine": 10, -"startColumn": 13, -"endLine": 10, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/GeneratedCode.CS/handwritten.cs#L11", -"region": { -"startLine": 11, -"startColumn": 13, -"endLine": 11, -"endColumn": 30 -} -} -} -] -} diff --git a/analyzers/its/expected/akka.net/Akka--netstandard2.0-S2228.json b/analyzers/its/expected/akka.net/Akka--netstandard2.0-S2228.json deleted file mode 100644 index 5839046541e..00000000000 --- a/analyzers/its/expected/akka.net/Akka--netstandard2.0-S2228.json +++ /dev/null @@ -1,121 +0,0 @@ -{ -"issues": [ -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka/Actor/Futures.cs#L532", -"region": { -"startLine": 532, -"startColumn": 25, -"endLine": 532, -"endColumn": 42 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka/Actor/Futures.cs#L540", -"region": { -"startLine": 540, -"startColumn": 22, -"endLine": 540, -"endColumn": 39 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka/Dispatch/AbstractDispatcher.cs#L373", -"region": { -"startLine": 373, -"startColumn": 21, -"endLine": 373, -"endColumn": 38 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka/Dispatch/AbstractDispatcher.cs#L381", -"region": { -"startLine": 381, -"startColumn": 25, -"endLine": 381, -"endColumn": 42 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka/Dispatch/Mailbox.cs#L535", -"region": { -"startLine": 535, -"startColumn": 13, -"endLine": 535, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka/Event/LoggingBus.cs#L119", -"region": { -"startLine": 119, -"startColumn": 33, -"endLine": 119, -"endColumn": 50 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka/Event/StandardOutLogger.cs#L77", -"region": { -"startLine": 77, -"startColumn": 17, -"endLine": 77, -"endColumn": 34 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka/Util/StandardOutWriter.cs#L64", -"region": { -"startLine": 64, -"startColumn": 21, -"endLine": 64, -"endColumn": 38 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka/Util/StandardOutWriter.cs#L66", -"region": { -"startLine": 66, -"startColumn": 21, -"endLine": 66, -"endColumn": 34 -} -} -} -] -} diff --git a/analyzers/its/expected/akka.net/Akka.MultiNodeTestRunner.Shared--netstandard2.0-S2228.json b/analyzers/its/expected/akka.net/Akka.MultiNodeTestRunner.Shared--netstandard2.0-S2228.json deleted file mode 100644 index 17051c1265f..00000000000 --- a/analyzers/its/expected/akka.net/Akka.MultiNodeTestRunner.Shared--netstandard2.0-S2228.json +++ /dev/null @@ -1,199 +0,0 @@ -{ -"issues": [ -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/Reporting/TeamCityLoggerActor.cs#L28", -"region": { -"startLine": 28, -"startColumn": 21, -"endLine": 28, -"endColumn": 38 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/Sinks/ConsoleMessageSinkActor.cs#L143", -"region": { -"startLine": 143, -"startColumn": 13, -"endLine": 143, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/Sinks/ConsoleMessageSinkActor.cs#L150", -"region": { -"startLine": 150, -"startColumn": 13, -"endLine": 150, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/Sinks/ConsoleMessageSinkActor.cs#L157", -"region": { -"startLine": 157, -"startColumn": 13, -"endLine": 157, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/Sinks/ConsoleMessageSinkActor.cs#L164", -"region": { -"startLine": 164, -"startColumn": 13, -"endLine": 164, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/Sinks/ConsoleMessageSinkActor.cs#L170", -"region": { -"startLine": 170, -"startColumn": 13, -"endLine": 170, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/Sinks/ConsoleMessageSinkActor.cs#L211", -"region": { -"startLine": 211, -"startColumn": 13, -"endLine": 211, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/Sinks/FileSystemMessageSinkActor.cs#L68", -"region": { -"startLine": 68, -"startColumn": 17, -"endLine": 68, -"endColumn": 34 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/Sinks/FileSystemMessageSinkActor.cs#L76", -"region": { -"startLine": 76, -"startColumn": 21, -"endLine": 76, -"endColumn": 38 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/Sinks/FileSystemMessageSinkActor.cs#L79", -"region": { -"startLine": 79, -"startColumn": 17, -"endLine": 79, -"endColumn": 34 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/Sinks/TeamCityMessageSinkActor.cs#L114", -"region": { -"startLine": 114, -"startColumn": 13, -"endLine": 114, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/Sinks/TimelineLogCollectorActor.cs#L75", -"region": { -"startLine": 75, -"startColumn": 21, -"endLine": 75, -"endColumn": 38 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/Sinks/TimelineLogCollectorActor.cs#L79", -"region": { -"startLine": 79, -"startColumn": 29, -"endLine": 79, -"endColumn": 46 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/Sinks/TimelineLogCollectorActor.cs#L81", -"region": { -"startLine": 81, -"startColumn": 21, -"endLine": 81, -"endColumn": 38 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.MultiNodeTestRunner.Shared/TrxReporter/TrxMessageSink.cs#L24", -"region": { -"startLine": 24, -"startColumn": 13, -"endLine": 24, -"endColumn": 30 -} -} -} -] -} diff --git a/analyzers/its/expected/akka.net/Akka.Remote.TestKit--netstandard2.0-S2228.json b/analyzers/its/expected/akka.net/Akka.Remote.TestKit--netstandard2.0-S2228.json deleted file mode 100644 index e1fa0ec1dab..00000000000 --- a/analyzers/its/expected/akka.net/Akka.Remote.TestKit--netstandard2.0-S2228.json +++ /dev/null @@ -1,17 +0,0 @@ -{ -"issues": [ -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Remote.TestKit/MultiNodeSpec.cs#L687", -"region": { -"startLine": 687, -"startColumn": 21, -"endLine": 687, -"endColumn": 38 -} -} -} -] -} diff --git a/analyzers/its/expected/akka.net/Akka.Streams--netstandard2.0-S2228.json b/analyzers/its/expected/akka.net/Akka.Streams--netstandard2.0-S2228.json deleted file mode 100644 index dc21cf6d568..00000000000 --- a/analyzers/its/expected/akka.net/Akka.Streams--netstandard2.0-S2228.json +++ /dev/null @@ -1,550 +0,0 @@ -{ -"issues": [ -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/ActorMaterializerImpl.cs#L127", -"region": { -"startLine": 127, -"startColumn": 21, -"endLine": 127, -"endColumn": 38 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs#L268", -"region": { -"startLine": 268, -"startColumn": 34, -"endLine": 268, -"endColumn": 51 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs#L273", -"region": { -"startLine": 273, -"startColumn": 34, -"endLine": 273, -"endColumn": 51 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs#L278", -"region": { -"startLine": 278, -"startColumn": 34, -"endLine": 278, -"endColumn": 51 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs#L293", -"region": { -"startLine": 293, -"startColumn": 34, -"endLine": 293, -"endColumn": 51 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs#L298", -"region": { -"startLine": 298, -"startColumn": 34, -"endLine": 298, -"endColumn": 51 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs#L303", -"region": { -"startLine": 303, -"startColumn": 34, -"endLine": 303, -"endColumn": 51 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs#L309", -"region": { -"startLine": 309, -"startColumn": 34, -"endLine": 309, -"endColumn": 51 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs#L1236", -"region": { -"startLine": 1236, -"startColumn": 29, -"endLine": 1236, -"endColumn": 46 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs#L1364", -"region": { -"startLine": 1364, -"startColumn": 21, -"endLine": 1364, -"endColumn": 38 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/ActorGraphInterpreter.cs#L1503", -"region": { -"startLine": 1503, -"startColumn": 21, -"endLine": 1503, -"endColumn": 38 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs#L89", -"region": { -"startLine": 89, -"startColumn": 26, -"endLine": 89, -"endColumn": 43 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs#L570", -"region": { -"startLine": 570, -"startColumn": 61, -"endLine": 570, -"endColumn": 78 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs#L950", -"region": { -"startLine": 950, -"startColumn": 13, -"endLine": 950, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs#L951", -"region": { -"startLine": 951, -"startColumn": 13, -"endLine": 951, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs#L952", -"region": { -"startLine": 952, -"startColumn": 38, -"endLine": 952, -"endColumn": 55 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs#L953", -"region": { -"startLine": 953, -"startColumn": 13, -"endLine": 953, -"endColumn": 30 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/Fusing.cs#L954", -"region": { -"startLine": 954, -"startColumn": 38, -"endLine": 954, -"endColumn": 55 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs#L544", -"region": { -"startLine": 544, -"startColumn": 26, -"endLine": 544, -"endColumn": 43 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs#L555", -"region": { -"startLine": 555, -"startColumn": 26, -"endLine": 555, -"endColumn": 43 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs#L650", -"region": { -"startLine": 650, -"startColumn": 17, -"endLine": 650, -"endColumn": 34 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs#L751", -"region": { -"startLine": 751, -"startColumn": 26, -"endLine": 751, -"endColumn": 43 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs#L796", -"region": { -"startLine": 796, -"startColumn": 30, -"endLine": 796, -"endColumn": 47 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs#L845", -"region": { -"startLine": 845, -"startColumn": 30, -"endLine": 845, -"endColumn": 47 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs#L856", -"region": { -"startLine": 856, -"startColumn": 34, -"endLine": 856, -"endColumn": 51 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs#L1021", -"region": { -"startLine": 1021, -"startColumn": 26, -"endLine": 1021, -"endColumn": 43 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs#L1045", -"region": { -"startLine": 1045, -"startColumn": 26, -"endLine": 1045, -"endColumn": 43 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs#L1073", -"region": { -"startLine": 1073, -"startColumn": 26, -"endLine": 1073, -"endColumn": 43 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/Fusing/GraphInterpreter.cs#L1100", -"region": { -"startLine": 1100, -"startColumn": 36, -"endLine": 1100, -"endColumn": 53 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/StreamLayout.cs#L2215", -"region": { -"startLine": 2215, -"startColumn": 17, -"endLine": 2215, -"endColumn": 34 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/StreamLayout.cs#L2240", -"region": { -"startLine": 2240, -"startColumn": 17, -"endLine": 2240, -"endColumn": 34 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/StreamLayout.cs#L2265", -"region": { -"startLine": 2265, -"startColumn": 17, -"endLine": 2265, -"endColumn": 34 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/StreamLayout.cs#L2335", -"region": { -"startLine": 2335, -"startColumn": 26, -"endLine": 2335, -"endColumn": 43 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/StreamLayout.cs#L2355", -"region": { -"startLine": 2355, -"startColumn": 17, -"endLine": 2355, -"endColumn": 34 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/StreamLayout.cs#L2379", -"region": { -"startLine": 2379, -"startColumn": 17, -"endLine": 2379, -"endColumn": 34 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/StreamLayout.cs#L2380", -"region": { -"startLine": 2380, -"startColumn": 17, -"endLine": 2380, -"endColumn": 34 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/StreamLayout.cs#L2381", -"region": { -"startLine": 2381, -"startColumn": 17, -"endLine": 2381, -"endColumn": 34 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/StreamLayout.cs#L2389", -"region": { -"startLine": 2389, -"startColumn": 21, -"endLine": 2389, -"endColumn": 38 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/StreamLayout.cs#L2393", -"region": { -"startLine": 2393, -"startColumn": 17, -"endLine": 2393, -"endColumn": 34 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/StreamLayout.cs#L2421", -"region": { -"startLine": 2421, -"startColumn": 17, -"endLine": 2421, -"endColumn": 34 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/StreamLayout.cs#L2443", -"region": { -"startLine": 2443, -"startColumn": 17, -"endLine": 2443, -"endColumn": 34 -} -} -}, -{ -"id": "S2228", -"message": "Remove this logging statement.", -"location": { -"uri": "https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/its/sources/akka.net/src/core/Akka.Streams/Implementation/StreamLayout.cs#L2448", -"region": { -"startLine": 2448, -"startColumn": 21, -"endLine": 2448, -"endColumn": 38 -} -} -} -] -} From ea04dc597e29cd4eeca3d6e519dfb87956459d3d Mon Sep 17 00:00:00 2001 From: mary-georgiou-sonarsource Date: Mon, 25 Sep 2023 09:21:35 +0200 Subject: [PATCH 05/10] delete test file --- .../Rules/DoNotWriteToStandardOutputTest.cs | 46 ------------------- 1 file changed, 46 deletions(-) delete mode 100644 analyzers/tests/SonarAnalyzer.UnitTest/Rules/DoNotWriteToStandardOutputTest.cs diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/DoNotWriteToStandardOutputTest.cs b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/DoNotWriteToStandardOutputTest.cs deleted file mode 100644 index a5962f3ca15..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/DoNotWriteToStandardOutputTest.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarAnalyzer for .NET - * Copyright (C) 2015-2023 SonarSource SA - * mailto: contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -using SonarAnalyzer.Rules.CSharp; - -namespace SonarAnalyzer.UnitTest.Rules -{ - [TestClass] - public class DoNotWriteToStandardOutputTest - { - private readonly VerifierBuilder builder = new VerifierBuilder(); - - [TestMethod] - public void DoNotWriteToStandardOutput() => - builder.AddPaths("ConsoleLogging.cs").Verify(); - - [TestMethod] - public void DoNotWriteToStandardOutput_ConditionalDirectives1() => - builder.AddPaths("ConsoleLogging_Conditionals1.cs") - .WithConcurrentAnalysis(false) - .Verify(); - - [TestMethod] - public void DoNotWriteToStandardOutput_ConditionalDirectives2() => - builder.AddPaths("ConsoleLogging_Conditionals2.cs") - .WithConcurrentAnalysis(false) - .Verify(); - } -} From fef5c3cfe24fc256e6fe8009a3cff3092f9186dd Mon Sep 17 00:00:00 2001 From: mary-georgiou-sonarsource Date: Tue, 26 Sep 2023 14:02:27 +0200 Subject: [PATCH 06/10] Revert "delete test file" This reverts commit ea04dc597e29cd4eeca3d6e519dfb87956459d3d. --- .../Rules/DoNotWriteToStandardOutputTest.cs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 analyzers/tests/SonarAnalyzer.UnitTest/Rules/DoNotWriteToStandardOutputTest.cs diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/DoNotWriteToStandardOutputTest.cs b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/DoNotWriteToStandardOutputTest.cs new file mode 100644 index 00000000000..a5962f3ca15 --- /dev/null +++ b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/DoNotWriteToStandardOutputTest.cs @@ -0,0 +1,46 @@ +/* + * SonarAnalyzer for .NET + * Copyright (C) 2015-2023 SonarSource SA + * mailto: contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +using SonarAnalyzer.Rules.CSharp; + +namespace SonarAnalyzer.UnitTest.Rules +{ + [TestClass] + public class DoNotWriteToStandardOutputTest + { + private readonly VerifierBuilder builder = new VerifierBuilder(); + + [TestMethod] + public void DoNotWriteToStandardOutput() => + builder.AddPaths("ConsoleLogging.cs").Verify(); + + [TestMethod] + public void DoNotWriteToStandardOutput_ConditionalDirectives1() => + builder.AddPaths("ConsoleLogging_Conditionals1.cs") + .WithConcurrentAnalysis(false) + .Verify(); + + [TestMethod] + public void DoNotWriteToStandardOutput_ConditionalDirectives2() => + builder.AddPaths("ConsoleLogging_Conditionals2.cs") + .WithConcurrentAnalysis(false) + .Verify(); + } +} From eb17efb8ca0ebbc65e2e35bdce9c6bb08393c9ec Mon Sep 17 00:00:00 2001 From: mary-georgiou-sonarsource Date: Tue, 26 Sep 2023 14:03:31 +0200 Subject: [PATCH 07/10] Revert "delete implementations" This reverts commit 014ac5050dbd0e8af3ce8c60dc5a9ab956607a26. --- .../Rules/ConsoleLogging.cs | 33 ++++++++ .../Rules/ConsoleLoggingTest.cs | 46 +++++++++++ .../TestCases/ConsoleLogging.cs | 78 +++++++++++++++++++ .../TestCases/ConsoleLogging_Conditionals1.cs | 38 +++++++++ .../TestCases/ConsoleLogging_Conditionals2.cs | 21 +++++ 5 files changed, 216 insertions(+) create mode 100644 analyzers/src/SonarAnalyzer.CSharp/Rules/ConsoleLogging.cs create mode 100644 analyzers/tests/SonarAnalyzer.UnitTest/Rules/ConsoleLoggingTest.cs create mode 100644 analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging.cs create mode 100644 analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals1.cs create mode 100644 analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals2.cs diff --git a/analyzers/src/SonarAnalyzer.CSharp/Rules/ConsoleLogging.cs b/analyzers/src/SonarAnalyzer.CSharp/Rules/ConsoleLogging.cs new file mode 100644 index 00000000000..e50233adebb --- /dev/null +++ b/analyzers/src/SonarAnalyzer.CSharp/Rules/ConsoleLogging.cs @@ -0,0 +1,33 @@ +/* + * SonarAnalyzer for .NET + * Copyright (C) 2015-2023 SonarSource SA + * mailto: contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +namespace SonarAnalyzer.Rules.CSharp +{ + [Obsolete("This rule is superseded by S106.")] + [DiagnosticAnalyzer(LanguageNames.CSharp)] + public sealed class ConsoleLogging : DoNotWriteToStandardOutputBase + { + private const string DiagnosticId = "S2228"; + private const string MessageFormat = "Remove this logging statement."; + + protected override DiagnosticDescriptor Rule => + DescriptorFactory.Create(DiagnosticId, MessageFormat); + } +} diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/ConsoleLoggingTest.cs b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/ConsoleLoggingTest.cs new file mode 100644 index 00000000000..d35f91fa6a0 --- /dev/null +++ b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/ConsoleLoggingTest.cs @@ -0,0 +1,46 @@ +/* + * SonarAnalyzer for .NET + * Copyright (C) 2015-2023 SonarSource SA + * mailto: contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +using SonarAnalyzer.Rules.CSharp; + +namespace SonarAnalyzer.UnitTest.Rules +{ + [TestClass] + public class ConsoleLoggingTest + { + private readonly VerifierBuilder builder = new VerifierBuilder(); + + [TestMethod] + public void ConsoleLogging() => + builder.AddPaths("ConsoleLogging.cs").Verify(); + + [TestMethod] + public void ConsoleLogging_ConditionalDirectives1() => + builder.AddPaths("ConsoleLogging_Conditionals1.cs") + .WithConcurrentAnalysis(false) + .Verify(); + + [TestMethod] + public void ConsoleLogging_ConditionalDirectives2() => + builder.AddPaths("ConsoleLogging_Conditionals2.cs") + .WithConcurrentAnalysis(false) + .Verify(); + } +} diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging.cs new file mode 100644 index 00000000000..c6a7fdd8379 --- /dev/null +++ b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; + +namespace Tests.Diagnostics +{ + public class ConsoleLogging + { + private static byte[] GenerateKey(byte[] key) + { + Console.WriteLine("debug key = {0}", BitConverter.ToString(key)); //Noncompliant {{Remove this logging statement.}} +// ^^^^^^^^^^^^^^^^^ + + Console.WriteLine(); //Noncompliant +// ^^^^^^^^^^^^^^^^^ + + Console.Write("debug key = {0}", BitConverter.ToString(key)); //Noncompliant +// ^^^^^^^^^^^^^ + + Console.Write(true); //Noncompliant +// ^^^^^^^^^^^^^ + + Console.ReadKey(); + System.Diagnostics.Debug.WriteLine("debug key = {0}", BitConverter.ToString(key)); + return key; + } + + public static void LogDebug(string message) => + Console.WriteLine(message); // Noncompliant + + private static void NestedMethod() + { + var s = GetData(); + string GetData() + { + Console.Write(true); // Noncompliant + return "data"; + } + } + + private string property1; + public string Property1 + { + get + { + Console.WriteLine("Property1 read"); // Noncompliant + return property1; + } + set + { + Console.WriteLine("Property1 written"); // Noncompliant + property1 = value; + } + } + } + + internal class Exceptions_MethodLevelConditionals + { + [System.Diagnostics.Conditional("Wrong conditional")] // Error [CS0633] + public static void LogDebugA(string message) + { + Console.WriteLine(); // Noncompliant - wrong conditional +// ^^^^^^^^^^^^^^^^^ + } + + [System.Diagnostics.Conditional("DEBUG")] + public static void LogDebugB(string message) + { + Console.WriteLine(); // compliant - in debug-only method + } + + [System.Diagnostics.Conditional("debug")] // wrong case + public static void LogDebugC(string message) + { + Console.WriteLine(); // Noncompliant - wrong case + } + } +} diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals1.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals1.cs new file mode 100644 index 00000000000..a046ee509b8 --- /dev/null +++ b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals1.cs @@ -0,0 +1,38 @@ +#define DEBUG +#define debug +#define BLOCK1 + +using System; + +namespace Rules2015 +{ + class S2228_ConsoleWriteLineInDebugBlock + { + +#if DEBUG + public void Method1() + { + Console.WriteLine("Hello World"); // compliant - in a debug section + } +#else + public void DoStuff() + { + Console.WriteLine("Hello World"); // won't be processed - nodes aren't active + } +#endif + +#if debug + public void DoStuff() + { + Console.WriteLine("Hello World"); // Noncompliant + } +#endif + +#if BLOCK1 + public void Method2() + { + Console.WriteLine("Hello World"); // Noncompliant + } +#endif + } +} diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals2.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals2.cs new file mode 100644 index 00000000000..c666cc3d14e --- /dev/null +++ b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals2.cs @@ -0,0 +1,21 @@ +#define DEBUG +using System; + +namespace Rules2015 +{ + class S2228_ConsoleWriteLineInDebugBlock + { + +#if !DEBUG + public void Method1() + { + Console.WriteLine("Hello World"); // won't be processed - nodes aren't active + } +#else + public void DoStuff() + { + Console.WriteLine("Hello World"); // Noncompliant: false-positive (we don't handle logical operators in debug blocks) + } +#endif + } +} From 7cf90d17e3b52d17c4c4b6ae8254dcd00a90921d Mon Sep 17 00:00:00 2001 From: mary-georgiou-sonarsource Date: Tue, 26 Sep 2023 14:08:24 +0200 Subject: [PATCH 08/10] apply comments --- .../Rules/ConsoleLogging.cs | 33 ------------- .../Rules/DoNotWriteToStandardOutput.cs | 20 +++----- .../Rules/ConsoleLoggingTest.cs | 46 ------------------- .../Rules/DoNotWriteToStandardOutputTest.cs | 6 +-- ...gging.cs => DoNotWriteToStandardOutput.cs} | 0 ...NotWriteToStandardOutput_Conditionals1.cs} | 0 ...NotWriteToStandardOutput_Conditionals2.cs} | 0 7 files changed, 9 insertions(+), 96 deletions(-) delete mode 100644 analyzers/src/SonarAnalyzer.CSharp/Rules/ConsoleLogging.cs delete mode 100644 analyzers/tests/SonarAnalyzer.UnitTest/Rules/ConsoleLoggingTest.cs rename analyzers/tests/SonarAnalyzer.UnitTest/TestCases/{ConsoleLogging.cs => DoNotWriteToStandardOutput.cs} (100%) rename analyzers/tests/SonarAnalyzer.UnitTest/TestCases/{ConsoleLogging_Conditionals1.cs => DoNotWriteToStandardOutput_Conditionals1.cs} (100%) rename analyzers/tests/SonarAnalyzer.UnitTest/TestCases/{ConsoleLogging_Conditionals2.cs => DoNotWriteToStandardOutput_Conditionals2.cs} (100%) diff --git a/analyzers/src/SonarAnalyzer.CSharp/Rules/ConsoleLogging.cs b/analyzers/src/SonarAnalyzer.CSharp/Rules/ConsoleLogging.cs deleted file mode 100644 index e50233adebb..00000000000 --- a/analyzers/src/SonarAnalyzer.CSharp/Rules/ConsoleLogging.cs +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarAnalyzer for .NET - * Copyright (C) 2015-2023 SonarSource SA - * mailto: contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -namespace SonarAnalyzer.Rules.CSharp -{ - [Obsolete("This rule is superseded by S106.")] - [DiagnosticAnalyzer(LanguageNames.CSharp)] - public sealed class ConsoleLogging : DoNotWriteToStandardOutputBase - { - private const string DiagnosticId = "S2228"; - private const string MessageFormat = "Remove this logging statement."; - - protected override DiagnosticDescriptor Rule => - DescriptorFactory.Create(DiagnosticId, MessageFormat); - } -} diff --git a/analyzers/src/SonarAnalyzer.CSharp/Rules/DoNotWriteToStandardOutput.cs b/analyzers/src/SonarAnalyzer.CSharp/Rules/DoNotWriteToStandardOutput.cs index fefde2a89a8..62c82e208a8 100644 --- a/analyzers/src/SonarAnalyzer.CSharp/Rules/DoNotWriteToStandardOutput.cs +++ b/analyzers/src/SonarAnalyzer.CSharp/Rules/DoNotWriteToStandardOutput.cs @@ -20,16 +20,18 @@ namespace SonarAnalyzer.Rules.CSharp { - // This base class is only there to avoid duplication between the implementation of S106 and S2228 - public abstract class DoNotWriteToStandardOutputBase : SonarDiagnosticAnalyzer + [DiagnosticAnalyzer(LanguageNames.CSharp)] + public class DoNotWriteToStandardOutput : SonarDiagnosticAnalyzer { - protected abstract DiagnosticDescriptor Rule { get; } + private const string DiagnosticId = "S106"; + private const string MessageFormat = "Remove this logging statement."; + protected DiagnosticDescriptor Rule => + DescriptorFactory.Create(DiagnosticId, MessageFormat); private static readonly ISet BannedConsoleMembers = new HashSet { "WriteLine", "Write" }; public override ImmutableArray SupportedDiagnostics => ImmutableArray.Create(Rule); - protected sealed override void Initialize(SonarAnalysisContext context) => context.RegisterNodeAction(c => { @@ -52,14 +54,4 @@ protected sealed override void Initialize(SonarAnalysisContext context) => }, SyntaxKind.InvocationExpression); } - - [DiagnosticAnalyzer(LanguageNames.CSharp)] - public class DoNotWriteToStandardOutput : DoNotWriteToStandardOutputBase - { - private const string DiagnosticId = "S106"; - private const string MessageFormat = "Remove this logging statement."; - - protected override DiagnosticDescriptor Rule => - DescriptorFactory.Create(DiagnosticId, MessageFormat); - } } diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/ConsoleLoggingTest.cs b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/ConsoleLoggingTest.cs deleted file mode 100644 index d35f91fa6a0..00000000000 --- a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/ConsoleLoggingTest.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarAnalyzer for .NET - * Copyright (C) 2015-2023 SonarSource SA - * mailto: contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -using SonarAnalyzer.Rules.CSharp; - -namespace SonarAnalyzer.UnitTest.Rules -{ - [TestClass] - public class ConsoleLoggingTest - { - private readonly VerifierBuilder builder = new VerifierBuilder(); - - [TestMethod] - public void ConsoleLogging() => - builder.AddPaths("ConsoleLogging.cs").Verify(); - - [TestMethod] - public void ConsoleLogging_ConditionalDirectives1() => - builder.AddPaths("ConsoleLogging_Conditionals1.cs") - .WithConcurrentAnalysis(false) - .Verify(); - - [TestMethod] - public void ConsoleLogging_ConditionalDirectives2() => - builder.AddPaths("ConsoleLogging_Conditionals2.cs") - .WithConcurrentAnalysis(false) - .Verify(); - } -} diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/DoNotWriteToStandardOutputTest.cs b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/DoNotWriteToStandardOutputTest.cs index a5962f3ca15..2df9cf5b55e 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/Rules/DoNotWriteToStandardOutputTest.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/Rules/DoNotWriteToStandardOutputTest.cs @@ -29,17 +29,17 @@ public class DoNotWriteToStandardOutputTest [TestMethod] public void DoNotWriteToStandardOutput() => - builder.AddPaths("ConsoleLogging.cs").Verify(); + builder.AddPaths("DoNotWriteToStandardOutput.cs").Verify(); [TestMethod] public void DoNotWriteToStandardOutput_ConditionalDirectives1() => - builder.AddPaths("ConsoleLogging_Conditionals1.cs") + builder.AddPaths("DoNotWriteToStandardOutput_Conditionals1.cs") .WithConcurrentAnalysis(false) .Verify(); [TestMethod] public void DoNotWriteToStandardOutput_ConditionalDirectives2() => - builder.AddPaths("ConsoleLogging_Conditionals2.cs") + builder.AddPaths("DoNotWriteToStandardOutput_Conditionals2.cs") .WithConcurrentAnalysis(false) .Verify(); } diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/DoNotWriteToStandardOutput.cs similarity index 100% rename from analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging.cs rename to analyzers/tests/SonarAnalyzer.UnitTest/TestCases/DoNotWriteToStandardOutput.cs diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals1.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/DoNotWriteToStandardOutput_Conditionals1.cs similarity index 100% rename from analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals1.cs rename to analyzers/tests/SonarAnalyzer.UnitTest/TestCases/DoNotWriteToStandardOutput_Conditionals1.cs diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals2.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/DoNotWriteToStandardOutput_Conditionals2.cs similarity index 100% rename from analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ConsoleLogging_Conditionals2.cs rename to analyzers/tests/SonarAnalyzer.UnitTest/TestCases/DoNotWriteToStandardOutput_Conditionals2.cs From 6ba4c006923a2a97b8dfdcb506abe092894a4348 Mon Sep 17 00:00:00 2001 From: mary-georgiou-sonarsource Date: Tue, 26 Sep 2023 14:09:16 +0200 Subject: [PATCH 09/10] add line break before method --- .../src/SonarAnalyzer.CSharp/Rules/DoNotWriteToStandardOutput.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/analyzers/src/SonarAnalyzer.CSharp/Rules/DoNotWriteToStandardOutput.cs b/analyzers/src/SonarAnalyzer.CSharp/Rules/DoNotWriteToStandardOutput.cs index 62c82e208a8..84b7d4ceead 100644 --- a/analyzers/src/SonarAnalyzer.CSharp/Rules/DoNotWriteToStandardOutput.cs +++ b/analyzers/src/SonarAnalyzer.CSharp/Rules/DoNotWriteToStandardOutput.cs @@ -25,6 +25,7 @@ public class DoNotWriteToStandardOutput : SonarDiagnosticAnalyzer { private const string DiagnosticId = "S106"; private const string MessageFormat = "Remove this logging statement."; + protected DiagnosticDescriptor Rule => DescriptorFactory.Create(DiagnosticId, MessageFormat); From 12bcaa1f9c81c0474c9510103e80b76fabe87955 Mon Sep 17 00:00:00 2001 From: mary-georgiou-sonarsource Date: Wed, 27 Sep 2023 10:43:14 +0200 Subject: [PATCH 10/10] apply comments --- .../SonarAnalyzer.CSharp/Rules/DoNotWriteToStandardOutput.cs | 2 +- .../TestCases/DoNotWriteToStandardOutput_Conditionals1.cs | 4 ++-- .../TestCases/DoNotWriteToStandardOutput_Conditionals2.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/analyzers/src/SonarAnalyzer.CSharp/Rules/DoNotWriteToStandardOutput.cs b/analyzers/src/SonarAnalyzer.CSharp/Rules/DoNotWriteToStandardOutput.cs index 84b7d4ceead..b1ab7d02af6 100644 --- a/analyzers/src/SonarAnalyzer.CSharp/Rules/DoNotWriteToStandardOutput.cs +++ b/analyzers/src/SonarAnalyzer.CSharp/Rules/DoNotWriteToStandardOutput.cs @@ -26,7 +26,7 @@ public class DoNotWriteToStandardOutput : SonarDiagnosticAnalyzer private const string DiagnosticId = "S106"; private const string MessageFormat = "Remove this logging statement."; - protected DiagnosticDescriptor Rule => + protected static DiagnosticDescriptor Rule => DescriptorFactory.Create(DiagnosticId, MessageFormat); private static readonly ISet BannedConsoleMembers = new HashSet { "WriteLine", "Write" }; diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/DoNotWriteToStandardOutput_Conditionals1.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/DoNotWriteToStandardOutput_Conditionals1.cs index a046ee509b8..39025b25321 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/DoNotWriteToStandardOutput_Conditionals1.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/DoNotWriteToStandardOutput_Conditionals1.cs @@ -4,9 +4,9 @@ using System; -namespace Rules2015 +namespace Tests.Diagnostics { - class S2228_ConsoleWriteLineInDebugBlock + class Tests { #if DEBUG diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/DoNotWriteToStandardOutput_Conditionals2.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/DoNotWriteToStandardOutput_Conditionals2.cs index c666cc3d14e..d73faca6683 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/DoNotWriteToStandardOutput_Conditionals2.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/DoNotWriteToStandardOutput_Conditionals2.cs @@ -1,9 +1,9 @@ #define DEBUG using System; -namespace Rules2015 +namespace Tests.Diagnostics { - class S2228_ConsoleWriteLineInDebugBlock + class Tests { #if !DEBUG