-
-
Notifications
You must be signed in to change notification settings - Fork 821
Function generics matcher #4460
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 #4460 +/- ##
=========================================
Coverage 84.55% 84.56%
Complexity 3397 3397
=========================================
Files 484 484
Lines 11272 11276 +4
Branches 2059 2060 +1
=========================================
+ Hits 9531 9535 +4
Misses 698 698
Partials 1043 1043
Continue to review full report at Codecov.
|
f73771a to
5d8588f
Compare
eefa7bc to
746dcaa
Compare
5d8588f to
dc617af
Compare
746dcaa to
aa6655a
Compare
| ) : FunctionMatcher() { | ||
| override fun match(callableDescriptor: CallableDescriptor): Boolean { | ||
| if (callableDescriptor.fqNameOrNull()?.asString() != fullyQualifiedName) return false | ||
| val descriptor = callableDescriptor.original |
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.
Q: What is .original doing here? Why is it needed?
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.
That get's the function definition instead of the function call. If I request the type of the parameter of list("hello") it will say String but if I ask for the type of the original I get T.
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.
Gotcha 👍 Thanks for clarifying
dc617af to
6a9f0ca
Compare
aa6655a to
5c370c3
Compare
|
I would like to merge this one in 1.20 too if possible. This PR was waiting for #4459 to be merged because it depends on that code. |
5c370c3 to
568c2a4
Compare
|
I'm fine adding this, but we need some follow-up docs for this to the website |
|
🤔 I don't think we need to add new documentation here. The current documentation matchs what this matcher does. This one is more a "bug-fix" than a new feature. I mean, for sure it is a new feature but for a user it could seems like the same. The PR that introduced real changes was #4459 and I added the documentation directly in it. https://github.com/detekt/detekt/pull/4459/files#diff-76703cf8efe31f0c7e06926568e0d1e248eb82cb63bd40b0b37698dc35bed70fR52 |
* Match functions with generics * Add test to ensure that #4448 is fixed
Match generic names in signature functions.
Now ForbiddenMethod call allows to forbid
kotlin.runCatching {}but allowingrunCatching {}.closes #4448