Skip to content
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

Document and test edge cases for ForbiddenMethodCall function signatures #5495

Merged
merged 1 commit into from Nov 3, 2022

Conversation

dzirbel
Copy link
Contributor

@dzirbel dzirbel commented Nov 1, 2022

I was stuck trying to match some function signatures (from Timber on Android) for the ForbiddenMethodCall rule and had to test inside detekt to figure out how to do it properly. To make this more clear in the future, I've expanded the description of the methods configuration parameter and added more tests for these cases. Some of this might be obvious to some but it was not to me at the time so I think having some quick tips might be helpful; or perhaps a link to a more comprehensive guide on Kotlin function signatures (if one exists).

Copy link
Member

@schalkms schalkms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might have produced a name clash, which causes the compileSnippets task to fail.
The function named test might be the issue here. If this issue is resolved, I'd say LGTM.

Thank you for improving detekt's docs. These improvements are very much appreciated.

I was stuck trying to match some function signatures (from Timber on Android)
for the ForbiddenMethodCall rule and had to test inside detekt to figure out how
to do it properly. To make this more clear in the future, I've expanded the
description of the methods configuration parameter and added more tests for
these cases. Some of this might be obvious to some but it was not to me at the
time so I think having some quick tips might be helpful; or perhaps a link to a
more comprehensive guide on Kotlin function signatures (if one exists).
@dzirbel
Copy link
Contributor Author

dzirbel commented Nov 1, 2022

You might have produced a name clash, which causes the compileSnippets task to fail. The function named test might be the issue here. If this issue is resolved, I'd say LGTM.

Yep, it was just a copy-paste error between the Array and List tests - should be fixed now 🤞

@schalkms schalkms merged commit 621bcc9 into detekt:main Nov 3, 2022
21 checks passed
@BraisGabin
Copy link
Collaborator

Thanks! If you need to investigate further I recommend you to check FunctionMatcherSpec.kt. It contains a lot of tests about how to parse the function signatures. It's a really complex topic.

@cortinico cortinico added this to the 1.22.0 milestone Nov 5, 2022
@cortinico cortinico added the housekeeping Marker for housekeeping tasks and refactorings label Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Marker for housekeeping tasks and refactorings rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants