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.

>
>
Best Warnings of Static Analyzer

Best Warnings of Static Analyzer

Oct 29 2021

Everyone who runs the static analyzer on a project for the first time is slightly shocked by hundreds, thousands or even tens of thousands of warnings. It may be frustrating. Is my code so terrible? Or is the analyzer lying? In any case, filtering by the severity changes the situation, not completely though. That's why we thought about how we could improve the first experience with the analyzer. Let me show you the new feature step by step...

0879_Best_Warnings/image1.png

Intelligence Diagnostic Filter

What does a person, who runs code through a static analyzer for the first time, encounter? When run on large projects, a static analyzer produces a huge number of warnings for various code fragments.

Yes, it may be an enormous number of warnings. Of course, there will be false positives among them. Alas, static analysis cannot exist without false positives. Therefore, it was necessary to create a new approach that would simplify the process when one is just starting out with the analyzer.

That's how we got the idea to develop a special mechanism that would analyze a list of warnings and find the most interesting ones among them. We named it the Intelligence Diagnostic Filter or IDF for short.

I will not go into the details of its implementation in this article. The developer who created the mechanism will explain it better. So, don't forget to subscribe to our Habr account so as not to miss his article :)

Let's look at the top ten warnings

Well, you have installed the analyzer – what's next? Of course, you need to run it on a large project. Otherwise, the picture will be incomplete. There is a simple pattern here – the more code lines you have, the more difficult it is to maintain the code quality. Accordingly, the more difficult it is to maintain the code quality, the more bugs this code contains.

0879_Best_Warnings/image2.png

This is what the first run of the analyzer may look like ...

We have to admit, it's not so exciting to appreciate the capabilities of the analyzer by looking through these warnings all at once. So open the additional toolbar and click on Best Warnings button:

0879_Best_Warnings/image4.png

Example of the button in the PVS-Studio plugin for Visual Studio

After a short processing pause, you get a list of the most significant code problems according to the IDF. This mechanism was also developed to demonstrate various features of the analyzer. Therefore, we limited the number of similar warnings in the output. This helps look at various types of code problems at once. This will also simplify further study of the remaining warnings.

Note. Remember to mark the most interesting warnings with a star! It will be easier to find them later :)

What's next?

Of course, do not ignore other warnings. The Analyzer Best Warnings mode was made to help you see how PVS-Studio benefits your project. This mode also demonstrates the abilities of static analysis. Therefore, after studying the most significant code problems according to the IDF mechanism, let's go back to other warnings.

To do this, just click on the Best Warnings button one more time:

0879_Best_Warnings/image6.png

Example of a button in the PVS-Studio plugin for Visual Studio

Now it's time to study all the remaining warnings. In fact, this is an optional step – you don't have to view ALL the remaining warnings, you can view only High level ones, for example:

0879_Best_Warnings/image8.png

How to filter warnings in the PVS-Studio plugin for Visual Studio

New warnings can get lost among the remaining ones. Also, the remaining warnings can distract you from the further use of the analyzer. In this case. So, I advise you to use the mechanism of warning suppression.

Click on the Suppress All Messages button:

0879_Best_Warnings/image10.png

How to suppress warnings in the Visual Studio plugin

Now you will see the warnings strictly for the new code. This is a super useful mechanism, so don't be afraid to use it. You can always bring these warnings back to the log from the suppression file.

Note. Warnings do not disappear without a trace! If you edit the code next to a suppressed warning, it will show up again.

IDF development

Of course, we will further develop this intelligent filtering mechanism. Analyzer Best Warnings is the first feature that is based on IDF, but it's not the last one :)

We have various thoughts and ideas on how else we can use it. For example, we may add the ability to sort the entire report. This feature would be convenient, since later you can hide the least reliable warnings according to the IDF. Or we may add the ability to adjust the user-specific settings for projects...

In a word, there are a huge number of ideas! However, the real driving force of changes and improvements is not developers, but users. This is one of our most important principles – we take into account the wishes of our audience.

Try the new feature and send us your thoughts and ideas! That way, we will not only find out what you think about the new mechanism, but also find the right vector of its development.

Additional links

Popular related articles
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…
Characteristics of PVS-Studio Analyzer by the Example of EFL Core Libraries, 10-15% of False Positives

Date: Jul 31 2017

Author: Andrey Karpov

After I wrote quite a big article about the analysis of the Tizen OS code, I received a large number of questions concerning the percentage of false positives and the density of errors (how many erro…
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…
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…
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…
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…
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…
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…
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…

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