Can I write a rule that will report usages of Cont...
# detekt
d
Can I write a rule that will report usages of Context Receivers? ex:
Copy code
context(Activity)
fun finishWithContextReceiver(){
    finish()
}
b
You should be able, yes. And it shouldn't be really complex I guess.
d
@Brais Gabin Do you happen to know what the correct way to do that would be? The one visitation function I found that seems to fit is
visitContextReceiverList
, but it's not reporting anything for me.
Copy code
override fun visitContextReceiverList(contextReceiverList: KtContextReceiverList) {
        super.visitContextReceiverList(contextReceiverList)
        report(
            CodeSmell(
                issue = issue,
                entity = Entity.from(contextReceiverList),
                message = "Context Receivers are going to be removed.  Use named function parameters or extension methods instead",
            ),
        )
    }