slackhq / slack-lints

A collection of custom Android/Kotlin lint checks we use in our Android and Kotlin code bases at Slack.
Apache License 2.0
225 stars 11 forks source link

Extract mock annotations/classes/methods into Lint options #126

Closed SimonMarquis closed 11 months ago

SimonMarquis commented 1 year ago

Summary

This PR implements support for other mocking frameworks through Lint options:

Requirements

The following point can be removed after setting up CI (such as Travis) with coverage reports (such as Codecov)

The following point can be removed after setting up a CLA reporting tool such as cla-assistant.io

salesforce-cla[bot] commented 1 year ago

Thanks for the contribution! Before we can merge this, we need @SimonMarquis to sign the Salesforce Inc. Contributor License Agreement.

ZacSweers commented 1 year ago

@SimonMarquis are you still planning to pursue this?

SimonMarquis commented 1 year ago

Yes! I couldn't find time for this in the last weeks. But I'll try to add tests this weekend and see how classes & methods checks could be merged.

ZacSweers commented 1 year ago

Sounds good!

SimonMarquis commented 1 year ago

@ZacSweers I've added the MockDetectorOptionsTest test class, but I've a hard time figuring out how to merge methods and classes. I tried to find a way to access the fqn of the UCallExpression, but did not find anything :/

ZacSweers commented 1 year ago

I tried to find a way to access the fqn of the UCallExpression

I would expect this to work like so

Note that the fqcn likely includes the enclosing synthetic class for top-level functions

ZacSweers commented 11 months ago

@SimonMarquis we'd like to merge this soon, do you still want to contribute it?

SimonMarquis commented 11 months ago

Oh, indeed. But it seem's that MockK's reified mockk method would be resolved to io.mockk.MockKKt.mockk, while non-reified mockkClass would be resolved to io.mockk.mockkClass. I'm not sure if this could be considered a good API though. Also, I'm sorry, I wont be able to dedicate enough time to debug this in the near future.

ZacSweers commented 11 months ago

No worries, I can take this over

ZacSweers commented 11 months ago

Got it all working 👍

SimonMarquis commented 11 months ago

Thanks a lot for completing this PR!