To get a trial key
fill out the form below
Team License (a basic version)
Enterprise License (an extended version)
* By clicking this button you agree to our Privacy Policy statement

Request our prices
New License
License Renewal
--Select currency--
USD
EUR
GBP
RUB
* By clicking this button you agree to our Privacy Policy statement

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

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

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

Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
>
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/image28.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.

Popular related articles
PVS-Studio ROI

Date: Jan 30 2019

Author: Andrey Karpov

Occasionally, we're asked a question, what monetary value the company will receive from using PVS-Studio. We decided to draw up a response in the form of an article and provide tables, which will sho…
How PVS-Studio Proved to Be More Attentive Than Three and a Half Programmers

Date: Oct 22 2018

Author: Andrey Karpov

Just like other static analyzers, PVS-Studio often produces false positives. What you are about to read is a short story where I'll tell you how PVS-Studio proved, just one more time, to be more atte…
The Evil within the Comparison Functions

Date: May 19 2017

Author: Andrey Karpov

Perhaps, readers remember my article titled "Last line effect". It describes a pattern I've once noticed: in most cases programmers make an error in the last line of similar text blocks. Now I want t…
The way static analyzers fight against false positives, and why they do it

Date: Mar 20 2017

Author: Andrey Karpov

In my previous article I wrote that I don't like the approach of evaluating the efficiency of static analyzers with the help of synthetic tests. In that article, I give the example of a code fragment…
PVS-Studio for Java

Date: Jan 17 2019

Author: Andrey Karpov

In the seventh version of the PVS-Studio static analyzer, we added support of the Java language. It's time for a brief story of how we've started making support of the Java language, how far we've co…
The Ultimate Question of Programming, Refactoring, and Everything

Date: Apr 14 2016

Author: Andrey Karpov

Yes, you've guessed correctly - the answer is "42". In this article you will find 42 recommendations about coding in C++ that can help a programmer avoid a lot of errors, save time and effort. The au…
The Last Line Effect

Date: May 31 2014

Author: Andrey Karpov

I have studied many errors caused by the use of the Copy-Paste method, and can assure you that programmers most often tend to make mistakes in the last fragment of a homogeneous code block. I have ne…
Appreciate Static Code Analysis!

Date: Oct 16 2017

Author: Andrey Karpov

I am really astonished by the capabilities of static code analysis even though I am one of the developers of PVS-Studio analyzer myself. The tool surprised me the other day as it turned out to be sma…
Technologies used in the PVS-Studio code analyzer for finding bugs and potential vulnerabilities

Date: Nov 21 2018

Author: Andrey Karpov

A brief description of technologies used in the PVS-Studio tool, which let us effectively detect a large number of error patterns and potential vulnerabilities. The article describes the implementati…
Static analysis as part of the development process in Unreal Engine

Date: Jun 27 2017

Author: Andrey Karpov

Unreal Engine continues to develop as new code is added and previously written code is changed. What is the inevitable consequence of ongoing development in a project? The emergence of new bugs in th…

Comments (0)

Next comments
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site.
Learn More →
Accept