In this note I'll share with you some tips on how to easily start using PVS-Studio. Let's explore these two use cases: when you try the analyzer for the first time and when you integrate it into your project.
So, what do I expect when running the analyzer on a project for the first time? Primarily, I expect the analyzer to detect some interesting errors. However, there can be two extremes:
Let's take a look at both of these cases.
#1. You have enabled all necessary diagnostics and the analysis has completed successfully, but PVS-Studio still finds nothing? This is a good case, but it's worth noting that a single check is usually not enough.
Try to run a project analysis regularly for a period of time. As the result, the analyzer will be able to detect the issues that the team has not yet found and fixed. This way you can fully evaluate the tool's value.
I recommend you find out more on this topic in this brief note.
#2. Let's imagine a situation when the analyzer issues dozens, or even thousands of warnings. If only we could view just the interesting ones... The solution is the "Best warnings" filter. I'll explain it in a few words.
The "Best warnings" filter selects the most interesting warnings among all the other ones: these warnings should be diverse and report real errors in code.
You can enable this filter with a simple click, and immediately view a selection of the most interesting warnings. There are no more than 10 of them there.
The "Best warnings" filter is available in the "C and C++ Compiler Monitoring UI" tool, as well as in PVS-Studio plugins for:
We collected more information about "Best Warnings" in the documentation.
**
I'd like to answer these possible questions in advance:
You can find the answers under the spoilers.
The algorithm is not perfect. Please contact us if you didn't like the list of warnings or if false positives got into it. We'll try to fix it.
If you didn't like the resulting list try looking at warnings of "High" and "Medium" levels from the analyzer's full report. You may find something interesting there.
I decided to integrate PVS-Studio in an old project with a large amount of legacy code. I ran the analyzer and got hundreds of warnings. What's next? How can my team spot a new warning and correct an error if the total number of warnings changes from 673 to 674? The answer is — suppress warnings for legacy code.
The action algorithm is the following:
Use the baselining mechanism to suppress warnings for legacy code.
Making it easy to use PVS-Studio:
I also recommend looking through this article. It answers many questions related to the analyzer's first start.
You can download the latest version of PVS-Studio here.
0