-
-
Notifications
You must be signed in to change notification settings - Fork 784
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
Report KDoc comments that refer to non-public properties of a class #4768
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 ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this 👍
...ain/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/ReferencedEncapsulatedProperty.kt
Outdated
Show resolved
Hide resolved
...ain/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/ReferencedEncapsulatedProperty.kt
Outdated
Show resolved
Hide resolved
...ain/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/ReferencedEncapsulatedProperty.kt
Outdated
Show resolved
Hide resolved
...ain/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/ReferencedEncapsulatedProperty.kt
Outdated
Show resolved
Hide resolved
...kotlin/io/gitlab/arturbosch/detekt/rules/documentation/ReferencedEncapsulatedPropertySpec.kt
Outdated
Show resolved
Hide resolved
...kotlin/io/gitlab/arturbosch/detekt/rules/documentation/ReferencedEncapsulatedPropertySpec.kt
Outdated
Show resolved
Hide resolved
...ain/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/ReferencedEncapsulatedProperty.kt
Outdated
Show resolved
Hide resolved
...ain/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/ReferencedEncapsulatedProperty.kt
Outdated
Show resolved
Hide resolved
@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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
