Configuring the Warnings Next Generation plugin for PVS-Studio integration

Configuring the Warnings Next Generation plugin for PVS-Studio integration
The release of PVS-Studio 7.04 coincided with the release of the Warnings Next Generation 6.0.0 plugin for Jenkins. In this release, the Warnings NG Plugin added support for the static analyzer PVS-Studio. This plugin visualizes data about compiler warnings or other analysis tools in Jenkins. This article will detail how to install and configure this plugin for use with PVS-Studio and describe most of its capabilities.

Installing the Warnings Next Generation Plugin in Jenkins

By default, Jenkins is located at http://localhost:8080. On the Jenkins homepage, we select the 'Manage Jenkins' option in the top left:

Configuring the Warnings Next Generation plugin for PVS-Studio integration

Next, we select 'Manage Plugins' and open the 'Available' tab:

Configuring the Warnings Next Generation plugin for PVS-Studio integration

In the upper right corner of the filter field, we enter 'Warnings Next Generation':

Configuring the Warnings Next Generation plugin for PVS-Studio integration

We find the plugin in the list, check the box on the left and click 'Install without restart':

Configuring the Warnings Next Generation plugin for PVS-Studio integration

The plugin installation page will open. Here we will see the installation results:

Configuring the Warnings Next Generation plugin for PVS-Studio integration

Creating a new job in Jenkins

Now, let's create a job with a free configuration. On the Jenkins homepage, we select 'New Item'. We enter the project name (for example, WTM) and choose 'Freestyle project'.

Configuring the Warnings Next Generation plugin for PVS-Studio integration

We click 'Ok', which will open the job configuration page. At the bottom of this page, in the 'Post-build Actions' section, we open the 'Add post-build action' list. From the list, we select 'Record compiler warnings and static analysis results':

Configuring the Warnings Next Generation plugin for PVS-Studio integration

In the dropdown list of the 'Tool' field, we select 'PVS-Studio', after which we click the save button. On the job page, we click 'Build Now' to create a folder in the Jenkins workspace for our job:

Configuring the Warnings Next Generation plugin for PVS-Studio integration

Getting the project build results

Today, I came across the dotnetcore/WTM project trending on GitHub. I downloaded it from GitHub, placed it in the WTM build directory in Jenkins, and analyzed it in Visual Studio using the PVS-Studio analyzer. A detailed description of using PVS-Studio in Visual Studio is presented in the corresponding article: PVS-Studio for Visual Studio.

I ran the project build in Jenkins a couple of times. As a result, a chart appeared in the top right corner on the WTM job page in Jenkins, and a menu item appeared on the left: PVS-Studio Warnings:

Configuring the Warnings Next Generation plugin for PVS-Studio integration

Clicking on the chart or this menu item opens a page with the visualization of the PVS-Studio analyzer report by the Warnings Next Generation plugin:

Configuring the Warnings Next Generation plugin for PVS-Studio integration

Page with results

At the top of the page, there are two pie charts. To the right of the charts, there is a graph window. At the bottom, there is a table.

Configuring the Warnings Next Generation plugin for PVS-Studio integration

The left pie chart shows the ratio of warnings of varying levels of severity, while the right one displays the ratio of new, unresolved, and resolved warnings. There are three charts in total. You can switch between the displayed charts using the arrows on the left and right. The first two charts provide the same information as the pie charts, while the third shows the change in the number of warnings.

Configuring the Warnings Next Generation plugin for PVS-Studio integration

You can choose builds or days as the points on the charts.

It is also possible to narrow and expand the time range of the chart to view data over a specific period:

Configuring the Warnings Next Generation plugin for PVS-Studio integration

You can hide graphs for certain metrics by clicking on the metric label in the chart's legend:

Configuring the Warnings Next Generation plugin for PVS-Studio integration

Chart after hiding the ‘Normal’ metric:

Configuring the Warnings Next Generation plugin for PVS-Studio integration

At the bottom is a table displaying the analyzer report data. Clicking on a segment of the pie chart filters the table:

Configuring the Warnings Next Generation plugin for PVS-Studio integration

The table has several tabs for filtering data. In this example, filtering by namespace, file, category (warning name) is available. You can select how many warnings to display per page (10, 25, 50, 100):

Configuring the Warnings Next Generation plugin for PVS-Studio integration

There is an option to filter data by the term entered in the ‘Search’ field. Example of filtering by the word ‘Base’:

Configuring the Warnings Next Generation plugin for PVS-Studio integration

On the ‘Issues’ tab, clicking the plus sign at the start of the table row will display a brief description of the warning:

Configuring the Warnings Next Generation plugin for PVS-Studio integration

The brief description includes a link to a website with detailed information about this warning.

Clicking on values in the ‘Package’, ‘Category’, ‘Type’, and ‘Severity’ columns filters the table data based on the selected value. Filter by category:

Configuring the Warnings Next Generation plugin for PVS-Studio integration

The ‘Age’ column shows how many builds have experienced this warning. Clicking on the value in the ‘Age’ column opens the build page where this warning first appeared.

Clicking on the value in the ‘File’ column opens the source code of the file at the line with the code that triggered the warning. If the file is not present in the build directory or has been moved after the report was created, opening the source code of the file will not be possible.

Configuring the Warnings Next Generation plugin for PVS-Studio integration

Conclusion

Warnings Next Generation has proven to be a very convenient data visualization tool in Jenkins. We hope that support for PVS-Studio by this plugin will greatly assist those who already use PVS-Studio and attract the attention of other Jenkins users to static analysis. If you decide to choose PVS-Studio as your static analyzer, we will be very pleased. We invite you to download and try our tool.

Configuring the Warnings Next Generation plugin for PVS-Studio integration

If you wish to share this article with an English-speaking audience, please use the link to the translation: Valery Komarov. Configuration of the Warnings Next Generation plugin for integration into PVS-Studio.

Source: habr.com

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster