Skip to content

Commit

Permalink
fix for #1489
Browse files Browse the repository at this point in the history
  • Loading branch information
icemachined committed Sep 14, 2022
1 parent 9ca40d4 commit 391e26c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ class KdocFormatting(configRules: List<RulesConfig>) : DiktatRule(
.first()
.node
.startOffset, basicTags.first().node) {
val kdocSection = node.getFirstChildWithType(KDOC_SECTION)!!
val basicTagChildren = kdocTags
.filter { basicTagsOrdered.contains(it.knownTag) }
.map { it.node }
Expand All @@ -229,7 +228,8 @@ class KdocFormatting(configRules: List<RulesConfig>) : DiktatRule(
.map { it.node }

basicTagChildren.mapIndexed { index, astNode ->
kdocSection.treeParent.addChild(correctKdocOrder[index].clone() as CompositeElement, astNode.treeNext)
val kdocSection = astNode.treeParent
kdocSection.addChild(correctKdocOrder[index].clone() as CompositeElement, astNode)
kdocSection.removeChild(astNode)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,31 @@ class KdocFormattingTest : LintTestBase(::KdocFormatting) {
"${KDOC_WRONG_TAGS_ORDER.warnText()} @return, @throws, @param", true))
}

@Test
@Tag(WarningNames.KDOC_WRONG_TAGS_ORDER)
fun `tags should be ordered assertion issue`() {
val invalidCode = """
/**
* Reporter that produces a JSON report as a [Report]
*
* @property out a sink for output
*
* @param builder additional configuration lambda for serializers module
*/
class JsonReporter(
override val out: BufferedSink,
builder: PolymorphicModuleBuilder<Plugin.TestFiles>.() -> Unit = {}
) : Reporter
""".trimIndent()

lintMethod(invalidCode,
LintError(4, 4, ruleId,
"${KDOC_NO_NEWLINES_BETWEEN_BASIC_TAGS.warnText()} @property", true),
LintError(4, 4, ruleId,
"${KDOC_WRONG_TAGS_ORDER.warnText()} @property, @param", true)
)
}

@Test
@Tag(WarningNames.KDOC_NO_NEWLINES_BETWEEN_BASIC_TAGS)
fun `newlines are not allowed between basic tags`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ package com.saveourtool.save.reporter.json
* Reporter that produces a JSON report as a [Report]
*
* @property out a sink for output
*
* @param builder additional configuration lambda for serializers module
*/
class JsonReporter(
override val out: BufferedSink,
builder: PolymorphicModuleBuilder<Plugin.TestFiles>.() -> Unit = {}
) : Reporter
) : Reporter

0 comments on commit 391e26c

Please sign in to comment.