diff --git a/detekt-rules-documentation/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormat.kt b/detekt-rules-documentation/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormat.kt index 30b9fdcb271..6530fae105f 100644 --- a/detekt-rules-documentation/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormat.kt +++ b/detekt-rules-documentation/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormat.kt @@ -29,7 +29,7 @@ class EndOfSentenceFormat(config: Config = Config.empty) : Rule(config) { @Configuration("regular expression which should match the end of the first sentence in the KDoc") private val endOfSentenceFormat: Regex by config("""([.?!][ \t\n\r\f<])|([.?!:]$)""") { it.toRegex() } - private val htmlTag = Regex("<.+>") + private val htmlTag = Regex("^<.+>") override fun visitDeclaration(dcl: KtDeclaration) { super.visitDeclaration(dcl) diff --git a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormatSpec.kt b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormatSpec.kt index 9bd93405884..ce15d0bd264 100644 --- a/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormatSpec.kt +++ b/detekt-rules-documentation/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/EndOfSentenceFormatSpec.kt @@ -140,6 +140,21 @@ class EndOfSentenceFormatSpec { assertThat(subject.compileAndLint(code)).isEmpty() } + @Test + fun `reports invalid KDoc even when it looks like it contains html tags`() { + val code = """ + /** + * < is the less-than sign -- + * ``` + * this contains HTML, but doesn't start with a tag + * ``` + */ + class Test { + } + """.trimIndent() + assertThat(subject.compileAndLint(code)).hasSize(1) + } + @Test fun `does not report KDoc ending with periods`() { val code = """