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

Module specific suppression file not working #537

Open
Avinm opened this issue Oct 6, 2021 · 1 comment
Open

Module specific suppression file not working #537

Avinm opened this issue Oct 6, 2021 · 1 comment

Comments

@Avinm
Copy link

Avinm commented Oct 6, 2021

I have a checkstyle rule file with the following config for suppressions:

    <module name="SuppressionFilter">
        <property name="file" value="${checkstyle.suppression.filter}" default="checkstyle-suppressions.xml" />
    </module>

I have imported this rule to checkstyle-idea and provided the value checkstyle-suppressions.xml for the variable checkstyle.suppression.filter when importing.

The documentation says that the plugin will look for the file checkstyle-suppressions.xml in module root directory. However, in a project with multiple modules say M1, M2, M3, the plugin always uses M1/checkstyle-suppressions.xml for running inspections on all 3 modules.

Would it be possible to improve this behavior so that inspection in M2 use M2/checkstyle-suppressions.xml and those in M3 use M3/checkstyle-suppressions.xml and so on?

@jshiell
Copy link
Owner

jshiell commented Oct 27, 2021

It's a perfectly reasonable request, and indeed it is how the feature is intended to work. So there's two options: a) it's a bug, or b) it's realted to the horror that is ProjectUtil.guessModuleDir. To quote the IDEA docs:

Returns some directory which is located near module files.

There is no such thing as "base directory" for a module in IntelliJ project model.
A module may have multiple content roots, or not have content roots at all. The
module configuration file (.iml) may be located far away from the module files or
doesn't exist at all. So this method tries to suggest some directory which is related
to the module but due to its heuristics nature its result shouldn't be used for real
actions as is, user should be able to review and change it. For example it can be
used as a default selection in a file chooser.

Back when the feature was added, modules did have a base dir, but Jetbrains have decided to move away from that, bless them.

I've had a look and the logic does look sensible - we get the module for the current file, and then try the content roots, and then to guess the module dir. So my suspicion does tend towards (b), which would be a right pain. In any case I'll try to take a second look later when I'm fresh, and see if I'm missing something.

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