开发者

Eclipse Checkstyle with configuration and SuppressionFilter on server

开发者 https://www.devze.com 2022-12-16 22:41 出处:网络
I have configured my Eclipse to use a remote checkstyle configuration that is located on a server, which I reach via HTTP. This works fine, but the 开发者_运维知识库configuration contains:

I have configured my Eclipse to use a remote checkstyle configuration that is located on a server, which I reach via HTTP. This works fine, but the 开发者_运维知识库configuration contains:

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

So I try to set an additional property "basedir" which points to the same directory where the configuration is. When I try to run checkstyle on a project I get an error: cannot initialize module SuppressionsFilter - Cannot set property 'file' in module SuppressionFilter to 'http://"my Url "/checkstyle-filter.xml'

Any suggestions on how to configure Eclipse to use the checkstyle configuration from the server even though it has that it contains the SuppressionFilter? I do not want to put a checkstyle-filter in each project...


This is currently not possible as reported in Remote Configuration Files cannot use a SuppressionFilter - ID: 2018081. Actually, the problem is in Checkstyle which uses a java.io.File object for the external SuppressionFilter file (and thus setting a value starting with http:// won't work). There is a feature request on Checkstyle to change this (see Allow remote references to additional file configuration - ID: 2018608). But don't expect these changes to occur very soon (unless if you start working hard on it :)

That being said, while I perfectly understand the need for a corporate wide checkstyle configuration file, I'm more surprised by the need for a shared SuppressionFilter file. After all, its content is project specific, isn't it? So, I think that you should actually use another property, for example ${workspace} (or your own property, my understanding of Expanding property placeholders is that using a .properties file is supposed to work with a Remote Configuration too) and ask each project to provide its own file with its SuppressionFilter that would be referenced from the workspace. Based on convention, that should work.


Actually, you can use a suppression filter. I have it setup this way with a remote config using the 5.6 eclipse checkstyle plugin. Just put the suppression file in the same remote directory as the checkstyle.xml file and then use the following:

<property name="file" value="${config_loc}/suppression.xml" />

It will then work with eclipse. Basically just replace ${base_dir} with ${config_loc}


I wasn't able to add a patch to the original feature request, so I created a new feature request here: https://sourceforge.net/tracker/?func=detail&atid=397081&aid=3485185&group_id=29721

I've implemented this functionality as I needed it to be able to corporate-wide disable certain checks for unit tests and Eclipse-generated NLS classes.

I've tested it with the 5.5 version of eclipse-cs by patching the jar file for the plugin and it works quite well.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号