Using a custom ruleset
The built-in rulesets that come with Visual Studio cover a variety of usage scenarios, and provide a way to use the Code Analysis tool in your projects immediately. They are also of great value when exploring an unfamiliar code base, as you can take advantage of the static analysis tools to identify areas where code should be rewritten to meet your in-house standards. All this means that the existing default rules may need to be customized depending on the needs and complexity of your project as this recipe will demonstrate.
Getting ready
We are going to continue with the project we created in the Analyzing your C++ code recipe. You will need VS2015 Community or higher in order to modify rulesets.
How to do it…
To use a custom ruleset, perform the following steps:
Open the project created in the previous recipe.
Open the
AnalyzeThis.cpp
file, and add the following highlighted code:# include "AnalyzeThis.h" int x = 0;
Right-click on the project (not solution) in Solution...