New rule: procedure should not call a procedure decorated with [EventSubscriber] #403
Arthurvdv
started this conversation in
Suggestions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Event subscriber procedures exist to react to events raised by the platform or other apps. Calling them directly from regular code is a design smell:
SkipOnMissingLicense/SkipOnMissingPermissionor manual binding (EventSubscriberInstance = Manual) the way the event dispatcher does.The correct refactoring is to extract the shared logic into a regular procedure that both the subscriber and the other caller invoke.
Proposal: a new LinterCop rule that reports a diagnostic when an invocation target is a procedure decorated with
[EventSubscriber].Thoughts? Anything legitimate we'd break by discouraging this pattern?
Generated with Claude Fable 5
All reactions