Skip to content

Find and handle unused Policy/Permissions checks

The problem

We have hundreds of policy checks in our DeclarativePolicy classes. We do not have a programmatic way to check that each policy check in our classes is being used.

More context

This is a similar problem to: Find and handle undeclared policy keys (#369511)

In that issue, an undefined policy check is being used and evaluates to false rather than raising an error. The solution for this is a spec helper that checks whether each call to Ability.allowed? is associated with a defined ability. MR to add this spec: !94135 (merged)

We should write a similar spec that goes through each defined ability to looks for whether it is used anywhere in the codebase.