C #, PVS-Studio, ReSharper

    We are constantly being asked the question: "Does it make sense to use the PVS-Studio code analyzer if ReSharper is already used?". It is understood that the answer should be an article that will compare the capabilities of these tools in detecting errors in programs. We know that this is a dead end, and such an article will do nothing. However, the question is asked so often that it still needs to be answered. The answer is yes, it makes sense. I immediately warn you that in the article you will not find the expected comparison. But if you spend only 10 minutes to fully read this article, then we are sure you will agree with our answer and vision.

    PVS-Studio is a static code analyzer that detects errors in the code of C, C ++ programs. Recently, the analyzer has mastered a new field for itself - C #. Historically, ReSharper reigned among the helper tools for C #. This tool belongs to the category of productivity tool and is not in the classical sense a static code analyzer. However, ReSharper can perform many different checks and colors suspicious sections of code. Therefore, programmers inevitably have the question: “Does it make sense to look towards PVS-Studio, if you already have ReSharper?”.

    Answer: Yes! We are sure of this answer. But here it is impossible to justify this with a simple sign comparing opportunities. Make such a sign is not a problem. But we vowed to make detailed comparisons. As life shows, writing such comparisons rather spoils our karma, rather than improves it.

    For example, we had experience comparing PVS-Studio with Cppcheck and Visual Studio SCA. A lot of time and effort was spent. The results were presented in brief and detailed form. After which only the lazy did not write that we did everything wrong or that our comparison is unfair due to specially selected projects for verification.

    We see no more reason to waste time on such comparisons. No matter how thoroughly and honestly we approach him, one can always say that the comparison was biased.

    However, something we need to answer something to the person who asks about ReSharper. We can offer a great comparison option:

    Are you already using ReSharper? Excellent! Now install PVS-Studio and find errors in your project!

    This will be the best demonstration of the benefits of using PVS-Studio. By the way, there is no opposition. Tools can complement each other perfectly.

    The reader will say - well, the new tool will not hurt. But can you get to the C # tools market? Here, everything has been occupied and divided for a long time. Does someone need PVS-Studio for C #? To get started, the answer is:

    Certainty of death, small chance of success.  What are we waiting for?

    "Certain death. No chance of success. So what are we waiting for ?! "( en ).

    In fact, we already faced with the question:“ Do you need a PVS-Studio analyzer? ”This question sounded when the PVS-Studio analyzer was young and he was just about to gain popularity among C ++ programmers. It seemed pointless the appearance of another tool, because already existed:
    1. Compilers that implement the functionality of static analyzers. For example, some editions of Visual Studio contain a static C ++ code analyzer. And yet, for example, there is Clang.
    2. There are free code analyzers like Cppcheck.
    3. There are powerful paid tools: Coverity, Klocwork and so on.

    So why do we need “PVS-Studio for C ++?”. And we had nothing to answer this question. There is nothing to answer now. But this question no longer matters. We can easily demonstrate the benefits that the PVS-Studio analyzer brings.

    There is no more difference whether there are any other tools or not. We found thousands of errors in the programs, which is documented . We found these errors, despite the existence of other tools. You can talk about competitive advantages as much as you like. But we are not interested. Here are 9355 errors found in projects such as Chromium, Qt, LibreOffice, TortoiseSVN, Unreal Engine 4 and so on .

    Moreover, now we can give links when someone wants a comparison with a specific tool.
    • For example, someone wants to know why we are better than Clang. Excellent. Everything is very simple. We found errors in Clang: link 1 , link 2 .
    • Someone wants to know if it makes sense to use the PVS-Studio analyzer, or you can restrict yourself to the analyzer implemented in Visual Studio. Of course there is a point. Not for nothing that we find errors in the Visual Studio libraries: 2012 , 2013 .
    • Is it worth buying PVS-Studio if there is a free Cppcheck. Of course. There is a comparison article on this subject, which everyone scolded. Therefore, it is possible in another way: link .
    • Someone is sure that Coverity / Klocwork is enough for all occasions. Undoubtedly, these are powerful and extremely useful tools. But PVS-Studio doesn’t bother, since it can find what these tools don’t see: link 1 , link 2 .

    With the C # analyzer, we are only at the beginning of this journey. While we can modestly declare:
    • We found bugs in the Roslyn project.
    • Anyway, we find errors in the projects of Microsoft, which is famous for the high quality of the source code. To find at least something is already a great achievement. Examples: CoreFX , Microsoft Code Contracts

    Wait a moment and the question of comparison disappears. No, don’t wait. The analyzer can and should be used. Let him be young, and so far we have implemented only a small part of the diagnostics planned. But right now he can start to benefit. Try automatic verification after compilation. Hope you enjoy. And if something is not right - write , we are very actively working with reviews and suggestions.

    The results . Regardless of whether you use ReSharper or not, we offer to downloadand try the PVS-Studio analyzer. If he finds errors in your project, this will be the best proof of his usefulness. Just do not forget that single checks do not make sense. Code analyzers benefit only with regular use. It is inefficient to look for typos and errors by debugging the code if the analyzer can do this for you. Of course, he is not able to find all the mistakes, but he can save you a lot of time on more useful things than on finding a typo in the condition.

    Also popular now: