SonarQube 7.4 集成报告插件

网友投稿 1434 2022-05-28

前言

Sonar PDF Report Plugin

介绍

安装

快速使用

配置

下载报告

前言

Sonar PDF Report Plugin

介绍

安装

快速使用

配置

下载报告

sonar-cnes-report

介绍

快速开始

安装

单机模型

插件模式(自 2.2.0 起)

帮助命令

示例

兼容矩阵

小结

前言

本文总结目前两种常用的生成 SonarQube 结果报告的方法,以备查阅。

Sonar PDF Report Plugin

适用SonarQube版本 : 5.5–7.5。

2.0.X:适用SONARQUBE5.5–5.6.7版本

2.1.x:适用SONARQUBE6.0-6.2版本

3.0.x:适用SONARQUBE6.3+

官网地址:https://gitee.com/zzulj/sonar-pdf-plugin

介绍

本插件生成 PDF 格式的 sonarqube 报告.

报告包括以下内容:

概要

静态分析

SonarQube 7.4 集成报告插件

动态分析

编码问题

热点:

违反最多的规则TOP10

违规最多的文件TOP5

复杂度最高的文件TOP5

重复行最多的文件TOP5

违规详情

子模块信息(只有在存在时生成)

安装

下载对应的版本,将插件复制到 SONARQUBE_HOME/extensions/plugins 目录

重启 SonarQube

快速使用

SonarQube PDF 是一个 post-job任务. 因此,PDF 报告将在SonarQube 分析结束后生成.

配置 Skip 为“否”时生成 PDF 报告功能启用。

配置 Username 和 Password。如果出现 HTTP error: 401 或者 HTTP error: 403, msg: Forbidden,请查看该配置。

5.x版本:PDF 在仪表盘中下载,如果没有下载界面,需要在“配置控件”中添加该控件

6.x 以及 7.x 版本:因为 UI 变化无仪表盘页面,在工程中 More 菜单下查看:

生成的报告内容如下:

sonar-cnes-report

介绍

插件可以将代码分析从 SonarQube 服务器导出为 docx、xlsx、csv、markdown 和文本文件。

该工具可以作为 JAR 可执行文件(使用命令行)或作为 Sonarqube 插件独立使用。

特性:

将代码分析导出为一组文件

导出代码分析配置

使用自定义模板

获取自定义的OpenXML (docx, xlsx)报告

获得一个包含所有问题的动态透视表

导出成法语或英语

官网地址:https://github.com/cnescatlab/sonar-cnes-report

快速开始

设置一个SonarQube实例。

使用sonar-scanner, maven, gradle, msbuild 等运行分析。

执行cnesreport:

在单机中,使用命令行

在插件模式下,拷贝 jar 到 /opt/sonarqube/extensions/plugins,重启 sonarqube,然后点击 “More”>“CNES Report”。

安装

Cnesreport 不需要任何安装。它是一个可移植的 Java 应用程序,可以根据下面的示例复制并运行它。唯一的要求是一个最新的JRE(>=1.8)。

将 sonar-cnes-report.jar 复制到 sonarqube 的插件文件夹中(在 linux 上路径应该是这样的 /opt/sonarqube/extensions/plugins )

重新启动 sonarqube(在Linux上:sudo service sonar restart)

帮助命令

使用 java -jar cnesreport.jar -h 以获取有关 cnesreport 以下帮助:

usage: java -jar cnesreport.jar [-a ] [-b ] [-c] [-d ] [-e] [-h] [-l ] [-o ] [-p ] [-r ] [-s ] [-t ] [-v] [-w] [-x ] Generate editable reports for SonarQube projects. -a,--author Name of the report writer. -b,--branch Branch of the targeted project. Requires Developer Edition or sonarqube-community-branch-plugin. Default: usage of main branch. -c,--disable-conf Disable export of quality configuration used during analysis. -d,--date Date for the report. Format: yyyy-MM-dd. Default: current date. -e,--disable-spreadsheet Disable spreadsheet generation. -f,--disable-csv Disable csv generation. -h,--help Display this message. -l,--language Language of the report. Values: en_US, fr_FR. Default: en_US. -m,--disable-markdown Disable markdown generation. -n,--template-markdown Path to the report template in markdown. Default: usage of internal template. -o,--output Output path for exported resources. -p,--project SonarQube key of the targeted project. -r,--template-report Path to the report template. Default: usage of internal template. -s,--server Complete URL of the targeted SonarQube server. -t,--token SonarQube token of the SonarQube user who has permissions on the project. -v,--version Display current version. -w,--disable-report Disable report generation. -x,--template-spreadsheet Path to the spreadsheet template. Default: usage of internal template. Please report issues at https://github.com/cnescatlab/sonar-cnes-report/issues

示例

如果正在使用 SonarQube 的安全实例,可以通过 -t 选项提供一个 SonarQube 身份验证令牌,并使用 -s 指定 SonarQube 实例的url。文本报告的内部模板将被 -r 选项所取代。

java -Xmx1024m -Xms1024m -jar sonar-cnes-report.jar -t 6bc36088524a4d06e3e07e73ba419127cd90ff04 -s http://172.16.106.188:9088/ -p projectId -r template.docx

生成的文件如下:

打开其中 word 的报告:

兼容矩阵

有关遗留版本,请在这里查看 wiki 页面 : Note on legacy versions

小结

通过简单的实验,我发现 sonar-cnes-report 报告的数据较 Sonar PDF Report Plugin 更为正确,推荐使用前者。

代码检查 CodeCheck 网络

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Spark性能优化 (1) | 常规性能调优
下一篇:Kafka入门教程与详解
相关文章