-
-
Notifications
You must be signed in to change notification settings - Fork 783
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
#4169 OutdatedDocumentation rule #4185
#4169 OutdatedDocumentation rule #4185
Conversation
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.
Great work 💪 Thanks for taking the time to write this. I've left some comments. Let me know if you need some help or are unclear.
...ion/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentation.kt
Show resolved
Hide resolved
...ion/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentation.kt
Outdated
Show resolved
Hide resolved
...ion/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentation.kt
Outdated
Show resolved
Hide resolved
...ion/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentation.kt
Outdated
Show resolved
Hide resolved
...ion/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentation.kt
Outdated
Show resolved
Hide resolved
private data class MutableDeclarations( | ||
val params: MutableList<String> = mutableListOf(), | ||
val props: MutableList<String> = mutableListOf() | ||
) { | ||
fun toDeclarations(): Declarations { | ||
return Declarations( | ||
params = params, | ||
props = props | ||
) | ||
} | ||
} | ||
|
||
private data class Declarations( | ||
val params: List<String> = listOf(), | ||
val props: List<String> = listOf() | ||
) |
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 need both? I believe we could rewrite the code to be fully immutable here. Specifically we could get rid of MutableDeclarations
entirely.
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've refactored this part a bit to get rid of mutable version and use more functional style
...src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentationSpec.kt
Outdated
Show resolved
Hide resolved
Basic implementation covers: - class primary constructor parameters - class primary constructor property parameters - function parameters
…d declarations order
cb2a1cf
to
5bd7f86
Compare
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.
Looks good on my end 💪 Great work and thanks for doing it!
Let's wait for another maintainers' review and we should be good to go
Codecov Report
@@ Coverage Diff @@
## main #4185 +/- ##
============================================
+ Coverage 84.12% 84.19% +0.06%
- Complexity 3205 3233 +28
============================================
Files 467 468 +1
Lines 10113 10185 +72
Branches 1774 1786 +12
============================================
+ Hits 8508 8575 +67
+ Misses 673 671 -2
- Partials 932 939 +7
Continue to review full report at Codecov.
|
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.
Really good test coverage :)
* @param someParam Description of param | ||
* @property someProp Description of property | ||
*/ | ||
class MyClass(otherParam: String, val someProp: 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.
What happend with:
/**
* @property someParam Description of param
* @param someProp Description of property
*/
class MyClass(someParam: String, val someProp: String)
Should this rule catch when you use @param
over a property or @property
over a param?
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.
...src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentationSpec.kt
Outdated
Show resolved
Hide resolved
To me this PR is ready to merge. I would like to know your opinion about my comments but both can be done in a follow up PR. The only thing stopping us to merge this is that CI is complaining. Could you check those issues? |
I hopefully fixed CI (there were some minors e.g. not compiling test snipets, because of lack of function body). I would also like to fix issue mentioned here #4185 (comment) before you merge |
...src/test/kotlin/io/gitlab/arturbosch/detekt/rules/documentation/OutdatedDocumentationSpec.kt
Show resolved
Hide resolved
Great first contribution 👏 |
Hi, I've prepared implementation of OutdatedDocumentation rule proposed in #4169
When KDoc is present and contains any
@param
or@property
tag, rule will check if params and properties of class/function/constructor declaration matches the ones from KDoc.By default, both type and value parameters are considered, but I've added configuration for turning off checks for type parameters. Also the order of declarations matters in default configuration, but can be turned off as well.
If you want to suggest additional test scenarios or configurable behaviour feel free to comment and I will be happy to enhance this PR.