Skip to content

Commit

Permalink
EndOfSentenceFormat: fix HTML tag heuristic (#5313)
Browse files Browse the repository at this point in the history
  • Loading branch information
TWiStErRob committed Sep 18, 2022
1 parent 783a623 commit 8c11aaf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Expand Up @@ -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)
Expand Down
Expand Up @@ -142,6 +142,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 --
* ```
* <code>this contains HTML, but doesn't start with a tag</code>
* ```
*/
class Test {
}
""".trimIndent()
assertThat(subject.compileAndLint(code)).hasSize(1)
}

@Test
fun `does not report KDoc ending with periods`() {
val code = """
Expand Down

0 comments on commit 8c11aaf

Please sign in to comment.