-
-
Notifications
You must be signed in to change notification settings - Fork 778
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
Replace @requiresTypeResolution kdoc tag with @RequiresTypeResolution annotation #3579
Replace @requiresTypeResolution kdoc tag with @RequiresTypeResolution annotation #3579
Conversation
|
||
@Suppress("TooManyFunctions") |
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.
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. |
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 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.
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.
@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:
internal
until it is stable?@UnstableApi
to the annotation but that would all rules to require to add@OptIn(UnstableApi::class)
which does not feel right either.@Suppress("TooManyFunctions")
to theRuleVisitor
does not feel great, but I thinkt the code reads much better with those extension functions. Suggestions are welcome.