You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Multiple warnings from the same KDoc element but different sections should all be suppressed when included in baseline file.
All the warnings show up in the detekt-baseline.xml file but only some get suppressed.
Observed Behavior
Only the last one in the baseline gets suppressed.
Steps to Reproduce
Create a rule that logs multiple warnings for a given class documentation.
Create a class that triggers the rule violation multiple times.
Run gradle detekt
See all the warnings
Run gradle detektBaseline
Run gradle detekt again
Some of the warnings are gone but not all
Context
I was creating new custom rule but only wanted to fix new instances of it and slowly fix old ones. Was trying to use baselines to not report old instances until they can be fixed.
I was able to work around the bug by flagging only one issue for the entire class at the class's documentation element.
Your Environment
Version of detekt used: 1.19.0
Version of Gradle used (if applicable): 7.2
Gradle scan link (add --scan option when running the gradle task):
Operating System and version: Mac OS 11.6.4
Link to your project (if it's a public repository):
I don't have this in a public repo, but a sample rule would be
class PropertiesDocumentedInClassDocumentation(config: Config = Config.empty) : Rule(config) {
override val issue: Issue
get() = Issue(
this.javaClass.simpleName,
Severity.Style,
"Documenting properties as tag in class documentation is not allowed due to how they are rendered in Xcode when using frameworks",
Debt.FIVE_MINS
)
override fun visitClass(klass: KtClass) {
super.visitClass(klass)
klass.docComment?.getChildrenOfType<KDocSection>()
?.filter { it.name == "property" }
.forEach { docSection ->
reportPropertyDoc(klass, docSection)
}
}
private fun reportPropertyDoc(classDeclaration: KtClass, docSection: KDocSection) {
val propertyName = "${classDeclaration.fqName.toString()}.${docSection.getSubjectName()}"
report(
CodeSmell(
issue, Entity.from(docSection),
"Documentation for $propertyName should not be in class documentation"
)
)
}
}
The run it against
/**
* Simple class.
* @property bar The bar.
* @property other Some other documentation.
*/
class Foo(
val bar: Bar,
val other: String,
)
The text was updated successfully, but these errors were encountered:
Expected Behavior
Multiple warnings from the same KDoc element but different sections should all be suppressed when included in baseline file.
All the warnings show up in the detekt-baseline.xml file but only some get suppressed.
Observed Behavior
Only the last one in the baseline gets suppressed.
Steps to Reproduce
Create a rule that logs multiple warnings for a given class documentation.
Create a class that triggers the rule violation multiple times.
Run gradle detekt
See all the warnings
Run gradle detektBaseline
Run gradle detekt again
Some of the warnings are gone but not all
Context
I was creating new custom rule but only wanted to fix new instances of it and slowly fix old ones. Was trying to use baselines to not report old instances until they can be fixed.
I was able to work around the bug by flagging only one issue for the entire class at the class's documentation element.
Your Environment
--scan
option when running the gradle task):I don't have this in a public repo, but a sample rule would be
The run it against
The text was updated successfully, but these errors were encountered: