-
Notifications
You must be signed in to change notification settings - Fork 14
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
Allow unit return type for suspend functions #293
Conversation
Thanks for the contribution! Before we can merge this, we need @oguzcelik to sign the Salesforce Inc. Contributor License Agreement. |
Let's make this more intentional. Could we either add an opt-in annotation like |
import slack.lint.BaseSlackLintTest | ||
|
||
class RetrofitUsageDetectorTest : BaseSlackLintTest() { | ||
|
||
private companion object { | ||
private val allowUnitResponse = |
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 followed other examples of how to make the test recognise this import. Don't know if there is a better way.
* to have a return type of Unit, which otherwise will be flagged as an issue. | ||
*/ | ||
@Target(AnnotationTarget.FUNCTION) | ||
@Retention(AnnotationRetention.BINARY) |
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.
Marked as Binary retention as we don't need this at runtime.
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 it just be SOURCE?
Would you want to make the docs more explicit ? Something like:
|
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.
Sorry for the delay, I was on sabbatical over the summer. Left a couple comments, also please run ./gradlew spotlessApply
to fix formatting issues (and in the future - please match our project's conventions)
* to have a return type of Unit, which otherwise will be flagged as an issue. | ||
*/ | ||
@Target(AnnotationTarget.FUNCTION) | ||
@Retention(AnnotationRetention.BINARY) |
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 it just be SOURCE?
returnType.canonicalText == "kotlin.Unit" | ||
) { | ||
val isSuspend = context.evaluator.isSuspend(node) | ||
val hasAllowUnitResponseAnnotation = node.findAnnotation("slack.lint.annotations.AllowUnitResponse") != null |
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.
If this is false we should be able to skip needing the isVoidOrUnitReturnType variable right? Let's make that logic lazier
Sorry @oguzcelik but you've not signed our CLA, so I cannot accept this PR or finish it for you. Instructions were commented here. |
Hey @ZacSweers 🖖 hope you enjoyed your sabbatical 🥳 I had already mentioned in the pr description that the CLA link unfortunately doesn't work. Here's a video in case you are wondering what I mean Screen.Recording.2024-09-03.at.10.55.58.movPlease let me know once the cla link and the contributing guidelines links are fixed and I'll try to get back to this to open another pr 👍 |
Please use the one in the comment I linked above? The template is unfortunately old but the comment from the salesforce bot should be working |
Summary
This pr aims to fix the lint rule for retrofit usage. Solves this issue
For suspend functions it's a valid case to return Unit.
Requirements (place an
x
in each[ ]
)Unfortunately the contributing guidelines and Contributor license agreement links are not working.