Is there an API to retrieve metrics from polyspace access

4 ビュー (過去 30 日間)
Olivier
Olivier 2021 年 2 月 12 日
コメント済み: Ashray 2023 年 10 月 19 日
Hello,
I have a polyspace server like url:9443
Inside it, with jenkins, I created a folder structure that looks like Public/project_name/branch_name.
I can access the server with my access license, and I see all the history and metrics from my jenkins builds in there (polyspace being triggered by jenkins).
For reporting, I have to recover the metrics of a specific project_name/branch_name. Is there an API to access it?
The url of the page where I see the metrics is like : url:9443/metrics/index.html?a=metrics&p=44&r=13
The other way I see is dumping the html page and analyzing it, but this is not a very "easy" way.
Thanks
Olivier

採用された回答

Anirban
Anirban 2021 年 2 月 12 日
編集済み: Anirban 2021 年 2 月 12 日
Hi Olivier,
You definitely have options besides dumping the full html page.
Just to clarify, when you say "metrics", do you mean "code complexity metrics" that Polyspace calculates or all the information that you see on a page like this:
url:9443/metrics/index.html?a=metrics&p=44&r=13
Either way, you have to use the polyspace-access command with the -export option.
If you want the code complexity metrics, you have to use:
polyspace-access ... -export ...-code-metrics
This would export only the code complexity metrics to a tab-delimited text file and you can perform the calculations on the text file.
If you want all the info on the Polyspace Access dashboard exported, you have to first export results from a project to a text file with whatever filter you want and perform the computations on the text file. The polyspace-access command does not directly give out all the information that is on the Polyspace Access dashboard.
For syntax information and how to export only certain types of results, see polyspace-access.
If you use the Polyspace plugin in Jenkins, you can use some additional helper commands that does some of the computations. For instance, to get the number of results that are "To do" on the Polyspace Access dashboard, you can:
  • Apply a filter when exporting results to filter results that have the status "Unreviewed" (see the connection between "To do" and result statuses here)
  • Add up the number of results in the exported file using $ps_helper report_count_findings
That way, you can compute all the numbers that you see on the Polyspace Access dashboard without any heavy scripting. You can see an example script in Sample Scripts for Polyspace Analysis with Jenkins.
  1 件のコメント
Ashray
Ashray 2023 年 10 月 19 日
Hello Anirban,
Is there any way to retrive the line number as well for a given warning?
Also , it would be helpful if i can export one line suggestion which is present in "Result Details" Tab.
PS: it has been highlighted in red what i need to retrive/export in the polyspace report.

サインインしてコメントする。

その他の回答 (1 件)

Olivier
Olivier 2021 年 2 月 15 日
Hello,
I was able to retrieve the data thanks to your answer.
I did not use the polyspace plugin in jenkins, because I use a multibranch pipeline, so I used the JenkinsFile approach instead (using the example provided by mathworks).
One question:
Is there a way to retrieve the runId that I have to pass to the polyspace-access -export command without parsing the jenkins output (it's in here anyway, so it will be easy to parse, but maybe there is an easier/cleaner way)
Thanks
  1 件のコメント
Anirban
Anirban 2021 年 2 月 16 日
編集済み: Anirban 2021 年 2 月 16 日
Yes, you can use the polyspace-access -list-project with the project name as argument to get the last run ID of the project.

サインインしてコメントする。

タグ

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by