如何从 Sonar 导出 FindBugs/PMD/Checkstyle 规则并导入 Netbeans

发布于 2024-12-15 15:48:32 字数 695 浏览 4 评论 0原文

我的公司使用各种插件(PMDFindBugsCheckStyle)设置了声纳,尽管它按原样非常有用(它运行在通过签入 SVN 触发的每个 Jenkins 构建之后,我希望在签入代码之前能够在本地计算机上运行这些不同的插件。

我们有一组规则已经制定在声纳,所以理想情况下我希望能够导出该规则集,也许可以做一些修改数据,然后将生成的规则导入到我的 IDE (Netbeans 7.0.1) 中的相应插件中。有什么办法可以做到这一点吗?我已经进行了全面搜索,但没有完成并手动将每个规则添加到各种插件中,似乎没有办法做到这一点。我有什么遗漏的吗?

TL;DR(摘要):我想从声纳导出配置文件并将规则设置导入到Netbeans 中的 PMDFindbugsCheckStyle 插件。

My company has sonar set up to with various plugins (PMD, FindBugs, CheckStyle), and although it is very useful as is (it runs after every Jenkins build that was triggered by a check-in to SVN), I would like it if I could run these various plugins on my local machine before I check the code in.

We have a set of rules already set up in Sonar, so ideally I would like to be able to export that ruleset, perhaps do some munging of the data, and then import the resulting rules into my IDE (Netbeans 7.0.1) into the respective plugins. Is there any way to do this? I've searched all over and short of going through and manually adding each rule to the various plugins, there doesn't appear to be a way to do this. Is there something I'm missing?

TL;DR (Summary): I'd like to export a profile from sonar and import the rule settings into the PMD, Findbugs, and CheckStyle plugins in Netbeans.

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

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

发布评论

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

评论(4

红玫瑰 2024-12-22 15:48:33

每个 Sonar 配置文件都会在永久链接选项卡下发布其 Checkstyle、FIndbugs 和 PMD 配置。

假设您已在本地安装了 Sonar,以下链接显示了“Sonar Way”配置文件使用的配置文件:

http://localhost :9000/profiles/permalinks/2

Each Sonar profile publishes it's Checkstyle, FIndbugs and PMD configuration under the permalinks tab.

Assuming you've got Sonar installed locally, the following link shows the configuration files used by the "Sonar Way" profile:

http://localhost:9000/profiles/permalinks/2

只是在用心讲痛 2024-12-22 15:48:33

您不需要自己安装声纳。您可以从 Sonar 的 Nemo 站点获取任何 Sonar 内置质量配置文件的配置:

大约有十几个 Java 质量配置文件。常用的配置文件 - 使用 Findbugs 的声纳方式 - 位于:

http://nemo.sonarsource.org/rules_configuration/index/ 135

初始配置文件视图仅列出所有规则。不要使用该视图上的“下载”链接。这只是为您提供所有工具的合并规则的 CSV 列表。对审查有帮助,但不是你所要求的。

要导出特定于工具的配置,请选择“永久链接”选项卡/视图。这些链接以每个工具期望的形式返回配置文件。例如,以下是 FindBugs XML 配置文件的链接:

http://nemo.sonarsource.org/profiles/export?format=findbugs&language=java&name=Sonar%2520way%2520with%2520Findbugs

You don't need your own Sonar installation. You can get the configuration of any of Sonar's built-in Quality Profiles from Sonar's Nemo site:

There are about a dozen Java Quality Profiles. A commonly used profile - Sonar way with Findbugs - is available at:

http://nemo.sonarsource.org/rules_configuration/index/135

The initial Profile view just lists all the rules. Don't use the "Download" link on that view. That just gives you a CSV listing of the merged rules across all tools. Helpful for review, but not what you're asking for.

To export the tool-specific configuration, select the Permalinks tab/view. Those links return the configuration file in the form expected by each tool. For example, here's the link for the FindBugs XML configuration file:

http://nemo.sonarsource.org/profiles/export?format=findbugs&language=java&name=Sonar%2520way%2520with%2520Findbugs

北风几吹夏 2024-12-22 15:48:33

SonarLint 是较新的插件,它不再支持 Checkstyle/PMD/FindBugs 配置文件。所有内容都必须迁移到鱿鱼规则并在 SonarQube 服务器上的质量配置文件下进行配置。您需要使用连接模式连接到服务器,并将自定义质量配置文件设置为默认值,以便本地分析能够显示与您的质量配置文件相关的问题。
有关 SonarLint 插件和连接模式的更多信息,请访问
http://www.sonarlint.org/eclipse/index.html#Connected

SonarLint is the newer plugin and it doesn't support Checkstyle/PMD/FindBugs profiles anymore. Everything has to be migrated to squid rules and configured on the SonarQube server under Quality Profiles. You need to connect to the server using connected mode and set your custom quality profile as default so that local analysis would show issues related to your quality profile.
More information about SonarLint Plugin and connected mode can be found at
http://www.sonarlint.org/eclipse/index.html#Connected

酒解孤独 2024-12-22 15:48:33

另一个简单的机制是使用:备份/恢复配置文件
请参阅:http://docs.sonarqube.org/display/SONAR/Profile+Existence +编辑

实例(源)进行备份将在本地计算机上提供一个 backup.xml 文件,然后您可以在另一个实例(目标)上恢复它。

Another simple mechanism is to use : Backing up / Restoring a Profile
See : http://docs.sonarqube.org/display/SONAR/Profile+Existence+Edits

Taking backup from an instance(source) will give you a backup.xml file on your local machine and then on another instance(destination) you can restore it.

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