diff options
| author | David Cole <40234707+DavidArthurCole@users.noreply.github.com> | 2024-10-28 12:36:21 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-28 17:36:21 +0100 |
| commit | 88e72841f33c3a675ffd08001229b72a5f85793a (patch) | |
| tree | ec3bca71f9d992b2d9f49a2a84d42445af944b18 | |
| parent | 740a046c467a2b313c9aa04b87aeeca6e7632e46 (diff) | |
| download | SkyHanni-88e72841f33c3a675ffd08001229b72a5f85793a.tar.gz SkyHanni-88e72841f33c3a675ffd08001229b72a5f85793a.tar.bz2 SkyHanni-88e72841f33c3a675ffd08001229b72a5f85793a.zip | |
Backend Improvement: Companionize Detekt Rule Regex (#2853)
| -rw-r--r-- | detekt/src/main/kotlin/formatting/CustomCommentSpacing.kt | 14 |
1 files 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) + } } |
