Skip to content

Commit 30cec40

Browse files
authored
Merge pull request #2915 from guwirth/cppcheck-iterateByValue
Support Cppcheck rule iterateByValue
2 parents 066138e + 63c65f7 commit 30cec40

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,6 +2753,23 @@ const reference which is usually faster and recommended in C++.
27532753
</p>
27542754
<h2>References</h2>
27552755
<p><a href="https://cwe.mitre.org/data/definitions/398.html" target="_blank">CWE-398: 7PK - Code Quality</a></p>
2756+
]]>
2757+
</description>
2758+
<tag>cwe</tag>
2759+
<severity>MINOR</severity>
2760+
<type>BUG</type>
2761+
</rule>
2762+
<rule>
2763+
<key>iterateByValue</key>
2764+
<name>Range variable 'var' should be declared as const reference</name>
2765+
<description>
2766+
<![CDATA[
2767+
<p>
2768+
Variable 'var' is used to iterate by value. It could be declared as a
2769+
const reference which is usually faster and recommended in C++.
2770+
</p>
2771+
<h2>References</h2>
2772+
<p><a href="https://cwe.mitre.org/data/definitions/398.html" target="_blank">CWE-398: 7PK - Code Quality</a></p>
27562773
]]>
27572774
</description>
27582775
<tag>cwe</tag>

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 @@ void createRulesTest() {
3737
def.define(context);
3838

3939
RulesDefinition.Repository repo = context.repository(CxxCppCheckRuleRepository.KEY);
40-
assertThat(repo.rules()).hasSize(687);
40+
assertThat(repo.rules()).hasSize(688);
4141
}
4242

4343
}

0 commit comments

Comments
 (0)