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
Fixed KdocComments
and KdocFormatting
#1892
base: master
Are you sure you want to change the base?
Conversation
…es in class KDoc at the same time
…aven't empty line before them - added smoke test for class kdoc
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1892 +/- ##
============================================
+ Coverage 78.28% 78.31% +0.03%
+ Complexity 2471 2458 -13
============================================
Files 134 134
Lines 8712 8698 -14
Branches 2210 2199 -11
============================================
- Hits 6820 6812 -8
+ Misses 905 903 -2
+ Partials 987 983 -4 ☔ View full report in Codecov by Sentry. |
...t-rules/src/main/kotlin/com/saveourtool/diktat/ruleset/rules/chapter2/kdoc/KdocFormatting.kt
Show resolved
Hide resolved
...t-rules/src/main/kotlin/com/saveourtool/diktat/ruleset/rules/chapter2/kdoc/KdocFormatting.kt
Show resolved
Hide resolved
@@ -306,7 +263,8 @@ class KdocComments(configRules: List<RulesConfig>) : DiktatRule( | |||
|
|||
KDOC_NO_CONSTRUCTOR_PROPERTY.warnAndFix(configRules, emitWarn, isFixMode, warningText, node.startOffset, node) { | |||
val classNode = node.parent { it.elementType == CLASS }!! | |||
val newKdocText = if (isParamTagNeeded) "/**\n * @param $parameterName\n */" else "/**\n * @property $parameterName\n */" | |||
val paramOrPropertyTagText = if (isParamTagNeeded) "@param" else "@property" |
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.
Kotlin parser definitely has all these enum constants like param
and property
inside already. Use them.
) { | ||
val wrongTagText = if (isParamTagNeeded) "* @property $parameterName" else "* @param $parameterName" | ||
val replaceText = if (isParamTagNeeded) "* @param $parameterName" else "* @property $parameterName" | ||
val paramOrPropertySwitchText = if (isParamTagNeeded) "@property" to "@param" else "@param" to "@property" |
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 see this code in 3+ places: can you please rework it as common functions?
fun replace(isParamTagNeeded, parameterName) {
val (wrongTag, replacementTag) = if(isParamTagNeeded) (property, param) else (param, property)
val wrongTagText = ...
val replaceText = ...
changeTagInKdoc(kdocBeforeClass, wrongTagText, replaceText)
}
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 do not understand how 90% of refactoring work, but basically there are a lot of tests, so I believe in you :)
* kdoc | ||
* class | ||
* comment | ||
* |
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.
Can you please check our codestyle document. Do we mention this newline?
class A<K : Any, P: Any, G: Any> constructor( | ||
//single-line comment | ||
class A<K : Any, P : Any, G : Any> constructor( | ||
// single-line comment |
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 thought that test was checking how this space is fixed
* @param K | ||
* @property openName single-line comment | ||
* @property openLastName | ||
* block |
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 it was moved to a newline with a some purpose? Isn't it a newline rule that split long lines?
@@ -5,7 +5,7 @@ class A constructor( | |||
) {} | |||
|
|||
class A constructor( | |||
//single-line comment | |||
// single-line comment |
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.
why do we change a test?
What's done:
KdocComments
.KdocFormatting
for case when@property
and@constructor
basic tags haven't empty line before them.@property
tag.Closes #1884