Skip to content

Commit 589a8c3

Browse files
committed
Merge pull request #503 from Bertk/new-rules
add new CppCheck rules (V1.69 Dev)
2 parents d6825bb + ca417fc commit 589a8c3

File tree

2 files changed

+76
-3
lines changed

2 files changed

+76
-3
lines changed

sonar-cxx-plugin/src/main/resources/cppcheck.xml

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Follow these steps to make your custom Custom rules available in SonarQube:
1515
<li>Create a new rule in SonarQube by "copying" this rule template and specify the <code>CheckId</code> of your custom rule, a title, a description, and a default severity.</li>
1616
<li>Enable the newly created rule in your quality profile</li>
1717
</ol>
18-
<li>Relaunch an analysis on your projects, et voilà, your custom rules are executed!</li>
18+
<li>Relaunch an analysis on your projects, et voila, your custom rules are executed!</li>
1919
</ol>
2020
]]>
2121
</description>
@@ -1022,7 +1022,7 @@ Follow these steps to make your custom Custom rules available in SonarQube:
10221022
<rule>
10231023
<key>sizeofwithsilentarraypointer</key>
10241024
<configkey>sizeofwithsilentarraypointer</configkey>
1025-
<name>Using sizeof for array given as function argument returns the size of pointer</name>
1025+
<name>Using sizeof on array given as function argument returns the size of pointer</name>
10261026
<description>
10271027
Using &apos;sizeof&apos; for array given as function argument returns the size of pointer.
10281028
</description>
@@ -2858,6 +2858,79 @@ Follow these steps to make your custom Custom rules available in SonarQube:
28582858
&apos;arg1&apos; given to va_start() is not last named argument of the function. Did you intend to pass &apos;arg2&apos;?.
28592859
</description>
28602860
</rule>
2861+
<rule>
2862+
<key>unmatchedSuppression</key>
2863+
<configkey>unmatchedSuppression</configkey>
2864+
<name>Unmatched suppression: unusedFunction</name>
2865+
<description>
2866+
Unmatched suppression: unusedFunction.
2867+
</description>
2868+
</rule>
2869+
<!-- ########### New in cppcheck 1.69 Dev ########### -->
2870+
<rule>
2871+
<key>duplicateExpressionTernary</key>
2872+
<configkey>duplicateExpressionTernary</configkey>
2873+
<name>Same expression in both branches of ternary operator</name>
2874+
<description>
2875+
Same expression in both branches of ternary operator.
2876+
</description>
2877+
</rule>
2878+
<rule>
2879+
<key>noExplicitConstructor</key>
2880+
<configkey>noExplicitConstructor</configkey>
2881+
<name>Class has a constructor with 1 argument that is not explicit</name>
2882+
<description>
2883+
Class &apos;classname&apos; has a constructor with 1 argument that is not explicit.
2884+
</description>
2885+
</rule>
2886+
<rule>
2887+
<key>noExplicitCopyMoveConstructor</key>
2888+
<configkey>noExplicitCopyMoveConstructor</configkey>
2889+
<name>Abstract class has a copy/move constructor that is not explicit</name>
2890+
<description>
2891+
Abstract class &apos;classname&apos; has a copy/move constructor that is not explicit.
2892+
</description>
2893+
</rule>
2894+
<rule>
2895+
<key>operatorEqMissingReturnStatement</key>
2896+
<configkey>operatorEqMissingReturnStatement</configkey>
2897+
<name>Missing &apos;return&apos; statement in non-void function causes undefined behavior</name>
2898+
<description>
2899+
No &apos;return&apos; statement in non-void function causes undefined behavior.
2900+
</description>
2901+
</rule>
2902+
<rule>
2903+
<key>operatorEqShouldBeLeftUnimplemented</key>
2904+
<configkey>operatorEqShouldBeLeftUnimplemented</configkey>
2905+
<name>&apos;operator=&apos; should either return reference to &apos;this&apos;</name>
2906+
<description>
2907+
&apos;operator=&apos; should either return reference to &apos;this&apos; instance or be declared private and left unimplemented.
2908+
</description>
2909+
</rule>
2910+
<rule>
2911+
<key>redundantPointerOp</key>
2912+
<configkey>redundantPointerOp</configkey>
2913+
<name>Redundant pointer operation on varname</name>
2914+
<description>
2915+
Redundant pointer operation on varname - it&apos;s already a pointer.
2916+
</description>
2917+
</rule>
2918+
<rule>
2919+
<key>throwInNoexceptFunction</key>
2920+
<configkey>throwInNoexceptFunction</configkey>
2921+
<name>Exception thrown in function declared not to throw exceptions</name>
2922+
<description>
2923+
Exception thrown in function declared not to throw exceptions.
2924+
</description>
2925+
</rule>
2926+
<rule>
2927+
<key>useAutoPointerMalloc</key>
2928+
<configkey>useAutoPointerMalloc</configkey>
2929+
<name>Object pointed by an &apos;auto_ptr&apos; is destroyed using operator &apos;delete&apos;</name>
2930+
<description>
2931+
Object pointed by an &apos;auto_ptr&apos; is destroyed using operator &apos;delete&apos;. You should not use &apos;auto_ptr&apos; for pointers obtained with function &apos;malloc&apos;.
2932+
</description>
2933+
</rule>
28612934
</rules>
28622935

28632936

sonar-cxx-plugin/src/test/java/org/sonar/plugins/cxx/cppcheck/CxxCppCheckRuleRepositoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ public void createRulesTest() {
3939
def.define(context);
4040

4141
RulesDefinition.Repository repo = context.repository(CxxCppCheckRuleRepository.KEY);
42-
assertEquals(324, repo.rules().size());
42+
assertEquals(333, repo.rules().size());
4343
}
4444
}

0 commit comments

Comments
 (0)