-
Notifications
You must be signed in to change notification settings - Fork 157
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
Plugin does not support XML entity includes #350
Comments
Isn't this a core Checkstyle feature request rather than one for the plugin? |
It works from Gradle and when checkstyle is called directly so I'm guessing that it's the IDEA plugin that needs to set some parameters on the config parser, or checkstyle to set the cwd? |
Thanks for the suggestion. We do all sorts of hackery to make relative paths resolve correctly, so I imagine we'll just need to apply the same hackery here. I'll add it to the list. It probably won't be this weekend, I fear, as I've just come off production support and don't want to see a computer for a couple of days 😄 |
No worries, I just opened this so it's known, take your time. |
Hmm. This is harder than it looks.
I see two options at present:
The latter is, of course, madness. So we're really left with the pre-parse answer at present, which will require a little more time & thought (mostly to ensure I haven't missed anything obvious). |
Thabks for the update, nice to see you being so responsive. I wonder how it works in Gradle, that probably runs in-process as well, with cwd likely being Is it possible to use some You have to stay in-process, right? Otherwise it would be slow to do continuous checking on currently edited file. |
Some more investigation looks to be required - you're quite right, the Gradle plugin appears to run in-process. In fact, it appears to invoke the Ant plugin, which is part of the core Checkstyle distribution. I had a quick look there, but haven't spotted anything yet, so it'll take a bit more looking. It does seem a promising line of enquiry though, which I'll continue when I've a moment. The In theory we could run a background task ala the Gradle daemon or similar, but it's not a simple solution. And I don't believe forking for each scan would be performant - it'd be fine for the solo scans, but I believe the inspection would not be great with this approach. |
…. This only works for the properties check at present, not the rules file itself. (#350)
Still at a bit of a loss on this one. I've extended our own |
How bad is that change over time? What's the link that needs to be done? (is it a method that sets a field via reflection, whose name changes between versions, or more complicated than that?) |
Potentially painful. It'll be fragile, but as long as it's covered by the test cases that run against each version of Checkstyle it's potentially workable. |
To reuse and make the size of the configuration file manageable it could be a good practice to split the checkstyle configuration into multiple XML files and DTD entity declarations to pull them in.
A live example of this can be found in the Android support library, and the included files reside in the prebuilts/checkstyle repo.
Expected behavior: the path to the included file should be relative to the file that is including it. So
./bar.xml
should be in the same folder as thecheckstyle.xml
, so doesbar.xml
(without any prefix)./bar.xml
should link to the root folder on the drive wherecheckstyle.xml
resides (at least on Windows, on Unix it should be the usual/
).So if
P:\projects\blah\config\checkstyle.xml
, then<!ENTITY foo SYSTEM "./bar.xml">
→P:\projects\blah\config\bar.xml
<!ENTITY foo SYSTEM "./foo/bar.xml">
→P:\projects\blah\config\foo\bar.xml
<!ENTITY foo SYSTEM "bar.xml">
→P:\projects\blah\config\bar.xml
<!ENTITY foo SYSTEM "foo/bar.xml">
→P:\projects\blah\config\foo\bar.xml
<!ENTITY foo SYSTEM "/bar.xml">
→P:\bar.xml
<!ENTITY foo SYSTEM "/foo/bar.xml">
→P:\bar.xml
Actual behavior: The relative paths are resolved against the IDEA installation directory, for example:
<!ENTITY foo SYSTEM "./bar.xml">
→P:\tools\ide\idea\bin\bar.xml
<!ENTITY foo SYSTEM "./foo/bar.xml">
→P:\tools\ide\idea\bin\foo\bar.xml
Note: the same configuration XML works if ran through the command line (Gradle) checkstyle.
The text was updated successfully, but these errors were encountered: