From 361b5125ba42c50d9ed991313f5d39fe62aac094 Mon Sep 17 00:00:00 2001 From: Andrei Epure Date: Tue, 28 Feb 2023 13:52:00 +0100 Subject: [PATCH] add edge case --- ...rivateStaticMethodUsedOnlyByNestedClass.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/PrivateStaticMethodUsedOnlyByNestedClass.cs b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/PrivateStaticMethodUsedOnlyByNestedClass.cs index a777726e1a4..a20400e8ef5 100644 --- a/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/PrivateStaticMethodUsedOnlyByNestedClass.cs +++ b/analyzers/tests/SonarAnalyzer.UnitTest/TestCases/PrivateStaticMethodUsedOnlyByNestedClass.cs @@ -185,3 +185,37 @@ void Foo() } } } + +public class EdgeCaseWithLongCommonPaths +{ + private static void StaticMethod() { } // Noncompliant {{Move this method inside 'MiddleTwo'.}} + + public class MiddleOne + { + public class MiddleTwo + { + public class Foo + { + public class FooLeaf + { + public void Method() => StaticMethod(); + } + } + + public class Bar + { + public void Method() => StaticMethod(); + public class BarLeaf + { + public void Method() => StaticMethod(); + } + } + } + } + public class MiddleTwo { + public void StaticMethod() + { + } + public void Method() => StaticMethod(); + } +}