Report KDoc comments that refer to non-public properties of a class#4768
Conversation
New rule to address the issue of breaking encapsulation principle when KDoc comments have references to encapsulated (private) properties. Clients do not need to know the implementation details.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
@VitalyVPinchuk is attempting to deploy a commit to the Detekt Team on Vercel. A member of the Team first needs to authorize it. |
ba2c656 to
8e1bccc
Compare
8e1bccc to
b8700b6
Compare
|
Just curious - Should this rule also check the KDoc of methods and properties to verify it is not leaking private information? class C {
private var a: Int = 0
/**
* Mentioning [a]
*/
val b = "string"
/**
* Mentioning [a]
*/
fun foo() {
print("foo $a")
}
} |
I think it's a good idea! |
If you think they are valid, you could do so. I am just afraid that the rule will become overly complicated and hard to maintain. To be absolutely honest, I am not the biggest fan of documentation rules to begin with. Since you brought up the issue, you seem to have a clear use case. |
Codecov Report
@@ Coverage Diff @@
## main #4768 +/- ##
============================================
+ Coverage 84.69% 84.76% +0.06%
- Complexity 3418 3447 +29
============================================
Files 490 492 +2
Lines 11235 11302 +67
Branches 2068 2080 +12
============================================
+ Hits 9516 9580 +64
+ Misses 675 673 -2
- Partials 1044 1049 +5
Continue to review full report at Codecov.
|
b14a757 to
e99cd26
Compare
e99cd26 to
eed733c
Compare
Agree here. I would not add those extra checks unless we have a real use case or a user need for them |
cortinico
left a comment
There was a problem hiding this comment.
Code looks good to me. Just left minor comments to address
New rule to address the issue (#4462) of breaking encapsulation principle when KDoc comments have references to non-public properties.
Clients do not need to know the implementation details.
Screenshot
