Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EndOfSentenceFormat: fix HTML tag heuristic #5313

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -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 --
* ```
* <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