To get a trial key
fill out the form below
Team License (a basic version)
Enterprise License (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.

>
>
PVS-Studio has learned to watch over yo…

PVS-Studio has learned to watch over your programming

Jun 24 2011
Author:

PVS-Studio now has an operation mode that will help you to find errors and misprints as soon as possible. The analyzer launches right after the files have been compiled and "blushes with shame" for your code if something goes wrong. The feature is currently available only for Visual Studio 2010 users.

This note is obsolete. Please read "PVS-Studio's incremental analysis mode" in documentation.

0102_On-the-fly/image1.png

I wrote many times that the sooner an error is detected, the lower is the price of fixing it. Well, I'm certainly not the first one to say it and authors of numerous books and articles have been repeating this over again. Take S. McConnell, for example. So I will not repeat myself.

The previous versions of the PVS-Studio analyzer had to be run manually or during night builds. It is surely fine when you can look through a log at morning and fix some error found. But it's not ideal. It doesn't prevent you from making a couple of small mistakes during the day and spending 10 minutes to find each of them. PVS-Studio will hardly help you in such a case: it's not convenient to run it only for changed files and it's too long to run it for the whole project.

Fortunately, we are programmers ourselves and we are responsive to needs of our keyboard colleagues. A new mode of incremental analysis has appeared in PVS-Studio 4.30. Verification is now almost combined with the compilation step: the analyzer checks those files which are being compiled by pressing the F7 key that everyone loves so much. This mode can be enabled not just simply but very simply: you just have to check the box opposite to the "Incremental Analysis After Build" item in the PVS-Studio menu:

0102_On-the-fly/image2.png

Now let's see how it works by an example. Suppose I enjoyed the process of programming very much and was in a hurry, so I made a mistake in an array's index:

0102_On-the-fly/image3.png

The result of this expression is always 'false'. But I do not take notice of it. I'm writing the code further and feeling happy. Then, satisfied with the work I've done, I press F7 and the modified file compiles successfully and VS2010 does not generate any warnings. I proceed to edit the next code fragment.

But when compilation is complete, the PVS-Studio analyzer launches quietly in background and checks the modified files. It runs in background intentionally in order not to disturb the programmer. Static analysis takes more time to perform than compilation, so it's no good making the programmer sigh heavily watching the progress dialog. If everything is written correctly (both on your side and our side ;-) ), the programmer will never notice that PVS-Studio is working.

But we do have an error. Some time later the analyzer will signal a suspicious code fragment! It will get red and the programmer will but open the necessary tab to see the details:

0102_On-the-fly/image4.png

Indeed, you may read in the message that the condition is always false:

0102_On-the-fly/image5.png

As a result, the error will get fixed almost right after being written.

Please try the new mode of PVS-Studio. As usual, you may download the trial version here. If VS2010 gets a bit slow after installation, reduce its appetite. The analyzer by default uses all the available processor cores. So, you may specify in the settings how many cores can be used.

I'm anticipating some questions right now. That's why I've prepared a small FAQ at the end.

1) Why does the new mode have support only in VS2010?

Only Visual Studio 2010 has the API that allows you to determine which files have been modified and what files are dependent on them. In other words, a mechanism has appeared that allows you to choose the files to be checked. You may read about it in detail here [1].

If people like the new mode, we will think over as how to implement it for Visual Studio 2005/2008 users too. However, I want to note that it's much easier to switch to Visual Studio 2010 than it seems. You may select the old compiler but use capabilities of the new environment. This is achieved through Platform Toolset [2].

2) Why not implement check on the fly straight away and underline errors immediately like it is done in IntelliSense?

First, we do not have such a close integration with Visual Studio. To get it, we must be better friends with Microsoft.

Second, it won't do anyway. Static analysis is quite complicated and an analyzer must collect much information on a rather large code fragment to detect some errors. Since the code is being edited, it will be almost impossible to parse it. I think every programmer has seen how a C/C++ compiler goes mad about one unnecessary parenthesis or incorrect template. C/C++ is not the right language to be analyzed absolutely on the fly.

3) What to do if I cannot tell green from red?

A good remark. Well, in the next version there will be also a text written on the tab along with the color change.

4) Why doesn't something work here or there?

This is a new feature and some errors are highly probable. We will appreciate if you tell us about drawbacks you've noticed and your wishes. The Feedback page.

5) When I'm performing Rebuild, will the analyzer check the whole project then?

No. It's meaningless and too long. The analyzer ignores commands of solution and project rebuilds. If you want to check a solution or project, you still may use the corresponding commands in the analyzer.

References

UPDATE: Incremental Analysis feature available for all versions of Microsoft Visual Studio (2005/2008/2010) in PVS-Studio 4.33.

Popular related articles
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…
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 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…
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…
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…
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 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…
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 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…

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