Minor hurdles with Track uses of disallowed classes

I have been using ‘Track uses of disallowed classes’ to hinder parts of my code to import code from areas it should not.
While doing so I noticed two things that could either improve the feature or maybe a bug and was asked to make a new thread for it.

  • Possible new feature: Allow the regexp for class to start with a wildcard.
    E.g if I want to exclude all classes from *.fruits.* I have to add a the root node, e.g things.*.fruits.*. Allowing * at the start would help if you have multiple starts with fruits in them e.g oceanThings.*.fruits.* and landThings.*.fruits.*

  • Possible bug: Importing constants from a disallowed class is not noticed.
    E.g I dissallowe things.*.fruits.* and in my code I use
    I do not get an error.
    But if I where to do:
    new things.somewhere.fruits.Eatable().APPLE
    I do get an error.

For the first point, I don’t understand why you think it’s not possible. Basically you should be able to use simple Java regex. In your example it can be .*\.fruits\..*

For the second point I’ve created a ticket to improve the rule.

Thanks for the feedback!

Ahh, seems like user error on the first one. facepalm
I have a tendency to fail with regex whistles innocently :slight_smile:

But thanks for the ticket on the other point!