From e5a2d45f885044076ffb5ded554e775a7c37b657 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..6210a94aa03 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 'InsideMiddleOne'.}} + + public class MiddleOne + { + public class InsideMiddleOne + { + 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(); + } +}