Skip to content

Commit

Permalink
Allow inline comments for properties in primary constructor as docume…
Browse files Browse the repository at this point in the history
…ntation (detekt#3722)

* Allow inline comments for properties in primary constructor
Fixes detekt#3677

* Revert blank line removal in UndocumentedPublicProperty

* - remove configuration
- update tests

* - remove unused import
  • Loading branch information
arhont375 authored and Chao Zhang committed May 13, 2021
1 parent b8871b9 commit 55d4059
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class UndocumentedPublicProperty(config: Config = Config.empty) : Rule(config) {
if (constructor.isPublicInherited()) {
val comment = constructor.containingClassOrObject?.docComment?.text
constructor.valueParameters
.filter { it.isPublicNotOverridden() && it.hasValOrVar() && it.isUndocumented(comment) }
.filter { it.isPublicNotOverridden() && it.hasValOrVar() }
.filter { it.isUndocumented(comment) && it.docComment == null }
.forEach { report(it) }
}
super.visitPrimaryConstructor(constructor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,16 @@ class UndocumentedPublicPropertySpec : Spek({
* @property [c] int3
* @param d int4
*/
class Test(val a: Int, val b: Int, val c: Int, val d: Int)
class Test(
val a: Int,
val b: Int,
val c: Int,
val d: Int,
/**
* Some docs.
*/
val e: Int
)
"""
assertThat(subject.compileAndLint(code)).isEmpty()
}
Expand Down

0 comments on commit 55d4059

Please sign in to comment.