From 88e72841f33c3a675ffd08001229b72a5f85793a Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Mon, 28 Oct 2024 12:36:21 -0400 Subject: Backend Improvement: Companionize Detekt Rule Regex (#2853) --- detekt/src/main/kotlin/formatting/CustomCommentSpacing.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/detekt/src/main/kotlin/formatting/CustomCommentSpacing.kt b/detekt/src/main/kotlin/formatting/CustomCommentSpacing.kt index db9f2f8a7..bfb0b1a4b 100644 --- a/detekt/src/main/kotlin/formatting/CustomCommentSpacing.kt +++ b/detekt/src/main/kotlin/formatting/CustomCommentSpacing.kt @@ -21,12 +21,6 @@ class CustomCommentSpacing(config: Config) : Rule(config) { override fun visitComment(comment: PsiComment) { if (comment.text.containsPreprocessingPattern()) return - - /** - * REGEX-TEST: // Test comment - * REGEX-TEST: /* Test comment */ - */ - val commentRegex = Regex("""^(?:\/{2}|\/\*)(?:\s.*|$)""", RegexOption.DOT_MATCHES_ALL) if (!commentRegex.matches(comment.text)) { report( CodeSmell( @@ -40,4 +34,12 @@ class CustomCommentSpacing(config: Config) : Rule(config) { // Fallback to super (ostensibly a no-check) super.visitComment(comment) } + + companion object { + /** + * REGEX-TEST: // Test comment + * REGEX-TEST: /* Test comment */ + */ + val commentRegex = Regex("""^(?:\/{2}|\/\*)(?:\s.*|$)""", RegexOption.DOT_MATCHES_ALL) + } } -- cgit