fpgmaas/deptry

Add yesqa-style rule against unused ignores

Opened this issue · 2 comments

Is your feature request related to a problem? Please describe.

It's good to ensure that the ignores remain up-to-date, in particular it would be nice to ensure that unnecessary ignores are deleted.

Describe the solution you would like

My favorite solution to this type of problem is yesqa or equivalently RUF100. In particular, I'd like a new rule, like maybe DEP005, that fails when there exists an ignore which was never triggered.

That would be a great feature indeed!

Similarly to Ruff, since it's kind of a "meta" rule, maybe we could use DEP100 rather than DEP005? If we ever add new rules that are closer in behavior to the existing ones, I feel that having DEP006 after this one would feel quite weird for users.

I made a quick start with this last week, in which I coincidentally called it DEP100, see here. My idea was to add an attribute to the violation finders;

modules_to_ignore: A tuple of module names to ignore when scanning for issues. Defaults to an
    empty tuple.
used_ignores: a list to keep track of which values in 'modules_to_ignore' were actually used. This list should
    be updated during the `find()` method, so that the set difference of `modules_to_ignore` and `used_ignores`
    results in a set of modules in `modules_to_ignore` that no longer need to be ignored.

I struggled a bit with coming up how to implement it in the reporter classes, since they rely on a location; but we do not know the location for these ignores, they can come from either the command line or from pyproject.toml. Needs some more thought.