Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam

Webinar: Evaluation - 05.12

>
>
>
Beta-testing of PVS-Studio plugin for J…

Beta-testing of PVS-Studio plugin for JetBrains CLion

Jun 28 2021

Visual Studio from Microsoft has long been the main development environment to work with the PVS-Studio analyzer. Our analyzer started off on Windows, so Visual Studio was an obvious and reasonable choice. In more than 10 years of PVS-Studio development, the analyzer has become available for several other languages and platforms. No wonder people ask us if we can integrate PVS-Studio into their favorite IDEs.

0839_CLion_beta_test/image1.png

A year ago, on June 18, 2020, we released the first version of PVS-Studio plugin for the JetBrains Rider environment. That event coincided with another milestone moment - release of PVS-Studio C# on Linux and macOS.

Today, we are pleased to announce that we start public beta-testing of a plugin for another IDE from JetBrains — CLion. We believe, Linux and C++ cross-platform users will get better experience of using our product due to this change. Based on beta-tests, we hope to release the first CLion plugin version in the upcoming PVS-Studio 7.14 release, at the end of July to early August.

Take part in beta-testing of PVS-Studio for CLion

To fully test the plugin, you'll need to install both the beta plugin version and the C++ core beta version of the analyzer. There are several ways to install the plugin: from the official repository, from the repository on our site, or using Windows PVS-Studio installer. Below we'll tell you in detail how to do this.

After you install the plugin and the analyzer, you can register for the PVS-Studio for CLion beta-test on our early access page. You will receive a trial analyzer key by email.

Find here the detailed documentation how to install and work with PVS-Studio for CLion and Rider plugins. Below you'll read a brief instruction on how to install and first run PVS-Studio in CLion.

Any beta-test collects users' feedback on a new product, usability, and inevitable bugs that are always present in early versions. This beta test is no exception. If you found an error or simply want to share your experiences about the new PVS-Studio plugin, be sure to reply to the email you've received when registering to our beta-test,or contact us using the feedback form.

Installation from official repository

Run CLion and select File->Settings->Plugins, then select the Marketplace tab, and enter 'PVS-Studio' in the search field. Next, install the PVS-Studio for CLion plugin.

0839_CLion_beta_test/image2.png

How to install the plugin from the PVS-Studio repository

This step is similar to the previous one, but first you need to set up CLion for a new repository. To do this, go to File->Settings->Plugins, click on the "gear" icon on the right side of the window, and select Manage Plugin Repositories from the drop-down menu.

0839_CLion_beta_test/image4.png

In the opened window, add the http://files.pvs-studio.com/java/pvsstudio-clion-plugins/updatePlugins.xml path. Click OK.

0839_CLion_beta_test/image6.png

Next, install the plugin similar to the previous step.

Installation with Windows Installer

If you use a Windows operating system, you can install the plugin and the analyzer core from the distribution. To do this, download and run the installer from here. Download the ".exe" installer file in the Windows column of the table.

Installation of the C++ analyzer beta version

Besides the plugin itself, you must also install the C++ analyzer core. This way PVS-Studio will work correctly in CLion. To do this, follow this link and download a distribution for your platform. If you have installed a distribution for Windows, you can skip this step.

If you work on Linux or macOS, you can also use the following installation commands:

For debian-based systems:

wget -q -O - https://files.pvs-studio.com/beta/etc/pubkey.txt | \
  sudo apt-key add -

sudo wget -O /etc/apt/sources.list.d/viva64-beta.list \
  https://files.pvs-studio.com/beta/etc/viva64.list
 
sudo apt-get update
sudo apt-get install pvs-studio

For yum-based systems:

wget -O /etc/yum.repos.d/viva64-beta.repo \
  https://files.pvs-studio.com/beta/etc/viva64.repo
 
yum update
yum install pvs-studio

For zypper-based systems:

wget -q -O /tmp/viva64-beta.key https://files.pvs-studio.com/beta/etc/pubkey.txt
sudo rpm --import /tmp/viva64-beta.key
sudo zypper ar -f https://files.pvs-studio.com/beta/rpm viva64-beta
sudo zypper update
sudo zypper install pvs-studio

For macOS:

brew install viva64/pvs-studio/pvs-studio-beta

Product registration

After you register as a beta-tester and get a registration key, go to the Tools->PVS-Studio->Settings window to activate the license. Go to the Registration tab in the settings window.

0839_CLion_beta_test/image7.png

Enter the corresponding license data in the User Name and Serial Number fields. A quick reminder - you can get the registration key here: early access page.

First experience with the plugin

Once installed and configured, the plugin will roughly look like the screenshot below.

0839_CLion_beta_test/image9.png

The plugin allows you to analyze CMake projects opened in CLion, as well as individual selected files.

To run the analysis, click Tools->PVS-Studio->Check Project.

0839_CLion_beta_test/image11.png

To analyze selected files, click Tools-> PVS-Studio -> Check Current File.

0839_CLion_beta_test/image12.png

See analysis results in the PVS-Studio window:

0839_CLion_beta_test/image13.png

A table that consists of columns with warning error codes, problem descriptions, positions, etc.

Right-clicking on the PVS-Studio analyzer message will open a context menu that contains additional commands for selected analyzer messages.

'Mark selected messages as False Alarms / Remove false alarm masks' marks analyzer warning as a false positive. The command adds the code that triggered a warning and a special comment.

'Exclude from analysis' adds a path or a part of the path to the list of directories excluded from the analysis. In turn, a path or a part of the path indicate the file with analyzer warning. All files that fall under this filter will be excluded from the analysis.

0839_CLion_beta_test/image15.png

Double-clicking the left mouse button on the line will open a file on that very line where the analyzer warning was found.

0839_CLion_beta_test/image17.png

Plugin setup

To open the plugin settings window, go to Tools->PVS-Studio->Settings. The plugin settings panel has several tabs. Let's look closer at each of them.

Settings — PVS-Studio analyzer core settings. When you hover the mouse over the name of a setting, a hint shows up describing what the setting is for.

0839_CLion_beta_test/image19.png

Warnings — list of all warning types supported by the analyzer. If you untick a warning, all warnings of this type will be filtered in analyzer output table:

0839_CLion_beta_test/image21.png

Excludes — contains masks for file names and paths that will be excluded from analysis.

0839_CLion_beta_test/image23.png

How to start using analyzer on a large legacy project

Numerous existing analyzer warnings on legacy code often interfere with using static analysis regularly. Such code is usually well tested and stably works. So it may not be practical to correct all existing analyzer warnings. This may take a long time especially when the code base size is large enough. Warnings for existing code mix up with the ones generated on the new one, which is still in development.

To solve this problem and start using static analysis regularly, PVS-Studio offers the ability to "disable" messages for the old code. To suppress analyzer messages for the old code, use the main menu command 'Tools -> PVS-Studio -> Suppress All Messages' or the 'Suppress All Messages' button on PVS-Studio window panel. The suppression mechanism works as follows. First, you run the 'Suppress All Messages' command. Then suppressed warnings get into special suppress files. When you start the analysis later, all messages added to such suppress files will not appear in the analyzer report. The suppression system with suppress files is quite flexible. Let's say, you changed or moved code fragments that trigger suppressed warnings. The system can still "track" such messages.

0839_CLion_beta_test/image25.png

In CLion, suppressed warnings are added to suppress_base.json. This file is written in the .PVS-Studio directory in the root directory of the project opened in CLion. To return all messages to the analyzer output, delete this file and restart the analysis.

Check out the article "How to introduce a static code analyzer in a legacy project and not to discourage the team".

How to save and download analysis results

To save or load the analyzer results, use the main menu commands in 'Tools -> PVS-Studio':

0839_CLion_beta_test/image26.png

'Open Report' opens the .json report file and uploads its contents to the grid of the 'PVS-Studio' window.

The 'Recent Reports' submenu shows a list of the most recent report files that have been opened. If the report still exists by the path, clicking on a report file in the list will open the corresponding report. Its contents will be uploaded to the 'PVS-Studio' window.

'Save Report' saves all messages from the window (even the filtered ones) to the .json report file. If the current analysis has not yet been saved, you must specify a name and a place to save the report.

Similarly, 'Save Report As' saves all warnings from the window (even the filtered ones) to the .json report file, always offering to choose where to save the report.

Incremental analysis

We usually recommend running full analysis regularly, such as once a day, at night. In addition to nightly analysis, we highly recommend checking new code immediately after writing it. This way you'll get the best advantage of using the analyzer. To do this, use incremental analysis, which works as follows. A project was changed, a developer runs a build. After successful compilation only modified files will be analyzed. Modified files are the ones that have been changed since the previous analysis.

You can enable or disable incremental analysis. Choose the option Tools->PVS-Studio->Analysis after Build (Modified files only) and then Enabled or Disabled.

0839_CLion_beta_test/image27.png

Conclusion

By adding support for a new IDE - JetBrains CLion- we hope to make our analyzer more convenient for C++ users on all supported platforms (Windows, Linux, macOS). Although there are still many development environments with no direct PVS-Studio integration, apart from the possibility to use standard compiler warning viewing functionality, we plan to increase the number of IDEs we support directly in the future.

Based on the interest of our users, Visual Studio Code will be the most likely next candidate for such support. Please write us if you'd like our analyzer to be directly integrated into "your" IDE. Your idea may become part of our plans as well.

And as a closing note, let me remind you once again that you can register for the beta-testing and write us about your problems and wishes using the feedback form.



Comments (0)

Next comments next comments
close comment form