Replace @requiresTypeResolution kdoc tag with @RequiresTypeResolution annotation#3579
Conversation
| import java.lang.reflect.Modifier | ||
| import kotlin.reflect.KClass | ||
|
|
||
| @Suppress("TooManyFunctions") |
There was a problem hiding this comment.
Let's move the methods of KtClassOrObject.requiresTypeResolution() and KtClassOrObject.isAnnotatedWith() to detekt-api. I think they should be exposed and can be reused.
Hopefully we won't require suppressing TooManyFunctions
Codecov Report
@@ Coverage Diff @@
## main #3579 +/- ##
============================================
+ Coverage 77.53% 77.59% +0.06%
+ Complexity 2837 2832 -5
============================================
Files 464 465 +1
Lines 8781 8805 +24
Branches 1720 1719 -1
============================================
+ Hits 6808 6832 +24
Misses 1047 1047
Partials 926 926
Continue to review full report at Codecov.
|
|
I removed the annotation from the exposed api by moving it to the internal package. Also the retention is changed to SOURCE so it is not available at runtime. This way we should be fairly flexible when it comes to changing the annotation(s) without breaking peoples code. |
cortinico
left a comment
There was a problem hiding this comment.
I still have some formatting issues. That is why there is one commit that just reformats the code according to the ktlint plugin
I wonder why this is happening 🤔
I started out adding @UnstableApi to the annotation but that would all rules to require to add @OptIn(UnstableApi::class) which does not feel right either.
I think @UnstableApi is a bit of an overkill. Having the annotation inside .internal is sufficient. Also I don't know how many users will start relying on this annotation right after, so I won't worry too much about protecting this API.
picklebento
left a comment
There was a problem hiding this comment.
@cortinico I was wondering if this should be in external API. The problem is that we should also allow custom rules to be annotated correctly, #3577 is a good example to fully skip type resolution rules.
Regardless, this PR looks good as it stands for now. I don't mind if we "escalate" these apis later.
detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/internal/RequiresTypeResolution.kt
Outdated
Show resolved
Hide resolved
9bd9427 to
b520fef
Compare
...erator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/collection/RuleCollectorSpec.kt
Show resolved
Hide resolved
I believe yes, this should be an external API. Something to remember for the future 👍 |
b520fef to
acc5f7b
Compare
> Task :detekt-test:detektMain Property 'style>ForbiddenComment>values' is deprecated. Use `comments` instead, make sure you escape your text for Regular Expressions.. History: @requiresTypeResolution: detekt#3579 + 13a8389 @author: detekt#1776
This PR belongs to #3562 and replaces the @requiresTypeResolution kdoc tag with a @RequiresTypeResolution annotation.
There are a few things that I would like to point out/discuss:
internaluntil it is stable?@UnstableApito the annotation but that would all rules to require to add@OptIn(UnstableApi::class)which does not feel right either.@Suppress("TooManyFunctions")to theRuleVisitordoes not feel great, but I thinkt the code reads much better with those extension functions. Suggestions are welcome.