Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let build fail if multiple "bannedImport" elements are used, instead of "bannedImports" with multiple "bannedImport"-elements inside #112

Open
henrykuijpers opened this issue Nov 14, 2023 · 2 comments

Comments

@henrykuijpers
Copy link

We had a few configurations in our project, that had multiple bannedImport-elements. The first (or the last) is only considered, the others are ignored.

We should add something to prevent this from happening.

@skuzzle
Copy link
Owner

skuzzle commented Nov 24, 2023

I will look into this but I'm not sure whether this is doable. It depends on whether maven actually calls the setter twice when binding the XML values to the model. If it does, then adding a check should be fairly simple. If it doesn't, then adding a check for this might be impossible.

Actually, if the setter would be called twice we could consider getting rid of the bannedImports element altogether

@skuzzle
Copy link
Owner

skuzzle commented Nov 27, 2023

@henrykuijpers Could you please post your configuration? I just tried the following:

<configuration>
    <rules>
        <RestrictImports>
            <bannedImport>java.util.*</bannedImport>
            <bannedImport>java.*</bannedImport>
        </RestrictImports>
    </rules>
</configuration>

And it fails with the following message:

Caused by: java.lang.IllegalArgumentException: If you want to specify multiple banned imports you have to wrap them in a <bannedImports> tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants