Java code validation in VS Code, Boost smart pointers, plugin for Qt Creator on macOS

Java code validation in VS Code, Boost smart pointers, plugin for Qt Creator on macOS

A new release of PVS-Studio has been released – 7.29. Now you can run Java project analysis through the VS Code plugin, check Boost smart pointers, use the PVS-Studio plugin for Qt Creator 12 on macOS, and that’s not all! More details in this article.

You can download the PVS-Studio version here.

Support for Java projects in the plugin for Visual Studio Code

In the PVS-Studio plugin for Visual Studio Code, the ability to analyze Java projects has appeared. Functionality includes:

  • launch the analysis and view the report;

  • suppression of warnings using suppress-files;

  • incremental analysis;

  • and other functions described in the corresponding section of the documentation.

Support for Boost smart pointers

The C++ parser has gained support for smart pointers from the Boost library: boost::unique_ptr and boost::shared_ptr.

The PVS-Studio parser now detects errors such as null pointer dereference when using class data.

String hash accounting for marking false positives

In the new version of PVS-Studio, a mode of accounting for the hash of the source code line appeared, which caused a trigger when marking false positives.

In PVS-Studio, the hash was still considered, but it was used for navigation and more efficient operation of suppress files. Now there is a new way of using the hash: it can be specified in a line when marking false positives. This allows you to understand whether a line of code has changed since the trigger was marked as false. If there are changes to the code, the false positive flag will no longer suppress the analyzer warning.

An example of a string specifying a false positive flag and a change tracking hash:

std::string(4, std::string().at(0)); //-V530 //-VH"920700501"

Support for this function appeared in PVS-Studio plug-ins for Microsoft Visual Studio. You can learn more about the new mode in the documentation.

Note. If you are interested in learning more about methods and technologies for suppressing false positives, you can read this article.

Plugin support for Qt Creator 12 on macOS

Support for the PVS-Studio Qt Creator 12 plugin has appeared on operating systems of the macOS family.

You can learn more about using the PVS-Studio plugin in Qt Creator in the documentation.

New diagnostics

C, C++

  • V839. Increased efficiency. Function returns a constant value. This may interfere with move semantics.

  • V1104. Priority of ‘M’ operator is higher than that of the ‘N’ operator. Possible errors parentheses.

  • V2625. MISRA. Identifier with external linkage must be unique.

c#

  • V3194. Calling ‘OfType’ for collection will return an empty collection. This cannot be used in elements that contain elements for the parameter type.

  • V3195. Collection initializer implicitly calls the ‘Add’ method. Using this number with a certain null value will result in a null dereference exception.

Java

  • V6108. Do no use real-type variables in ‘for’ loop counters.

  • V6109. Potentially distinguished seed is used in pseudo-random number generator.

C++ quiz from PVS-Studio and Serhiy Kushnirenko

In this release, the PVS-Studio team together with Serhii Kushnirenko prepared a C++ quiz based on the errors described in his articles.

Try to find errors in the code and test your attentiveness and knowledge of the language! The quiz is available at the link.

Articles

For those who write in C++

For those who write C#

For those who write in Java

Articles of general topics

Want to test your project with PVS-Studio? Start from this page.

If you want to receive news about new releases, you can subscribe to the newsletter from the PVS-Studio team at the link.

If you would like to share this article with an English-speaking audience, please use the translation link: Gleb Aslamov. PVS-Studio 7.29: Java code check in VS Code, Boost smart pointers, and plugin for Qt Creator on macOS.

Related posts