服务器上带有配置和 SuppressionFilter 的 Eclipse Checkstyle

发布于 2024-08-18 20:36:57 字数 527 浏览 4 评论 0原文

我已将 Eclipse 配置为使用位于服务器上的远程 checkstyle 配置,我通过 HTTP 访问该服务器。这工作正常,但配置包含:

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

所以我尝试设置一个附加属性“basedir”,它指向配置所在的同一目录。当我尝试在项目上运行 checkstyle 时,出现错误:无法初始化模块 SuppressionsFilter - 无法将模块 SuppressionFilter 中的属性“文件”设置为“http://“my Url”/checkstyle-filter。 ?

关于如何配置 Eclipse 以使用服务器中的 checkstyle 配置(即使它包含 SuppressionFilter)有什么建议吗 我不想在每个项目中都放置一个 checkstyle-filter ...

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...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

人生戏 2024-08-25 20:36:57

目前这是不可能的,如 远程配置文件无法使用 SuppressionFilter - ID: 2018081。实际上,问题出在 Checkstyle 中,它使用 java.io.File 对象作为外部 SuppressionFilter 文件(因此设置以 http:// 开头的值将不起作用)。 Checkstyle 上有一个功能请求来更改此设置(请参阅 允许远程引用其他文件配置 - ID:2018608)。但不要指望这些变化很快就会发生(除非开始努力工作:)

话虽这么说,虽然我完全理解对公司范围的 checkstyle 配置文件的需求,但我还是更惊讶的是需要共享 SuppressionFilter 文件。毕竟,它的内容是特定于项目的,不是吗?所以,我认为你实际上应该使用另一个属性,例如 ${workspace} (或你自己的属性,我对 扩展属性占位符 是使用 .properties 文件也应该与远程配置一起使用)并要求每个项目提供其自己的文件及其 SuppressionFilter 将从工作区引用。根据惯例,这应该可行。

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.

安稳善良 2024-08-25 20:36:57

实际上,您可以使用抑制滤波器。我使用 5.6 eclipse checkstyle 插件通过远程配置以这种方式设置它。只需将抑制文件放在与 checkstyle.xml 文件相同的远程目录中,然后使用以下命令:

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

然后它将与 eclipse 一起使用。基本上只需将 ${base_dir} 替换为 ${config_loc}

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}

情话已封尘 2024-08-25 20:36:57

我无法向原始功能请求添加补丁,因此我在此处创建了一个新功能请求:https://sourceforge.net/tracker/?func=detail&atid=397081&aid=3485185&group_id=29721

我已经实现了此功能,因为我需要它能够在公司范围内禁用对单元测试和 Eclipse 生成的 NLS 类的某些检查。

我已经通过修补插件的 jar 文件使用 5.5 版本的 eclipse-cs 对其进行了测试,效果非常好。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文