Skip to content

Commit acb419b

Browse files
authored
Merge pull request #2307 from guwirth/cppcheck-2.70
Cppcheck 2.70 support
2 parents e9a8171 + a01db27 commit acb419b

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

cxx-sensors/src/main/resources/cppcheck.xml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,11 +2115,11 @@ Memory allocation size is negative.Negative allocation size has no specified beh
21152115
</rule>
21162116
<rule>
21172117
<key>noConstructor</key>
2118-
<name>The class 'classname' does not have a constructor although it has private member variables</name>
2118+
<name>The class 'classname' does not declare a constructor although it has private member variables which likely require initialization</name>
21192119
<description>
21202120
<![CDATA[
21212121
<p>
2122-
The class 'classname' does not have a constructor although it has
2122+
The class 'classname' does not declare a constructor although it has
21232123
private member variables. Member variables of builtin types are left
21242124
uninitialized when the class is instantiated. That may cause bugs or
21252125
undefined behavior.
@@ -8129,12 +8129,12 @@ Same iterator is used with different containers 'container1' and
81298129
</rule>
81308130
<rule>
81318131
<key>iterators3</key>
8132-
<name>Same iterator is used with containers 'container' that are defined in different scopes</name>
8132+
<name>Same iterator is used with containers 'container' that are temporaries or defined in different scopes</name>
81338133
<description>
81348134
<![CDATA[
81358135
<p>
8136-
Same iterator is used with containers 'container' that are defined in
8137-
different scopes.
8136+
Same iterator is used with containers 'container' that are temporaries
8137+
or defined in different scopes.
81388138
</p>
81398139
<h2>References</h2>
81408140
<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>
@@ -8504,11 +8504,11 @@ Parameter 'x' can be declared with const
85048504
</rule>
85058505
<rule>
85068506
<key>danglingTemporaryLifetime</key>
8507-
<name>Using object to temporary</name>
8507+
<name>Using object that is a temporary</name>
85088508
<description>
85098509
<![CDATA[
85108510
<p>
8511-
Using object to temporary.
8511+
Using object that is a temporary.
85128512
</p>
85138513
<h2>References</h2>
85148514
<p><a href="https://cwe.mitre.org/data/definitions/562.html" target="_blank">CWE-562: Return of Stack Variable Address</a></p>
@@ -8981,6 +8981,24 @@ missing return statement
89818981
<remediationFunction>LINEAR</remediationFunction>
89828982
<remediationFunctionGapMultiplier>5min</remediationFunctionGapMultiplier>
89838983
</rule>
8984+
<!-- ########### New in Cppcheck 2.70 ########### -->
8985+
<rule>
8986+
<key>missingMemberCopy</key>
8987+
<name>Member variable 'classname::varnamepriv' is not assigned in the copy constructor</name>
8988+
<description><![CDATA[
8989+
<p>
8990+
Member variable 'classname::varnamepriv' is not assigned in the copy
8991+
constructor. Should it be copied?
8992+
</p>
8993+
<h2>References</h2>
8994+
<p><a href="https://cwe.mitre.org/data/definitions/398.html" target="_blank">CWE-398: 7PK - Code Quality</a></p>
8995+
]]></description>
8996+
<tag>cwe</tag>
8997+
<severity>MINOR</severity>
8998+
<type>BUG</type>
8999+
<remediationFunction>LINEAR</remediationFunction>
9000+
<remediationFunctionGapMultiplier>5min</remediationFunctionGapMultiplier>
9001+
</rule>
89849002
<!-- ########### Misra Rules ########### -->
89859003
<rule>
89869004
<key>misra-c2012-1.1</key>

cxx-sensors/src/test/java/org/sonar/cxx/sensors/cppcheck/CxxCppCheckRuleRepositoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void createRulesTest() {
3737
def.define(context);
3838

3939
RulesDefinition.Repository repo = context.repository(CxxCppCheckRuleRepository.KEY);
40-
assertEquals(665, repo.rules().size());
40+
assertEquals(666, repo.rules().size());
4141
}
4242

4343
}
27.5 KB
Binary file not shown.

cxx-sensors/src/tools/generate_cppcheck_resources.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ECHO create Cppcheck errorlist cppcheck-errorlist.xml...
1616
"%CPPCHECK_DIR%cppcheck.exe" %CPPCHECK_LIBRARY_ARGS% --errorlist --xml-version=2 > cppcheck-errorlist.xml
1717

1818
ECHO create SonarQube rules file cppcheck.xml...
19-
"%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
19+
"%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
2020

2121
ECHO create cppcheck-comparison.md...
2222
"%PYTHON_DIR%python.exe" utils_createrules.py comparerules "%SCRIPT_DIR%\..\main\resources\cppcheck.xml" .\cppcheck.xml > cppcheck-comparison.md

cxx-sensors/src/tools/generate_cppcheck_resources.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1818
wget https://cwe.mitre.org/data/xml/cwec_latest.xml.zip --output-document=cwec_latest.xml.zip && unzip -j -o cwec_latest.xml.zip
1919

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

0 commit comments

Comments
 (0)