简体   繁体   English

定制的声纳Qube分析报告

[英]Customised Sonar Qube Analysis Report

I am trying to generate customized analysis reports from sonar. 我正在尝试从声纳生成定制的分析报告。 I am using sonar-ws-client. 我正在使用sonar-ws-client。 My code is : 我的代码是:

    Sonar sonar = new Sonar(new HttpClient4Connector(new Host(url, login, password)));

    Resource JunitTestCaseExample = sonar.find(ResourceQuery.createForMetrics("JunitTestCaseExample:JunitTestCaseExample", "critical_violations", 
            "major_violations", "minor_violations", "info_violations", "tests", "blocker_violations", "statements","coverage","uncovered_lines","lines",
            "skipped_tests","test_failures", "test_errors", "test_success_density", "new_coverage","overall_coverage"));

    Measure statements = JunitTestCaseExample.getMeasure("statements");
    System.out.println("statements : " + statements.getMetricKey() + " === " + statements.getFormattedValue());
    System.out.println(statements.getVariation1());

I am able to get most of the values, but statements.getVariation1() always returns null . 我能够获取大多数值,但是statements.getVariation1()始终返回null Is there any way to get the variation Value on Measure for 7 Days, 15 Days and 30 Days? 有什么方法可以获取7天,15天和30天的度量值变化量?

It's not a standard but you can fetch required data from sonar Db as its not available through web service Customised Sonar Qube Analysis Report. 这不是标准,但是您可以从声纳Db获取所需的数据,因为它无法通过Web服务“定制的声纳Qube分析报告”获得。

Step 1- fetch period_param from snapshots with the help of project_id from this you can manage to get variation period as you mention in your question 第1步,借助project_id从快照中获取period_param,您可以设法获取问题中提到的变化周期

2)-Execute this query,It will give you all variations, after that you can put your logic to pick what you want select distinct proj.name NAME_OF_PROJ,metric.name metric_name, metric.description Description, projdesc.value value,projdesc.variation_value_1,projdesc.variation_value_2,projdesc.variation_value_3,projdesc.variation_value_4,projdesc.variation_value_5 ,snap.created_at CREATED_DATE from projects proj inner join snapshots snap on snap.project_id=proj.id inner join " + "(select max(snap2.id) as id from snapshots snap2 where snap2.project_id in ("+projectId+") GROUP BY snap2.project_id ) as Lookup on Lookup.id=snap.id inner join project_measures projdesc on projdesc.snapshot_id=snap.id inner join metrics metric on projdesc.metric_id =metric.id where metric.id between '1' and "+metric_id_Count+' 2)-执行此查询,它将为您提供所有变化,然后您可以根据需要选择所需的逻辑,选择不同的项目名称NAME_OF_PROJ,metric.name metric_name,metric.description说明,projdesc.value值,projdesc。 variant_value_1,projdesc.variation_value_2,projdesc.variation_value_3,projdesc.variation_value_4,projdesc.variation_value_5,snap.created_at从项目proj内部联接快照捕捉到snap.project_id = proj.id内部联接“ +”(选择最大(s)2。作为快照snap2的ID,其中(“ + projectId +”)GROUP BY snap2.project_id中的snap2.project_id)作为对Lookup.id = snap.id的内部查找projdesc.snapshot_id = snap.id上的projdesc上的projdesc上的lookup .metric_id = metric.id,其中metric.id在“ 1”和“ + metric_id_Count +”之间

Hope it helps you. 希望对您有帮助。 Again remember as mention on sonar group its not a standard. 再次记得在声纳组上提到它不是一个标准。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM