Skip to content

Commit

Permalink
Merge pull request #2307 from guwirth/cppcheck-2.70
Browse files Browse the repository at this point in the history
Cppcheck 2.70 support
  • Loading branch information
guwirth authored Feb 11, 2022
2 parents e9a8171 + a01db27 commit acb419b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
32 changes: 25 additions & 7 deletions cxx-sensors/src/main/resources/cppcheck.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2115,11 +2115,11 @@ Memory allocation size is negative.Negative allocation size has no specified beh
</rule>
<rule>
<key>noConstructor</key>
<name>The class 'classname' does not have a constructor although it has private member variables</name>
<name>The class 'classname' does not declare a constructor although it has private member variables which likely require initialization</name>
<description>
<![CDATA[
<p>
The class 'classname' does not have a constructor although it has
The class 'classname' does not declare a constructor although it has
private member variables. Member variables of builtin types are left
uninitialized when the class is instantiated. That may cause bugs or
undefined behavior.
Expand Down Expand Up @@ -8129,12 +8129,12 @@ Same iterator is used with different containers 'container1' and
</rule>
<rule>
<key>iterators3</key>
<name>Same iterator is used with containers 'container' that are defined in different scopes</name>
<name>Same iterator is used with containers 'container' that are temporaries or defined in different scopes</name>
<description>
<![CDATA[
<p>
Same iterator is used with containers 'container' that are defined in
different scopes.
Same iterator is used with containers 'container' that are temporaries
or defined in different scopes.
</p>
<h2>References</h2>
<p><a href="https://cwe.mitre.org/data/definitions/664.html" target="_blank">CWE-664: Improper Control of a Resource Through its Lifetime</a></p>
Expand Down Expand Up @@ -8504,11 +8504,11 @@ Parameter 'x' can be declared with const
</rule>
<rule>
<key>danglingTemporaryLifetime</key>
<name>Using object to temporary</name>
<name>Using object that is a temporary</name>
<description>
<![CDATA[
<p>
Using object to temporary.
Using object that is a temporary.
</p>
<h2>References</h2>
<p><a href="https://cwe.mitre.org/data/definitions/562.html" target="_blank">CWE-562: Return of Stack Variable Address</a></p>
Expand Down Expand Up @@ -8981,6 +8981,24 @@ missing return statement
<remediationFunction>LINEAR</remediationFunction>
<remediationFunctionGapMultiplier>5min</remediationFunctionGapMultiplier>
</rule>
<!-- ########### New in Cppcheck 2.70 ########### -->
<rule>
<key>missingMemberCopy</key>
<name>Member variable 'classname::varnamepriv' is not assigned in the copy constructor</name>
<description><![CDATA[
<p>
Member variable 'classname::varnamepriv' is not assigned in the copy
constructor. Should it be copied?
</p>
<h2>References</h2>
<p><a href="https://cwe.mitre.org/data/definitions/398.html" target="_blank">CWE-398: 7PK - Code Quality</a></p>
]]></description>
<tag>cwe</tag>
<severity>MINOR</severity>
<type>BUG</type>
<remediationFunction>LINEAR</remediationFunction>
<remediationFunctionGapMultiplier>5min</remediationFunctionGapMultiplier>
</rule>
<!-- ########### Misra Rules ########### -->
<rule>
<key>misra-c2012-1.1</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void createRulesTest() {
def.define(context);

RulesDefinition.Repository repo = context.repository(CxxCppCheckRuleRepository.KEY);
assertEquals(665, repo.rules().size());
assertEquals(666, repo.rules().size());
}

}
Binary file modified cxx-sensors/src/tools/cwec_latest.xml.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion cxx-sensors/src/tools/generate_cppcheck_resources.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ECHO create Cppcheck errorlist cppcheck-errorlist.xml...
"%CPPCHECK_DIR%cppcheck.exe" %CPPCHECK_LIBRARY_ARGS% --errorlist --xml-version=2 > cppcheck-errorlist.xml

ECHO create SonarQube rules file cppcheck.xml...
"%CPPCHECK_DIR%cppcheck.exe" %CPPCHECK_LIBRARY_ARGS% --errorlist --xml-version=2 | "%PYTHON_DIR%python.exe" cppcheck_createrules.py rules cwec_v4.5.xml > cppcheck.xml
"%CPPCHECK_DIR%cppcheck.exe" %CPPCHECK_LIBRARY_ARGS% --errorlist --xml-version=2 | "%PYTHON_DIR%python.exe" cppcheck_createrules.py rules cwec_v4.6.xml > cppcheck.xml

ECHO create cppcheck-comparison.md...
"%PYTHON_DIR%python.exe" utils_createrules.py comparerules "%SCRIPT_DIR%\..\main\resources\cppcheck.xml" .\cppcheck.xml > cppcheck-comparison.md
2 changes: 1 addition & 1 deletion cxx-sensors/src/tools/generate_cppcheck_resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
wget https://cwe.mitre.org/data/xml/cwec_latest.xml.zip --output-document=cwec_latest.xml.zip && unzip -j -o cwec_latest.xml.zip

cppcheck ${CPPCHECK_LIBRARY_ARGS} --errorlist --xml-version=2 > cppcheck-errorlist.xml
cppcheck ${CPPCHECK_LIBRARY_ARGS} --errorlist --xml-version=2 | python cppcheck_createrules.py rules cwec_v4.2.xml > cppcheck.xml
cppcheck ${CPPCHECK_LIBRARY_ARGS} --errorlist --xml-version=2 | python cppcheck_createrules.py rules cwec_v4.6.xml > cppcheck.xml
python utils_createrules.py comparerules $SCRIPT_DIR/../main/resources/cppcheck.xml cppcheck.xml > cppcheck-comparison.md

0 comments on commit acb419b

Please sign in to comment.