[build]Turn on C++ code analysis (#21085)

Using Cpp.Build.props to setup C++ code analysis as default.
Starting with a ruleset based on Microsoft Recomended Native rules. But changing all to info. Future pull request should change a rulr from info to warning and fix the code.
This commit is contained in:
sosssego 2022-10-16 13:49:52 +01:00 коммит произвёл GitHub
Родитель 5b13328bdd
Коммит 982415f578
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 260 добавлений и 0 удалений

Просмотреть файл

@ -35,6 +35,8 @@
<PreferredToolArchitecture>x64</PreferredToolArchitecture> <PreferredToolArchitecture>x64</PreferredToolArchitecture>
<VcpkgEnabled>false</VcpkgEnabled> <VcpkgEnabled>false</VcpkgEnabled>
<ExternalIncludePath>$(MSBuildThisFileFullPath)\..\deps\;$(ExternalIncludePath)</ExternalIncludePath> <ExternalIncludePath>$(MSBuildThisFileFullPath)\..\deps\;$(ExternalIncludePath)</ExternalIncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>$(MsbuildThisFileDirectory)\CppRuleSet.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup> <ItemDefinitionGroup>
<ClCompile> <ClCompile>

258
CppRuleSet.ruleset Normal file
Просмотреть файл

@ -0,0 +1,258 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Cpp Rule Set" Description="Based on Microsoft Native Recommended Rules. These rules focus on the most critical and common problems in your native code, including potential security holes and application crashes. You should include this rule set in any custom rule set you create for your native projects. This ruleset is designed to work with Visual Studio Professional edition and higher." ToolsVersion="17.0">
<Rules AnalyzerId="Microsoft.Analyzers.NativeCodeAnalysis" RuleNamespace="Microsoft.Rules.Native">
<Rule Id="C26100" Action="Info" />
<Rule Id="C26101" Action="Info" />
<Rule Id="C26110" Action="Info" />
<Rule Id="C26111" Action="Info" />
<Rule Id="C26112" Action="Info" />
<Rule Id="C26115" Action="Info" />
<Rule Id="C26116" Action="Info" />
<Rule Id="C26117" Action="Info" />
<Rule Id="C26140" Action="Info" />
<Rule Id="C26437" Action="Info" />
<Rule Id="C26439" Action="Info" />
<Rule Id="C26441" Action="Info" />
<Rule Id="C26444" Action="Info" />
<Rule Id="C26449" Action="Info" />
<Rule Id="C26450" Action="Info" />
<Rule Id="C26451" Action="Info" />
<Rule Id="C26452" Action="Info" />
<Rule Id="C26453" Action="Info" />
<Rule Id="C26454" Action="Info" />
<Rule Id="C26478" Action="Info" />
<Rule Id="C26479" Action="Info" />
<Rule Id="C26495" Action="Info" />
<Rule Id="C26498" Action="Info" />
<Rule Id="C26800" Action="Info" />
<Rule Id="C26810" Action="Info" />
<Rule Id="C26811" Action="Info" />
<Rule Id="C26813" Action="Info" />
<Rule Id="C26815" Action="Info" />
<Rule Id="C26816" Action="Info" />
<Rule Id="C26817" Action="Info" />
<Rule Id="C26819" Action="Info" />
<Rule Id="C26820" Action="Info" />
<Rule Id="C26827" Action="Info" />
<Rule Id="C26828" Action="Info" />
<Rule Id="C28020" Action="Info" />
<Rule Id="C28021" Action="Info" />
<Rule Id="C28022" Action="Info" />
<Rule Id="C28023" Action="Info" />
<Rule Id="C28024" Action="Info" />
<Rule Id="C28039" Action="Info" />
<Rule Id="C28112" Action="Info" />
<Rule Id="C28113" Action="Info" />
<Rule Id="C28125" Action="Info" />
<Rule Id="C28137" Action="Info" />
<Rule Id="C28138" Action="Info" />
<Rule Id="C28159" Action="Info" />
<Rule Id="C28160" Action="Info" />
<Rule Id="C28163" Action="Info" />
<Rule Id="C28164" Action="Info" />
<Rule Id="C28182" Action="Info" />
<Rule Id="C28183" Action="Info" />
<Rule Id="C28193" Action="Info" />
<Rule Id="C28196" Action="Info" />
<Rule Id="C28202" Action="Info" />
<Rule Id="C28203" Action="Info" />
<Rule Id="C28205" Action="Info" />
<Rule Id="C28206" Action="Info" />
<Rule Id="C28207" Action="Info" />
<Rule Id="C28209" Action="Info" />
<Rule Id="C28210" Action="Info" />
<Rule Id="C28211" Action="Info" />
<Rule Id="C28212" Action="Info" />
<Rule Id="C28213" Action="Info" />
<Rule Id="C28214" Action="Info" />
<Rule Id="C28215" Action="Info" />
<Rule Id="C28216" Action="Info" />
<Rule Id="C28217" Action="Info" />
<Rule Id="C28218" Action="Info" />
<Rule Id="C28219" Action="Info" />
<Rule Id="C28220" Action="Info" />
<Rule Id="C28221" Action="Info" />
<Rule Id="C28222" Action="Info" />
<Rule Id="C28223" Action="Info" />
<Rule Id="C28224" Action="Info" />
<Rule Id="C28225" Action="Info" />
<Rule Id="C28226" Action="Info" />
<Rule Id="C28227" Action="Info" />
<Rule Id="C28228" Action="Info" />
<Rule Id="C28229" Action="Info" />
<Rule Id="C28230" Action="Info" />
<Rule Id="C28231" Action="Info" />
<Rule Id="C28232" Action="Info" />
<Rule Id="C28233" Action="Info" />
<Rule Id="C28234" Action="Info" />
<Rule Id="C28235" Action="Info" />
<Rule Id="C28236" Action="Info" />
<Rule Id="C28237" Action="Info" />
<Rule Id="C28238" Action="Info" />
<Rule Id="C28239" Action="Info" />
<Rule Id="C28240" Action="Info" />
<Rule Id="C28241" Action="Info" />
<Rule Id="C28243" Action="Info" />
<Rule Id="C28244" Action="Info" />
<Rule Id="C28245" Action="Info" />
<Rule Id="C28246" Action="Info" />
<Rule Id="C28250" Action="Info" />
<Rule Id="C28251" Action="Info" />
<Rule Id="C28252" Action="Info" />
<Rule Id="C28253" Action="Info" />
<Rule Id="C28254" Action="Info" />
<Rule Id="C28262" Action="Info" />
<Rule Id="C28263" Action="Info" />
<Rule Id="C28267" Action="Info" />
<Rule Id="C28272" Action="Info" />
<Rule Id="C28273" Action="Info" />
<Rule Id="C28275" Action="Info" />
<Rule Id="C28279" Action="Info" />
<Rule Id="C28280" Action="Info" />
<Rule Id="C28282" Action="Info" />
<Rule Id="C28285" Action="Info" />
<Rule Id="C28286" Action="Info" />
<Rule Id="C28287" Action="Info" />
<Rule Id="C28288" Action="Info" />
<Rule Id="C28289" Action="Info" />
<Rule Id="C28290" Action="Info" />
<Rule Id="C28291" Action="Info" />
<Rule Id="C28300" Action="Info" />
<Rule Id="C28301" Action="Info" />
<Rule Id="C28302" Action="Info" />
<Rule Id="C28303" Action="Info" />
<Rule Id="C28304" Action="Info" />
<Rule Id="C28305" Action="Info" />
<Rule Id="C28306" Action="Info" />
<Rule Id="C28307" Action="Info" />
<Rule Id="C28308" Action="Info" />
<Rule Id="C28309" Action="Info" />
<Rule Id="C28350" Action="Info" />
<Rule Id="C28351" Action="Info" />
<Rule Id="C33001" Action="Info" />
<Rule Id="C33004" Action="Info" />
<Rule Id="C33005" Action="Info" />
<Rule Id="C33010" Action="Info" />
<Rule Id="C33011" Action="Info" />
<Rule Id="C33020" Action="Info" />
<Rule Id="C6001" Action="Info" />
<Rule Id="C6011" Action="Info" />
<Rule Id="C6029" Action="Info" />
<Rule Id="C6031" Action="Info" />
<Rule Id="C6053" Action="Info" />
<Rule Id="C6054" Action="Info" />
<Rule Id="C6059" Action="Info" />
<Rule Id="C6063" Action="Info" />
<Rule Id="C6064" Action="Info" />
<Rule Id="C6066" Action="Info" />
<Rule Id="C6067" Action="Info" />
<Rule Id="C6101" Action="Info" />
<Rule Id="C6200" Action="Info" />
<Rule Id="C6201" Action="Info" />
<Rule Id="C6214" Action="Info" />
<Rule Id="C6215" Action="Info" />
<Rule Id="C6216" Action="Info" />
<Rule Id="C6217" Action="Info" />
<Rule Id="C6220" Action="Info" />
<Rule Id="C6226" Action="Info" />
<Rule Id="C6230" Action="Info" />
<Rule Id="C6235" Action="Info" />
<Rule Id="C6236" Action="Info" />
<Rule Id="C6237" Action="Info" />
<Rule Id="C6242" Action="Info" />
<Rule Id="C6248" Action="Info" />
<Rule Id="C6250" Action="Info" />
<Rule Id="C6255" Action="Info" />
<Rule Id="C6258" Action="Info" />
<Rule Id="C6259" Action="Info" />
<Rule Id="C6260" Action="Info" />
<Rule Id="C6262" Action="Info" />
<Rule Id="C6263" Action="Info" />
<Rule Id="C6268" Action="Info" />
<Rule Id="C6269" Action="Info" />
<Rule Id="C6270" Action="Info" />
<Rule Id="C6271" Action="Info" />
<Rule Id="C6272" Action="Info" />
<Rule Id="C6273" Action="Info" />
<Rule Id="C6274" Action="Info" />
<Rule Id="C6276" Action="Info" />
<Rule Id="C6277" Action="Info" />
<Rule Id="C6278" Action="Info" />
<Rule Id="C6279" Action="Info" />
<Rule Id="C6280" Action="Info" />
<Rule Id="C6281" Action="Info" />
<Rule Id="C6282" Action="Info" />
<Rule Id="C6283" Action="Info" />
<Rule Id="C6284" Action="Info" />
<Rule Id="C6285" Action="Info" />
<Rule Id="C6286" Action="Info" />
<Rule Id="C6287" Action="Info" />
<Rule Id="C6288" Action="Info" />
<Rule Id="C6289" Action="Info" />
<Rule Id="C6290" Action="Info" />
<Rule Id="C6291" Action="Info" />
<Rule Id="C6292" Action="Info" />
<Rule Id="C6293" Action="Info" />
<Rule Id="C6294" Action="Info" />
<Rule Id="C6295" Action="Info" />
<Rule Id="C6296" Action="Info" />
<Rule Id="C6297" Action="Info" />
<Rule Id="C6299" Action="Info" />
<Rule Id="C6302" Action="Info" />
<Rule Id="C6303" Action="Info" />
<Rule Id="C6305" Action="Info" />
<Rule Id="C6306" Action="Info" />
<Rule Id="C6308" Action="Info" />
<Rule Id="C6310" Action="Info" />
<Rule Id="C6312" Action="Info" />
<Rule Id="C6314" Action="Info" />
<Rule Id="C6317" Action="Info" />
<Rule Id="C6318" Action="Info" />
<Rule Id="C6319" Action="Info" />
<Rule Id="C6324" Action="Info" />
<Rule Id="C6328" Action="Info" />
<Rule Id="C6331" Action="Info" />
<Rule Id="C6332" Action="Info" />
<Rule Id="C6333" Action="Info" />
<Rule Id="C6335" Action="Info" />
<Rule Id="C6381" Action="Info" />
<Rule Id="C6383" Action="Info" />
<Rule Id="C6384" Action="Info" />
<Rule Id="C6385" Action="Info" />
<Rule Id="C6386" Action="Info" />
<Rule Id="C6387" Action="Info" />
<Rule Id="C6388" Action="Info" />
<Rule Id="C6500" Action="Info" />
<Rule Id="C6501" Action="Info" />
<Rule Id="C6503" Action="Info" />
<Rule Id="C6504" Action="Info" />
<Rule Id="C6505" Action="Info" />
<Rule Id="C6506" Action="Info" />
<Rule Id="C6508" Action="Info" />
<Rule Id="C6509" Action="Info" />
<Rule Id="C6510" Action="Info" />
<Rule Id="C6511" Action="Info" />
<Rule Id="C6513" Action="Info" />
<Rule Id="C6514" Action="Info" />
<Rule Id="C6515" Action="Info" />
<Rule Id="C6516" Action="Info" />
<Rule Id="C6517" Action="Info" />
<Rule Id="C6518" Action="Info" />
<Rule Id="C6522" Action="Info" />
<Rule Id="C6525" Action="Info" />
<Rule Id="C6527" Action="Info" />
<Rule Id="C6530" Action="Info" />
<Rule Id="C6540" Action="Info" />
<Rule Id="C6551" Action="Info" />
<Rule Id="C6552" Action="Info" />
<Rule Id="C6701" Action="Info" />
<Rule Id="C6702" Action="Info" />
<Rule Id="C6703" Action="Info" />
<Rule Id="C6704" Action="Info" />
<Rule Id="C6705" Action="Info" />
<Rule Id="C6706" Action="Info" />
<Rule Id="C6993" Action="Info" />
<Rule Id="C6995" Action="Info" />
<Rule Id="C6997" Action="Info" />
</Rules>
</RuleSet>