-
-
Notifications
You must be signed in to change notification settings - Fork 802
OutdatedDocumentation - Check if only public property is documented #6057
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #6057 +/- ##
=========================================
Coverage 84.85% 84.85%
- Complexity 3949 3979 +30
=========================================
Files 561 564 +3
Lines 13256 13312 +56
Branches 2315 2330 +15
=========================================
+ Hits 11248 11296 +48
- Misses 868 870 +2
- Partials 1140 1146 +6
|
) { | ||
val doc = element.docComment ?: return | ||
val docDeclarations = getDocDeclarations(doc) | ||
if (docDeclarations.isNotEmpty()) { | ||
val elementDeclarations = elementDeclarationsProvider() | ||
if (!declarationsMatch(docDeclarations, elementDeclarations)) { | ||
val isInternalPrimaryConstructor = element is KtClass && isInternalOrPrivate(element.primaryConstructor) |
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.
We call this method reportIfDocumentationIsOutdated
with 3 different element
types. However, in this method we check whether element has 1 specific type (e.g. KtClass
). For me, this feels like a polymorphism code smell. See here for more details.
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.
Do we want me to move this check to visitClass
method?
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.
Yes, just type KtClass
of the 3 cases needs all those added checks.
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.
I have updated the code
private fun declarationsMatch( | ||
doc: List<Declaration>, | ||
element: List<Declaration>, | ||
shouldAllowOnlyPropertyDoc: Boolean, |
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.
Using boolean parameters is at least controversial. One obvious reason is that it makes code harder to read and maintain.
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.
Removed boolean
/** | ||
* Exception thrown from MyLibrary that can not be created outside of the library. | ||
* @property errorCode Description of param | ||
*/ | ||
class MyLibraryException internal constructor( | ||
val errorCode: String, | ||
cause: Throwable?, | ||
) : Exception(cause) |
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.
I think smaller test code snippets are sufficient here to understand what's being tested here.
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.
Is this somehow hampering the readability of the test code? I saw the other TCs which use MyClass
but current TC is inspired by the issue #5217 also conveys why someone wants to document property in this manner
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.
Isn't shorter, more concise and less noisy to add code snippets like this?
/**
* Doc
* @property b desc
*/
class A internal constructor(val b: String)
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.
TBH even the current TC was readable to me. But I have updated the cases. Thanks for reviewing it
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! Looks good now.
Fixes #5217