3 Commits 78dc5380de ... 2cb69c8603

Tác giả SHA1 Thông báo Ngày
  prozessorkern 2cb69c8603 extended tests for cyclomatic_switch_case_once metric 8 tháng trước cách đây
  prozessorkern eda5d4ea8a extended basic tests for cyclomatic_switch_case_once metric 8 tháng trước cách đây
  prozessorkern 6c6cdb41b0 added cyclomatic_switch_case_once metric which counts switch case constructs only once 8 tháng trước cách đây
33 tập tin đã thay đổi với 757 bổ sung129 xóa
  1. 20 6
      metrixpp/ext/std/code/complexity.py
  2. 2 0
      metrixpp/tests/general/test_basic.py
  3. 4 0
      metrixpp/tests/general/test_basic/test_help_collect_default_stdout.gold.txt
  4. 19 19
      metrixpp/tests/general/test_basic/test_workflow_export_default_stdout.gold.txt
  5. 18 18
      metrixpp/tests/general/test_basic/test_workflow_export_second_stdout.gold.txt
  6. 1 0
      metrixpp/tests/general/test_basic/test_workflow_info_default_stdout.gold.txt
  7. 1 0
      metrixpp/tests/general/test_basic/test_workflow_info_second_stdout.gold.txt
  8. 7 0
      metrixpp/tests/general/test_basic/test_workflow_view_default_stdout.gold.txt
  9. 20 11
      metrixpp/tests/general/test_basic/test_workflow_view_second_per_file_stdout.gold.txt
  10. 19 0
      metrixpp/tests/general/test_basic/test_workflow_view_second_per_file_txt_all_stdout.gold.txt
  11. 18 0
      metrixpp/tests/general/test_basic/test_workflow_view_second_per_file_txt_new_stdout.gold.txt
  12. 18 0
      metrixpp/tests/general/test_basic/test_workflow_view_second_per_file_txt_touched_stdout.gold.txt
  13. 9 0
      metrixpp/tests/general/test_basic/test_workflow_view_second_stdout.gold.txt
  14. 12 0
      metrixpp/tests/general/test_basic/test_workflow_view_second_txt_all_stdout.gold.txt
  15. 12 0
      metrixpp/tests/general/test_basic/test_workflow_view_second_txt_new_stdout.gold.txt
  16. 12 0
      metrixpp/tests/general/test_basic/test_workflow_view_second_txt_touched_stdout.gold.txt
  17. 3 1
      metrixpp/tests/general/test_std_code_cpp.py
  18. 13 0
      metrixpp/tests/general/test_std_code_cpp/sources/test2.cpp
  19. 1 1
      metrixpp/tests/general/test_std_code_cpp/test_parser_limit_default_stdout.gold.txt
  20. 11 2
      metrixpp/tests/general/test_std_code_cpp/test_parser_view_default_stdout.gold.txt
  21. 150 11
      metrixpp/tests/general/test_std_code_cpp/test_parser_view_files_stdout.gold.txt
  22. 3 1
      metrixpp/tests/general/test_std_code_cs.py
  23. 14 0
      metrixpp/tests/general/test_std_code_cs/sources/Generics.cs
  24. 1 1
      metrixpp/tests/general/test_std_code_cs/test_parser_limit_default_stdout.gold.txt
  25. 14 3
      metrixpp/tests/general/test_std_code_cs/test_parser_view_default_stdout.gold.txt
  26. 112 37
      metrixpp/tests/general/test_std_code_cs/test_parser_view_files_stdout.gold.txt
  27. 3 1
      metrixpp/tests/general/test_std_code_cs_unit.py
  28. 5 0
      metrixpp/tests/general/test_std_code_cs_unit/test_parser_view_default_stdout.gold.txt
  29. 27 0
      metrixpp/tests/general/test_std_code_cs_unit/test_parser_view_files_stdout.gold.txt
  30. 3 1
      metrixpp/tests/general/test_std_code_java.py
  31. 14 2
      metrixpp/tests/general/test_std_code_java/sources/attrs.java
  32. 13 2
      metrixpp/tests/general/test_std_code_java/test_parser_view_default_stdout.gold.txt
  33. 178 12
      metrixpp/tests/general/test_std_code_java/test_parser_view_files_stdout.gold.txt

+ 20 - 6
metrixpp/ext/std/code/complexity.py

@@ -14,21 +14,25 @@ class Plugin(api.Plugin, api.MetricPluginMixin, api.Child, api.IConfigurable):
     def declare_configuration(self, parser):
         parser.add_option("--std.code.complexity.cyclomatic", "--sccc", action="store_true", default=False,
                          help="Enables collection of cyclomatic complexity metric (McCabe) [default: %default]")
+        parser.add_option("--std.code.complexity.cyclomatic_switch_case_once", "--scccnsc", action="store_true", default=False,
+                         help="Enables collection of cyclomatic complexity metric (McCabe) switch case is only counted once [default: %default]")
         parser.add_option("--std.code.complexity.maxindent", "--sccmi", action="store_true", default=False,
                          help="Enables collection of maximum indent level metric [default: %default]")
     
     def configure(self, options):
         self.is_active_cyclomatic = options.__dict__['std.code.complexity.cyclomatic']
+        self.is_active_cyclomatic_switch_case_once = options.__dict__['std.code.complexity.cyclomatic_switch_case_once']
         self.is_active_maxindent = options.__dict__['std.code.complexity.maxindent']
         
     # cyclomatic complexity pattern
     # - C/C++
-    pattern_cpp = re.compile(r'''([^0-9A-Za-z_]((if)|(case)|(for)|(while)|(catch))[^0-9A-Za-z_])|[&][&]|[|][|]|[?]''')
+    regex_cpp = r'''([^0-9A-Za-z_]((if)|(case)|(for)|(while)|(catch))[^0-9A-Za-z_])|[&][&]|[|][|]|[?]'''
     # - C#
     #   supports Null-coalescing '??' and conditional '?:'
-    pattern_cs = re.compile(r'''([^0-9A-Za-z_]((if)|(case)|(for)|(foreach)|(while)|(catch))[^0-9A-Za-z_])|[&][&]|[|][|]|[?][?]?''')
+    regex_cs = r'''([^0-9A-Za-z_]((if)|(case)|(for)|(foreach)|(while)|(catch))[^0-9A-Za-z_])|[&][&]|[|][|]|[?][?]?'''
     # - Java
-    pattern_java = re.compile(r'''([^0-9A-Za-z_]((if)|(case)|(for)|(while)|(catch))[^0-9A-Za-z_])|[&][&]|[|][|]|[?]''')
+    regex_java = r'''([^0-9A-Za-z_]((if)|(case)|(for)|(while)|(catch))[^0-9A-Za-z_])|[&][&]|[|][|]|[?]'''
+
 
     pattern_indent = re.compile(r'''[}{]''')
 
@@ -36,9 +40,19 @@ class Plugin(api.Plugin, api.MetricPluginMixin, api.Child, api.IConfigurable):
         self.declare_metric(self.is_active_cyclomatic,
                             self.Field('cyclomatic', int),
                             {
-                                'std.code.cpp': self.pattern_cpp,
-                                'std.code.cs': self.pattern_cs,
-                                'std.code.java': self.pattern_java
+                                'std.code.cpp': re.compile(self.regex_cpp),
+                                'std.code.cs': re.compile(self.regex_cs),
+                                'std.code.java': re.compile(self.regex_java)
+                            },
+                            marker_type_mask=api.Marker.T.CODE,
+                            region_type_mask=api.Region.T.FUNCTION)
+        # add the identical regex again but replace case with switch to count switch cases only once
+        self.declare_metric(self.is_active_cyclomatic_switch_case_once,
+                            self.Field('cyclomatic_switch_case_once', int),
+                            {
+                                'std.code.cpp': re.compile(self.regex_cpp.replace("(case)", "(switch)")),
+                                'std.code.cs': re.compile(self.regex_cs.replace("(case)", "(switch)")),
+                                'std.code.java': re.compile(self.regex_java.replace("(case)", "(switch)"))
                             },
                             marker_type_mask=api.Marker.T.CODE,
                             region_type_mask=api.Region.T.FUNCTION)

+ 2 - 0
metrixpp/tests/general/test_basic.py

@@ -16,6 +16,7 @@ class Test(tests.common.TestCase):
         # first collection
         runner = tests.common.ToolRunner('collect',
                                          ['--std.code.complexity.cyclomatic',
+                                          '--std.code.complexity.cyclomatic_switch_case_once',
                                           '--std.code.lines.total',
                                           '--std.code.lines.code',
                                           '--std.code.lines.preprocessor',
@@ -53,6 +54,7 @@ class Test(tests.common.TestCase):
         # second collection
         runner = tests.common.ToolRunner('collect',
                                          ['--std.code.complexity.cyclomatic',
+                                          '--std.code.complexity.cyclomatic_switch_case_once',
                                           '--std.code.lines.total',
                                           '--std.code.lines.code',
                                           '--std.code.lines.preprocessor',

+ 4 - 0
metrixpp/tests/general/test_basic/test_help_collect_default_stdout.gold.txt

@@ -21,6 +21,10 @@ Options:
   --std.code.complexity.cyclomatic, --sccc
                         Enables collection of cyclomatic complexity metric
                         (McCabe) [default: False]
+  --std.code.complexity.cyclomatic_switch_case_once, --scccnsc
+                        Enables collection of cyclomatic complexity metric
+                        (McCabe) switch case is only counted once [default:
+                        False]
   --std.code.complexity.maxindent, --sccmi
                         Enables collection of maximum indent level metric
                         [default: False]

+ 19 - 19
metrixpp/tests/general/test_basic/test_workflow_export_default_stdout.gold.txt

@@ -1,19 +1,19 @@
-file,region,type,modified,line start,line end,std.code.complexity:cyclomatic,std.code.lines:code,std.code.lines:comments,std.code.lines:preprocessor,std.code.lines:total,std.code.ratio:comments,std.suppress:count,std.suppress:list,std.suppress.file:count,std.suppress.file:list
-./file_deleted_in_new_sources.cpp,__global__,global,,1,34,,0,0,0,0,0.0,,,,
-./file_deleted_in_new_sources.cpp,hmm,namespace,,3,24,,4,3,0,7,0.428,,,,
-./file_deleted_in_new_sources.cpp,B,class,,9,22,,3,0,0,3,0.0,,,,
-./file_deleted_in_new_sources.cpp,B,function,,12,20,1,8,2,0,9,0.2,,,,
-./file_deleted_in_new_sources.cpp,never_old,function,,26,33,1,7,0,0,7,0.0,,,,
-./file_deleted_in_new_sources.cpp,,file,,1,34,,,,,,,,,,
-./simple.cpp,__global__,global,,1,90,,0,0,0,0,0.0,,,,
-./simple.cpp,hmm,namespace,,3,89,,4,1,1,6,0.2,,,,
-./simple.cpp,A,class,,9,87,,20,0,0,20,0.0,,,,
-./simple.cpp,A,function,,12,23,3,11,2,0,12,0.153,,,,
-./simple.cpp,func,function,,26,40,1,5,0,0,5,0.0,,,,
-./simple.cpp,embeded,class,,28,38,,3,0,0,3,0.0,,,,
-./simple.cpp,embeded,function,,30,37,1,7,1,0,8,0.125,,,,
-./simple.cpp,func_to_be_removed_in_new_sources,function,,42,56,2,5,0,0,5,0.0,,,,
-./simple.cpp,embeded,class,,44,54,,3,0,0,3,0.0,,,,
-./simple.cpp,embeded,function,,46,53,1,7,1,0,8,0.125,,,,
-./simple.cpp,never,function,,58,65,1,7,0,0,7,0.0,,,,
-./simple.cpp,,file,,1,90,,,,,,,,,,
+file,region,type,modified,line start,line end,std.code.complexity:cyclomatic,std.code.complexity:cyclomatic_switch_case_once,std.code.lines:code,std.code.lines:comments,std.code.lines:preprocessor,std.code.lines:total,std.code.ratio:comments,std.suppress:count,std.suppress:list,std.suppress.file:count,std.suppress.file:list
+./file_deleted_in_new_sources.cpp,__global__,global,,1,34,,,0,0,0,0,0.0,,,,
+./file_deleted_in_new_sources.cpp,hmm,namespace,,3,24,,,4,3,0,7,0.428,,,,
+./file_deleted_in_new_sources.cpp,B,class,,9,22,,,3,0,0,3,0.0,,,,
+./file_deleted_in_new_sources.cpp,B,function,,12,20,1,1,8,2,0,9,0.2,,,,
+./file_deleted_in_new_sources.cpp,never_old,function,,26,33,1,1,7,0,0,7,0.0,,,,
+./file_deleted_in_new_sources.cpp,,file,,1,34,,,,,,,,,,,
+./simple.cpp,__global__,global,,1,90,,,0,0,0,0,0.0,,,,
+./simple.cpp,hmm,namespace,,3,89,,,4,1,1,6,0.2,,,,
+./simple.cpp,A,class,,9,87,,,20,0,0,20,0.0,,,,
+./simple.cpp,A,function,,12,23,3,3,11,2,0,12,0.153,,,,
+./simple.cpp,func,function,,26,40,1,1,5,0,0,5,0.0,,,,
+./simple.cpp,embeded,class,,28,38,,,3,0,0,3,0.0,,,,
+./simple.cpp,embeded,function,,30,37,1,1,7,1,0,8,0.125,,,,
+./simple.cpp,func_to_be_removed_in_new_sources,function,,42,56,2,2,5,0,0,5,0.0,,,,
+./simple.cpp,embeded,class,,44,54,,,3,0,0,3,0.0,,,,
+./simple.cpp,embeded,function,,46,53,1,1,7,1,0,8,0.125,,,,
+./simple.cpp,never,function,,58,65,1,1,7,0,0,7,0.0,,,,
+./simple.cpp,,file,,1,90,,,,,,,,,,,

+ 18 - 18
metrixpp/tests/general/test_basic/test_workflow_export_second_stdout.gold.txt

@@ -1,18 +1,18 @@
-file,region,type,modified,line start,line end,std.code.complexity:cyclomatic,std.code.lines:code,std.code.lines:comments,std.code.lines:preprocessor,std.code.lines:total,std.code.ratio:comments,std.suppress:count,std.suppress:list,std.suppress.file:count,std.suppress.file:list
-./simple.cpp,__global__,global,False,1,78,,0,0,0,0,0.0,,,,
-./simple.cpp,hmm,namespace,True,3,77,,4,1,2,7,0.2,,,,
-./simple.cpp,A,class,True,10,75,,4,0,0,4,0.0,,,,
-./simple.cpp,A,function,False,13,24,3,11,2,0,12,0.153,,,,
-./simple.cpp,func,function,False,26,42,1,5,0,0,5,0.0,,,,
-./simple.cpp,embeded,class,False,28,40,,3,0,0,3,0.0,,,,
-./simple.cpp,embeded,function,True,30,39,2,8,2,0,9,0.2,,,,
-./simple.cpp,never,function,True,44,51,1,7,1,0,7,0.125,,,,
-./simple.cpp,new_func,function,,53,56,0,3,1,0,4,0.25,,,,
-./simple.cpp,new_func_complex,function,,58,62,1,5,0,0,5,0.0,,,,
-./simple.cpp,new_func_complex_but_suppressed,function,,64,72,2,8,1,0,9,0.111,1,[std.code.complexity:cyclomatic],,
-./simple.cpp,,file,True,1,78,,,,,,,,,,
-./simple2.cpp,__global__,global,,1,26,,0,0,0,0,0.0,,,,
-./simple2.cpp,hmm,namespace,,3,25,,4,1,0,5,0.2,,,,
-./simple2.cpp,New_A,class,,7,23,,3,0,0,3,0.0,,,,
-./simple2.cpp,New_A,function,,10,21,3,10,2,0,12,0.166,,,,
-./simple2.cpp,,file,,1,26,,,,,,,,,,
+file,region,type,modified,line start,line end,std.code.complexity:cyclomatic,std.code.complexity:cyclomatic_switch_case_once,std.code.lines:code,std.code.lines:comments,std.code.lines:preprocessor,std.code.lines:total,std.code.ratio:comments,std.suppress:count,std.suppress:list,std.suppress.file:count,std.suppress.file:list
+./simple.cpp,__global__,global,False,1,78,,,0,0,0,0,0.0,,,,
+./simple.cpp,hmm,namespace,True,3,77,,,4,1,2,7,0.2,,,,
+./simple.cpp,A,class,True,10,75,,,4,0,0,4,0.0,,,,
+./simple.cpp,A,function,False,13,24,3,3,11,2,0,12,0.153,,,,
+./simple.cpp,func,function,False,26,42,1,1,5,0,0,5,0.0,,,,
+./simple.cpp,embeded,class,False,28,40,,,3,0,0,3,0.0,,,,
+./simple.cpp,embeded,function,True,30,39,2,2,8,2,0,9,0.2,,,,
+./simple.cpp,never,function,True,44,51,1,1,7,1,0,7,0.125,,,,
+./simple.cpp,new_func,function,,53,56,0,0,3,1,0,4,0.25,,,,
+./simple.cpp,new_func_complex,function,,58,62,1,1,5,0,0,5,0.0,,,,
+./simple.cpp,new_func_complex_but_suppressed,function,,64,72,2,2,8,1,0,9,0.111,1,[std.code.complexity:cyclomatic],,
+./simple.cpp,,file,True,1,78,,,,,,,,,,,
+./simple2.cpp,__global__,global,,1,26,,,0,0,0,0,0.0,,,,
+./simple2.cpp,hmm,namespace,,3,25,,,4,1,0,5,0.2,,,,
+./simple2.cpp,New_A,class,,7,23,,,3,0,0,3,0.0,,,,
+./simple2.cpp,New_A,function,,10,21,3,3,10,2,0,12,0.166,,,,
+./simple2.cpp,,file,,1,26,,,,,,,,,,,

+ 1 - 0
metrixpp/tests/general/test_basic/test_workflow_info_default_stdout.gold.txt

@@ -17,6 +17,7 @@ test_workflow.db:: info: Created using plugins and settings:
 
 test_workflow.db:: info: Collected metrics:
 	std.code.complexity:cyclomatic: 
+	std.code.complexity:cyclomatic_switch_case_once: 
 	std.code.lines:code: 
 	std.code.lines:comments: 
 	std.code.lines:preprocessor: 

+ 1 - 0
metrixpp/tests/general/test_basic/test_workflow_info_second_stdout.gold.txt

@@ -17,6 +17,7 @@ test_workflow.db:: info: Created using plugins and settings:
 
 test_workflow.db:: info: Collected metrics:
 	std.code.complexity:cyclomatic: 
+	std.code.complexity:cyclomatic_switch_case_once: 
 	std.code.lines:code: 
 	std.code.lines:comments: 
 	std.code.lines:preprocessor: 

+ 7 - 0
metrixpp/tests/general/test_basic/test_workflow_view_default_stdout.gold.txt

@@ -10,6 +10,13 @@
                         <distribution-bar count="1" metric="3" ratio="0.125" />
                     </distribution-bars>
                 </cyclomatic>
+                <cyclomatic_switch_case_once avg="1.375" count="8" max="3" min="1" nonzero="False" sup="0" total="11.0">
+                    <distribution-bars>
+                        <distribution-bar count="6" metric="1" ratio="0.75" />
+                        <distribution-bar count="1" metric="2" ratio="0.125" />
+                        <distribution-bar count="1" metric="3" ratio="0.125" />
+                    </distribution-bars>
+                </cyclomatic_switch_case_once>
             </std.code.complexity>
             <std.code.lines>
                 <code avg="5.875" count="16" max="20" min="0" nonzero="False" sup="0" total="94.0">

+ 20 - 11
metrixpp/tests/general/test_basic/test_workflow_view_second_per_file_stdout.gold.txt

@@ -12,6 +12,15 @@
                         <distribution-bar __diff__="0" count="1" metric="3" ratio="0.14285714" />
                     </distribution-bars>
                 </cyclomatic>
+                <cyclomatic_switch_case_once avg="1.42857143" count="7" max="3" min="0" nonzero="False" sup="0" total="10.0">
+                    <__diff__ avg="-0.07142857" count="1" max="0" min="-1" nonzero="0" sup="0" total="1.0" />
+                    <distribution-bars>
+                        <distribution-bar __diff__="1" count="1" metric="0" ratio="0.14285714" />
+                        <distribution-bar __diff__="-1" count="3" metric="1" ratio="0.42857143" />
+                        <distribution-bar __diff__="1" count="2" metric="2" ratio="0.28571429" />
+                        <distribution-bar __diff__="0" count="1" metric="3" ratio="0.14285714" />
+                    </distribution-bars>
+                </cyclomatic_switch_case_once>
             </std.code.complexity>
             <std.code.lines>
                 <code avg="5.27272727" count="11" max="11" min="0" nonzero="False" sup="0" total="58.0">
@@ -123,8 +132,8 @@
                 </region>
                 <region>
                     <data>
-                        <std.code.complexity cyclomatic="3">
-                            <__diff__ cyclomatic="0" />
+                        <std.code.complexity cyclomatic="3" cyclomatic_switch_case_once="3">
+                            <__diff__ cyclomatic="0" cyclomatic_switch_case_once="0" />
                         </std.code.complexity>
                         <std.code.lines code="11" comments="2" preprocessor="0" total="12">
                             <__diff__ code="0" comments="0" preprocessor="0" total="0" />
@@ -137,8 +146,8 @@
                 </region>
                 <region>
                     <data>
-                        <std.code.complexity cyclomatic="1">
-                            <__diff__ cyclomatic="0" />
+                        <std.code.complexity cyclomatic="1" cyclomatic_switch_case_once="1">
+                            <__diff__ cyclomatic="0" cyclomatic_switch_case_once="0" />
                         </std.code.complexity>
                         <std.code.lines code="5" comments="0" preprocessor="0" total="5">
                             <__diff__ code="0" comments="0" preprocessor="0" total="0" />
@@ -162,8 +171,8 @@
                 </region>
                 <region>
                     <data>
-                        <std.code.complexity cyclomatic="2">
-                            <__diff__ cyclomatic="1" />
+                        <std.code.complexity cyclomatic="2" cyclomatic_switch_case_once="2">
+                            <__diff__ cyclomatic="1" cyclomatic_switch_case_once="1" />
                         </std.code.complexity>
                         <std.code.lines code="8" comments="2" preprocessor="0" total="9">
                             <__diff__ code="1" comments="1" preprocessor="0" total="1" />
@@ -176,8 +185,8 @@
                 </region>
                 <region>
                     <data>
-                        <std.code.complexity cyclomatic="1">
-                            <__diff__ cyclomatic="0" />
+                        <std.code.complexity cyclomatic="1" cyclomatic_switch_case_once="1">
+                            <__diff__ cyclomatic="0" cyclomatic_switch_case_once="0" />
                         </std.code.complexity>
                         <std.code.lines code="7" comments="1" preprocessor="0" total="7">
                             <__diff__ code="0" comments="1" preprocessor="0" total="0" />
@@ -190,7 +199,7 @@
                 </region>
                 <region>
                     <data>
-                        <std.code.complexity cyclomatic="0" />
+                        <std.code.complexity cyclomatic="0" cyclomatic_switch_case_once="0" />
                         <std.code.lines code="3" comments="1" preprocessor="0" total="4" />
                         <std.code.ratio comments="0.25" />
                     </data>
@@ -198,7 +207,7 @@
                 </region>
                 <region>
                     <data>
-                        <std.code.complexity cyclomatic="1" />
+                        <std.code.complexity cyclomatic="1" cyclomatic_switch_case_once="1" />
                         <std.code.lines code="5" comments="0" preprocessor="0" total="5" />
                         <std.code.ratio comments="0.0" />
                     </data>
@@ -206,7 +215,7 @@
                 </region>
                 <region>
                     <data>
-                        <std.code.complexity cyclomatic="2" />
+                        <std.code.complexity cyclomatic="2" cyclomatic_switch_case_once="2" />
                         <std.code.lines code="8" comments="1" preprocessor="0" total="9" />
                         <std.code.ratio comments="0.111" />
                         <std.suppress count="1" list="[std.code.complexity:cyclomatic]" />

+ 19 - 0
metrixpp/tests/general/test_basic/test_workflow_view_second_per_file_txt_all_stdout.gold.txt

@@ -41,6 +41,7 @@
 	Line numbers   : 13-24
 	Modified       : False
 	std.code.complexity:cyclomatic: 3 [+0]
+	std.code.complexity:cyclomatic_switch_case_once: 3 [+0]
 	std.code.lines:code: 11 [+0]
 	std.code.lines:comments: 2 [+0]
 	std.code.lines:preprocessor: 0 [+0]
@@ -54,6 +55,7 @@
 	Line numbers   : 26-42
 	Modified       : False
 	std.code.complexity:cyclomatic: 1 [+0]
+	std.code.complexity:cyclomatic_switch_case_once: 1 [+0]
 	std.code.lines:code: 5 [+0]
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
@@ -79,6 +81,7 @@
 	Line numbers   : 30-39
 	Modified       : True
 	std.code.complexity:cyclomatic: 2 [+1]
+	std.code.complexity:cyclomatic_switch_case_once: 2 [+1]
 	std.code.lines:code: 8 [+1]
 	std.code.lines:comments: 2 [+1]
 	std.code.lines:preprocessor: 0 [+0]
@@ -92,6 +95,7 @@
 	Line numbers   : 44-51
 	Modified       : True
 	std.code.complexity:cyclomatic: 1 [+0]
+	std.code.complexity:cyclomatic_switch_case_once: 1 [+0]
 	std.code.lines:code: 7 [+0]
 	std.code.lines:comments: 1 [+1]
 	std.code.lines:preprocessor: 0 [+0]
@@ -105,6 +109,7 @@
 	Line numbers   : 53-56
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 	std.code.lines:code: 3
 	std.code.lines:comments: 1
 	std.code.lines:preprocessor: 0
@@ -118,6 +123,7 @@
 	Line numbers   : 58-62
 	Modified       : None
 	std.code.complexity:cyclomatic: 1
+	std.code.complexity:cyclomatic_switch_case_once: 1
 	std.code.lines:code: 5
 	std.code.lines:comments: 0
 	std.code.lines:preprocessor: 0
@@ -131,6 +137,7 @@
 	Line numbers   : 64-72
 	Modified       : None
 	std.code.complexity:cyclomatic: 2
+	std.code.complexity:cyclomatic_switch_case_once: 2
 	std.code.lines:code: 8
 	std.code.lines:comments: 1
 	std.code.lines:preprocessor: 0
@@ -151,6 +158,18 @@
 	             2 : 0.286 : 0.857 : 2 [+1]	||||||||||||||||||||||||||||
 	             3 : 0.143 : 1.000 : 1 [+0]	||||||||||||||
 
+./simple.cpp:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 1.42857143 [-0.07142857]
+	Minimum        : 0 [-1]
+	Maximum        : 3 [+0]
+	Total          : 10.0 [+1.0]
+	Distribution   : 7 [+1] regions in total (including 0 [+0] suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 0.143 : 0.143 : 1 [+1]	||||||||||||||
+	             1 : 0.429 : 0.571 : 3 [-1]	||||||||||||||||||||||||||||||||||||||||||
+	             2 : 0.286 : 0.857 : 2 [+1]	||||||||||||||||||||||||||||
+	             3 : 0.143 : 1.000 : 1 [+0]	||||||||||||||
+
 ./simple.cpp:: info: Overall metrics for 'std.code.lines:code' metric
 	Average        : 5.27272727 [-1.27272727]
 	Minimum        : 0 [+0]

+ 18 - 0
metrixpp/tests/general/test_basic/test_workflow_view_second_per_file_txt_new_stdout.gold.txt

@@ -41,6 +41,7 @@
 	Line numbers   : 13-24
 	Modified       : False
 	std.code.complexity:cyclomatic: 3 [+0]
+	std.code.complexity:cyclomatic_switch_case_once: 3 [+0]
 	std.code.lines:code: 11 [+0]
 	std.code.lines:comments: 2 [+0]
 	std.code.lines:preprocessor: 0 [+0]
@@ -54,6 +55,7 @@
 	Line numbers   : 26-42
 	Modified       : False
 	std.code.complexity:cyclomatic: 1 [+0]
+	std.code.complexity:cyclomatic_switch_case_once: 1 [+0]
 	std.code.lines:code: 5 [+0]
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
@@ -79,6 +81,7 @@
 	Line numbers   : 30-39
 	Modified       : True
 	std.code.complexity:cyclomatic: 2 [+1]
+	std.code.complexity:cyclomatic_switch_case_once: 2 [+1]
 	std.code.lines:code: 8 [+1]
 	std.code.lines:comments: 2 [+1]
 	std.code.lines:preprocessor: 0 [+0]
@@ -92,6 +95,7 @@
 	Line numbers   : 44-51
 	Modified       : True
 	std.code.complexity:cyclomatic: 1 [+0]
+	std.code.complexity:cyclomatic_switch_case_once: 1 [+0]
 	std.code.lines:code: 7 [+0]
 	std.code.lines:comments: 1 [+1]
 	std.code.lines:preprocessor: 0 [+0]
@@ -105,6 +109,7 @@
 	Line numbers   : 53-56
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 	std.code.lines:code: 3
 	std.code.lines:comments: 1
 	std.code.lines:preprocessor: 0
@@ -118,6 +123,7 @@
 	Line numbers   : 58-62
 	Modified       : None
 	std.code.complexity:cyclomatic: 1
+	std.code.complexity:cyclomatic_switch_case_once: 1
 	std.code.lines:code: 5
 	std.code.lines:comments: 0
 	std.code.lines:preprocessor: 0
@@ -131,6 +137,7 @@
 	Line numbers   : 64-72
 	Modified       : None
 	std.code.complexity:cyclomatic: 2
+	std.code.complexity:cyclomatic_switch_case_once: 2
 	std.code.lines:code: 8
 	std.code.lines:comments: 1
 	std.code.lines:preprocessor: 0
@@ -150,6 +157,17 @@
 	             1 : 0.333 : 0.667 : 1 [+1]	|||||||||||||||||||||||||||||||||
 	             2 : 0.333 : 1.000 : 1 [+1]	|||||||||||||||||||||||||||||||||
 
+./simple.cpp:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 1.0 [+1.0]
+	Minimum        : 0 [+0]
+	Maximum        : 2 [+2]
+	Total          : 3.0 [+3.0]
+	Distribution   : 3 [+3] regions in total (including 0 [+0] suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 0.333 : 0.333 : 1 [+1]	|||||||||||||||||||||||||||||||||
+	             1 : 0.333 : 0.667 : 1 [+1]	|||||||||||||||||||||||||||||||||
+	             2 : 0.333 : 1.000 : 1 [+1]	|||||||||||||||||||||||||||||||||
+
 ./simple.cpp:: info: Overall metrics for 'std.code.lines:code' metric
 	Average        : 5.33333333 [+5.33333333]
 	Minimum        : 3 [+3]

+ 18 - 0
metrixpp/tests/general/test_basic/test_workflow_view_second_per_file_txt_touched_stdout.gold.txt

@@ -41,6 +41,7 @@
 	Line numbers   : 13-24
 	Modified       : False
 	std.code.complexity:cyclomatic: 3 [+0]
+	std.code.complexity:cyclomatic_switch_case_once: 3 [+0]
 	std.code.lines:code: 11 [+0]
 	std.code.lines:comments: 2 [+0]
 	std.code.lines:preprocessor: 0 [+0]
@@ -54,6 +55,7 @@
 	Line numbers   : 26-42
 	Modified       : False
 	std.code.complexity:cyclomatic: 1 [+0]
+	std.code.complexity:cyclomatic_switch_case_once: 1 [+0]
 	std.code.lines:code: 5 [+0]
 	std.code.lines:comments: 0 [+0]
 	std.code.lines:preprocessor: 0 [+0]
@@ -79,6 +81,7 @@
 	Line numbers   : 30-39
 	Modified       : True
 	std.code.complexity:cyclomatic: 2 [+1]
+	std.code.complexity:cyclomatic_switch_case_once: 2 [+1]
 	std.code.lines:code: 8 [+1]
 	std.code.lines:comments: 2 [+1]
 	std.code.lines:preprocessor: 0 [+0]
@@ -92,6 +95,7 @@
 	Line numbers   : 44-51
 	Modified       : True
 	std.code.complexity:cyclomatic: 1 [+0]
+	std.code.complexity:cyclomatic_switch_case_once: 1 [+0]
 	std.code.lines:code: 7 [+0]
 	std.code.lines:comments: 1 [+1]
 	std.code.lines:preprocessor: 0 [+0]
@@ -105,6 +109,7 @@
 	Line numbers   : 53-56
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 	std.code.lines:code: 3
 	std.code.lines:comments: 1
 	std.code.lines:preprocessor: 0
@@ -118,6 +123,7 @@
 	Line numbers   : 58-62
 	Modified       : None
 	std.code.complexity:cyclomatic: 1
+	std.code.complexity:cyclomatic_switch_case_once: 1
 	std.code.lines:code: 5
 	std.code.lines:comments: 0
 	std.code.lines:preprocessor: 0
@@ -131,6 +137,7 @@
 	Line numbers   : 64-72
 	Modified       : None
 	std.code.complexity:cyclomatic: 2
+	std.code.complexity:cyclomatic_switch_case_once: 2
 	std.code.lines:code: 8
 	std.code.lines:comments: 1
 	std.code.lines:preprocessor: 0
@@ -150,6 +157,17 @@
 	             1 : 0.400 : 0.600 : 2 [-1]	||||||||||||||||||||||||||||||||||||||||
 	             2 : 0.400 : 1.000 : 2 [+1]	||||||||||||||||||||||||||||||||||||||||
 
+./simple.cpp:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 1.2 [-0.05]
+	Minimum        : 0 [-1]
+	Maximum        : 2 [+0]
+	Total          : 6.0 [+1.0]
+	Distribution   : 5 [+1] regions in total (including 0 [+0] suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 0.200 : 0.200 : 1 [+1]	||||||||||||||||||||
+	             1 : 0.400 : 0.600 : 2 [-1]	||||||||||||||||||||||||||||||||||||||||
+	             2 : 0.400 : 1.000 : 2 [+1]	||||||||||||||||||||||||||||||||||||||||
+
 ./simple.cpp:: info: Overall metrics for 'std.code.lines:code' metric
 	Average        : 5.57142857 [-2.0]
 	Minimum        : 3 [+0]

+ 9 - 0
metrixpp/tests/general/test_basic/test_workflow_view_second_stdout.gold.txt

@@ -12,6 +12,15 @@
                         <distribution-bar __diff__="1" count="2" metric="3" ratio="0.25" />
                     </distribution-bars>
                 </cyclomatic>
+                <cyclomatic_switch_case_once avg="1.625" count="8" max="3" min="0" nonzero="False" sup="0" total="13.0">
+                    <__diff__ avg="0.25" count="0" max="0" min="-1" nonzero="0" sup="0" total="2.0" />
+                    <distribution-bars>
+                        <distribution-bar __diff__="1" count="1" metric="0" ratio="0.125" />
+                        <distribution-bar __diff__="-3" count="3" metric="1" ratio="0.375" />
+                        <distribution-bar __diff__="1" count="2" metric="2" ratio="0.25" />
+                        <distribution-bar __diff__="1" count="2" metric="3" ratio="0.25" />
+                    </distribution-bars>
+                </cyclomatic_switch_case_once>
             </std.code.complexity>
             <std.code.lines>
                 <code avg="5.0" count="15" max="11" min="0" nonzero="False" sup="0" total="75.0">

+ 12 - 0
metrixpp/tests/general/test_basic/test_workflow_view_second_txt_all_stdout.gold.txt

@@ -10,6 +10,18 @@
 	             2 : 0.250 : 0.750 : 2 [+1]	|||||||||||||||||||||||||
 	             3 : 0.250 : 1.000 : 2 [+1]	|||||||||||||||||||||||||
 
+./:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 1.625 [+0.25]
+	Minimum        : 0 [-1]
+	Maximum        : 3 [+0]
+	Total          : 13.0 [+2.0]
+	Distribution   : 8 [+0] regions in total (including 0 [+0] suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 0.125 : 0.125 : 1 [+1]	||||||||||||
+	             1 : 0.375 : 0.500 : 3 [-3]	|||||||||||||||||||||||||||||||||||||
+	             2 : 0.250 : 0.750 : 2 [+1]	|||||||||||||||||||||||||
+	             3 : 0.250 : 1.000 : 2 [+1]	|||||||||||||||||||||||||
+
 ./:: info: Overall metrics for 'std.code.lines:code' metric
 	Average        : 5.0 [-0.875]
 	Minimum        : 0 [+0]

+ 12 - 0
metrixpp/tests/general/test_basic/test_workflow_view_second_txt_new_stdout.gold.txt

@@ -10,6 +10,18 @@
 	             2 : 0.250 : 0.750 : 1 [+1]	|||||||||||||||||||||||||
 	             3 : 0.250 : 1.000 : 1 [+1]	|||||||||||||||||||||||||
 
+./:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 1.5 [+1.5]
+	Minimum        : 0 [+0]
+	Maximum        : 3 [+3]
+	Total          : 6.0 [+6.0]
+	Distribution   : 4 [+4] regions in total (including 0 [+0] suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 0.250 : 0.250 : 1 [+1]	|||||||||||||||||||||||||
+	             1 : 0.250 : 0.500 : 1 [+1]	|||||||||||||||||||||||||
+	             2 : 0.250 : 0.750 : 1 [+1]	|||||||||||||||||||||||||
+	             3 : 0.250 : 1.000 : 1 [+1]	|||||||||||||||||||||||||
+
 ./:: info: Overall metrics for 'std.code.lines:code' metric
 	Average        : 4.71428571 [+4.71428571]
 	Minimum        : 0 [+0]

+ 12 - 0
metrixpp/tests/general/test_basic/test_workflow_view_second_txt_touched_stdout.gold.txt

@@ -10,6 +10,18 @@
 	             2 : 0.333 : 0.833 : 2 [+1]	|||||||||||||||||||||||||||||||||
 	             3 : 0.167 : 1.000 : 1 [+1]	||||||||||||||||
 
+./:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 1.5 [+0.33333333]
+	Minimum        : 0 [-1]
+	Maximum        : 3 [+1]
+	Total          : 9.0 [+2.0]
+	Distribution   : 6 [+0] regions in total (including 0 [+0] suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 0.167 : 0.167 : 1 [+1]	||||||||||||||||
+	             1 : 0.333 : 0.500 : 2 [-3]	|||||||||||||||||||||||||||||||||
+	             2 : 0.333 : 0.833 : 2 [+1]	|||||||||||||||||||||||||||||||||
+	             3 : 0.167 : 1.000 : 1 [+1]	||||||||||||||||
+
 ./:: info: Overall metrics for 'std.code.lines:code' metric
 	Average        : 5.09090909 [-1.15909091]
 	Minimum        : 0 [+0]

+ 3 - 1
metrixpp/tests/general/test_std_code_cpp.py

@@ -14,7 +14,9 @@ class Test(tests.common.TestCase):
 
     def test_parser(self):
         
-        runner = tests.common.ToolRunner('collect', ['--std.code.complexity.cyclomatic'])
+        runner = tests.common.ToolRunner('collect',
+                                         ['--std.code.complexity.cyclomatic',
+                                          '--std.code.complexity.cyclomatic_switch_case_once'])
         self.assertExec(runner.run())
 
         runner = tests.common.ToolRunner('view', opts_list=['--format=xml'])

+ 13 - 0
metrixpp/tests/general/test_std_code_cpp/sources/test2.cpp

@@ -35,6 +35,19 @@ int main(int a, string b)
 	{
 
 	}
+	switch(a)
+	{
+	case 1:
+		break;
+	case 2:
+		break;
+	case 3:
+		break;
+	case 4:
+		break;
+	default:
+		break;
+	}
 }
 }
 

+ 1 - 1
metrixpp/tests/general/test_std_code_cpp/test_parser_limit_default_stdout.gold.txt

@@ -73,7 +73,7 @@
 ./test2.cpp:23: warning: Metric 'std.code.complexity:cyclomatic' for region 'main' exceeds the limit.
 	Metric name    : std.code.complexity:cyclomatic
 	Region name    : main
-	Metric value   : 2
+	Metric value   : 6
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0

+ 11 - 2
metrixpp/tests/general/test_std_code_cpp/test_parser_view_default_stdout.gold.txt

@@ -3,13 +3,22 @@
     <data>
         <aggregated-data>
             <std.code.complexity>
-                <cyclomatic avg="0.19767442" count="86" max="2" min="0" nonzero="False" sup="0" total="17.0">
+                <cyclomatic avg="0.24418605" count="86" max="6" min="0" nonzero="False" sup="0" total="21.0">
                     <distribution-bars>
                         <distribution-bar count="74" metric="0" ratio="0.86046512" />
                         <distribution-bar count="7" metric="1" ratio="0.08139535" />
-                        <distribution-bar count="5" metric="2" ratio="0.05813953" />
+                        <distribution-bar count="4" metric="2" ratio="0.04651163" />
+                        <distribution-bar count="1" metric="6" ratio="0.01162791" />
                     </distribution-bars>
                 </cyclomatic>
+                <cyclomatic_switch_case_once avg="0.20930233" count="86" max="3" min="0" nonzero="False" sup="0" total="18.0">
+                    <distribution-bars>
+                        <distribution-bar count="74" metric="0" ratio="0.86046512" />
+                        <distribution-bar count="7" metric="1" ratio="0.08139535" />
+                        <distribution-bar count="4" metric="2" ratio="0.04651163" />
+                        <distribution-bar count="1" metric="3" ratio="0.01162791" />
+                    </distribution-bars>
+                </cyclomatic_switch_case_once>
             </std.code.complexity>
         </aggregated-data>
         <file-data />

+ 150 - 11
metrixpp/tests/general/test_std_code_cpp/test_parser_view_files_stdout.gold.txt

@@ -26,6 +26,7 @@
 	Line numbers   : 5-8
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./function_ends_on_class.cpp:9: info: Metrics per 'function_end_on_struct' region
 	Region name    : function_end_on_struct
@@ -34,6 +35,7 @@
 	Line numbers   : 9-12
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./function_ends_on_class.cpp:13: info: Metrics per 'function_end_on_namespace' region
 	Region name    : function_end_on_namespace
@@ -42,6 +44,7 @@
 	Line numbers   : 13-16
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./function_ends_on_class.cpp:: info: Overall metrics for 'std.code.complexity:cyclomatic' metric
 	Average        : 0.0
@@ -52,6 +55,15 @@
 	  Metric value : Ratio : R-sum : Number of regions
 	             0 : 1.000 : 1.000 : 3	||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 
+./function_ends_on_class.cpp:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 0.0
+	Minimum        : 0
+	Maximum        : 0
+	Total          : 0.0
+	Distribution   : 3 regions in total (including 0 suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 1.000 : 1.000 : 3	||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+
 ./operator_test.hpp:0: info: Metrics per '__global__' region
 	Region name    : __global__
 	Region type    : global
@@ -73,6 +85,7 @@
 	Line numbers   : 3-29
 	Modified       : None
 	std.code.complexity:cyclomatic: 2
+	std.code.complexity:cyclomatic_switch_case_once: 2
 
 ./operator_test.hpp:31: info: Metrics per 'function_after' region
 	Region name    : function_after
@@ -81,6 +94,7 @@
 	Line numbers   : 31-31
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:35: info: Metrics per 'ALL_operators' region
 	Region name    : ALL_operators
@@ -96,6 +110,7 @@
 	Line numbers   : 36-36
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:37: info: Metrics per 'operator new' region
 	Region name    : operator new
@@ -104,6 +119,7 @@
 	Line numbers   : 37-37
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:38: info: Metrics per 'operator delete' region
 	Region name    : operator delete
@@ -112,6 +128,7 @@
 	Line numbers   : 38-38
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:39: info: Metrics per 'operator new[ ]' region
 	Region name    : operator new[ ]
@@ -120,6 +137,7 @@
 	Line numbers   : 39-39
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:40: info: Metrics per 'operator delete []' region
 	Region name    : operator delete []
@@ -128,6 +146,7 @@
 	Line numbers   : 40-40
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:41: info: Metrics per 'operator+' region
 	Region name    : operator+
@@ -136,6 +155,7 @@
 	Line numbers   : 41-41
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:42: info: Metrics per 'operator -' region
 	Region name    : operator -
@@ -144,6 +164,7 @@
 	Line numbers   : 42-42
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:43: info: Metrics per 'operator *' region
 	Region name    : operator *
@@ -152,6 +173,7 @@
 	Line numbers   : 43-43
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:44: info: Metrics per 'operator /' region
 	Region name    : operator /
@@ -160,6 +182,7 @@
 	Line numbers   : 44-44
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:45: info: Metrics per 'operator=' region
 	Region name    : operator=
@@ -168,6 +191,7 @@
 	Line numbers   : 45-45
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:46: info: Metrics per 'operator<' region
 	Region name    : operator<
@@ -176,6 +200,7 @@
 	Line numbers   : 46-46
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:47: info: Metrics per 'operator >' region
 	Region name    : operator >
@@ -184,6 +209,7 @@
 	Line numbers   : 47-47
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:48: info: Metrics per 'operator+=' region
 	Region name    : operator+=
@@ -192,6 +218,7 @@
 	Line numbers   : 48-48
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:49: info: Metrics per 'operator -=' region
 	Region name    : operator -=
@@ -200,6 +227,7 @@
 	Line numbers   : 49-49
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:50: info: Metrics per 'operator*=' region
 	Region name    : operator*=
@@ -208,6 +236,7 @@
 	Line numbers   : 50-50
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:51: info: Metrics per 'operator/=' region
 	Region name    : operator/=
@@ -216,6 +245,7 @@
 	Line numbers   : 51-51
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:52: info: Metrics per 'operator<<' region
 	Region name    : operator<<
@@ -224,6 +254,7 @@
 	Line numbers   : 52-52
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:53: info: Metrics per 'operator >>' region
 	Region name    : operator >>
@@ -232,6 +263,7 @@
 	Line numbers   : 53-53
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:54: info: Metrics per 'operator <<=' region
 	Region name    : operator <<=
@@ -240,6 +272,7 @@
 	Line numbers   : 54-54
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:55: info: Metrics per 'operator>>=' region
 	Region name    : operator>>=
@@ -248,6 +281,7 @@
 	Line numbers   : 55-55
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:56: info: Metrics per 'operator==' region
 	Region name    : operator==
@@ -256,6 +290,7 @@
 	Line numbers   : 56-56
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:57: info: Metrics per 'operator!=' region
 	Region name    : operator!=
@@ -264,6 +299,7 @@
 	Line numbers   : 57-57
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:58: info: Metrics per 'operator<=' region
 	Region name    : operator<=
@@ -272,6 +308,7 @@
 	Line numbers   : 58-58
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:59: info: Metrics per 'operator >=' region
 	Region name    : operator >=
@@ -280,6 +317,7 @@
 	Line numbers   : 59-59
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:60: info: Metrics per 'operator ++' region
 	Region name    : operator ++
@@ -288,6 +326,7 @@
 	Line numbers   : 60-60
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:61: info: Metrics per 'operator--' region
 	Region name    : operator--
@@ -296,6 +335,7 @@
 	Line numbers   : 61-61
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:62: info: Metrics per 'operator%' region
 	Region name    : operator%
@@ -304,6 +344,7 @@
 	Line numbers   : 62-62
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:63: info: Metrics per 'operator &' region
 	Region name    : operator &
@@ -312,6 +353,7 @@
 	Line numbers   : 63-63
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:64: info: Metrics per 'operator ^' region
 	Region name    : operator ^
@@ -320,6 +362,7 @@
 	Line numbers   : 64-64
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:65: info: Metrics per 'operator !' region
 	Region name    : operator !
@@ -328,6 +371,7 @@
 	Line numbers   : 65-65
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:66: info: Metrics per 'operator|' region
 	Region name    : operator|
@@ -336,6 +380,7 @@
 	Line numbers   : 66-66
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:67: info: Metrics per 'operator~' region
 	Region name    : operator~
@@ -344,6 +389,7 @@
 	Line numbers   : 67-67
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:68: info: Metrics per 'operator &=' region
 	Region name    : operator &=
@@ -352,6 +398,7 @@
 	Line numbers   : 68-68
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:69: info: Metrics per 'operator ^=' region
 	Region name    : operator ^=
@@ -360,6 +407,7 @@
 	Line numbers   : 69-69
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:70: info: Metrics per 'operator |=' region
 	Region name    : operator |=
@@ -368,6 +416,7 @@
 	Line numbers   : 70-70
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:71: info: Metrics per 'operator &&' region
 	Region name    : operator &&
@@ -376,6 +425,7 @@
 	Line numbers   : 71-71
 	Modified       : None
 	std.code.complexity:cyclomatic: 1
+	std.code.complexity:cyclomatic_switch_case_once: 1
 
 ./operator_test.hpp:72: info: Metrics per 'operator ||' region
 	Region name    : operator ||
@@ -384,6 +434,7 @@
 	Line numbers   : 72-72
 	Modified       : None
 	std.code.complexity:cyclomatic: 1
+	std.code.complexity:cyclomatic_switch_case_once: 1
 
 ./operator_test.hpp:73: info: Metrics per 'operator %=' region
 	Region name    : operator %=
@@ -392,6 +443,7 @@
 	Line numbers   : 73-73
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:74: info: Metrics per 'operator []' region
 	Region name    : operator []
@@ -400,6 +452,7 @@
 	Line numbers   : 74-74
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:75: info: Metrics per 'operator  ()' region
 	Region name    : operator  ()
@@ -408,6 +461,7 @@
 	Line numbers   : 75-75
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:76: info: Metrics per 'operator()' region
 	Region name    : operator()
@@ -416,6 +470,7 @@
 	Line numbers   : 76-76
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:77: info: Metrics per 'operator()' region
 	Region name    : operator()
@@ -424,6 +479,7 @@
 	Line numbers   : 77-77
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:78: info: Metrics per 'operator()' region
 	Region name    : operator()
@@ -432,6 +488,7 @@
 	Line numbers   : 78-78
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:79: info: Metrics per 'operator ()' region
 	Region name    : operator ()
@@ -440,6 +497,7 @@
 	Line numbers   : 79-79
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:80: info: Metrics per 'operator ()' region
 	Region name    : operator ()
@@ -448,6 +506,7 @@
 	Line numbers   : 80-80
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:81: info: Metrics per 'operator ,' region
 	Region name    : operator ,
@@ -456,6 +515,7 @@
 	Line numbers   : 81-81
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:82: info: Metrics per 'operator ->*' region
 	Region name    : operator ->*
@@ -464,6 +524,7 @@
 	Line numbers   : 82-82
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:83: info: Metrics per 'operator->' region
 	Region name    : operator->
@@ -472,6 +533,7 @@
 	Line numbers   : 83-83
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:84: info: Metrics per 'operator.' region
 	Region name    : operator.
@@ -480,6 +542,7 @@
 	Line numbers   : 84-84
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./operator_test.hpp:: info: Overall metrics for 'std.code.complexity:cyclomatic' metric
 	Average        : 0.07843137
@@ -492,6 +555,17 @@
 	             1 : 0.039 : 0.980 :  2	|||
 	             2 : 0.020 : 1.000 :  1	|
 
+./operator_test.hpp:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 0.07843137
+	Minimum        : 0
+	Maximum        : 2
+	Total          : 4.0
+	Distribution   : 51 regions in total (including 0 suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 0.941 : 0.941 : 48	||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+	             1 : 0.039 : 0.980 :  2	|||
+	             2 : 0.020 : 1.000 :  1	|
+
 ./test.c:0: info: Metrics per '__global__' region
 	Region name    : __global__
 	Region type    : global
@@ -506,6 +580,7 @@
 	Line numbers   : 12-14
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:108: info: Metrics per 'boost' region
 	Region name    : boost
@@ -528,6 +603,7 @@
 	Line numbers   : 125-125
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:134: info: Metrics per 'mycontainer' region
 	Region name    : mycontainer
@@ -543,6 +619,7 @@
 	Line numbers   : 136-137
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:138: info: Metrics per 'increase' region
 	Region name    : increase
@@ -551,6 +628,7 @@
 	Line numbers   : 138-138
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:143: info: Metrics per 'mycontainer' region
 	Region name    : mycontainer
@@ -566,6 +644,7 @@
 	Line numbers   : 145-146
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:147: info: Metrics per 'uppercase' region
 	Region name    : uppercase
@@ -574,6 +653,7 @@
 	Line numbers   : 147-152
 	Modified       : None
 	std.code.complexity:cyclomatic: 2
+	std.code.complexity:cyclomatic_switch_case_once: 2
 
 ./test.c:156: info: Metrics per 'main' region
 	Region name    : main
@@ -582,6 +662,7 @@
 	Line numbers   : 155-162
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:164: info: Metrics per 'scoped_ptr' region
 	Region name    : scoped_ptr
@@ -597,6 +678,7 @@
 	Line numbers   : 185-190
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:192: info: Metrics per 'scoped_ptr' region
 	Region name    : scoped_ptr
@@ -605,6 +687,7 @@
 	Line numbers   : 192-198
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:202: info: Metrics per 'scoped_ptr' region
 	Region name    : scoped_ptr
@@ -613,6 +696,7 @@
 	Line numbers   : 202-207
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:210: info: Metrics per '~scoped_ptr' region
 	Region name    : ~scoped_ptr
@@ -621,6 +705,7 @@
 	Line numbers   : 209-216
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:216: info: Metrics per 'reset' region
 	Region name    : reset
@@ -629,6 +714,7 @@
 	Line numbers   : 216-220
 	Modified       : None
 	std.code.complexity:cyclomatic: 1
+	std.code.complexity:cyclomatic_switch_case_once: 1
 
 ./test.c:220: info: Metrics per 'operator*' region
 	Region name    : operator*
@@ -637,6 +723,7 @@
 	Line numbers   : 220-224
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:226: info: Metrics per 'operator->' region
 	Region name    : operator->
@@ -645,6 +732,7 @@
 	Line numbers   : 226-230
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:232: info: Metrics per 'operator  float' region
 	Region name    : operator  float
@@ -653,6 +741,7 @@
 	Line numbers   : 232-236
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:238: info: Metrics per 'get' region
 	Region name    : get
@@ -661,6 +750,7 @@
 	Line numbers   : 238-241
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:246: info: Metrics per 'swap' region
 	Region name    : swap
@@ -669,6 +759,7 @@
 	Line numbers   : 246-251
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:254: info: Metrics per 'swap' region
 	Region name    : swap
@@ -677,6 +768,7 @@
 	Line numbers   : 254-257
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:261: info: Metrics per 'get_pointer' region
 	Region name    : get_pointer
@@ -685,6 +777,7 @@
 	Line numbers   : 261-264
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:276: info: Metrics per 'Central' region
 	Region name    : Central
@@ -700,6 +793,7 @@
 	Line numbers   : 277-294
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:296: info: Metrics per 'save' region
 	Region name    : save
@@ -708,6 +802,7 @@
 	Line numbers   : 296-321
 	Modified       : None
 	std.code.complexity:cyclomatic: 1
+	std.code.complexity:cyclomatic_switch_case_once: 1
 
 ./test.c:323: info: Metrics per 'show' region
 	Region name    : show
@@ -716,6 +811,7 @@
 	Line numbers   : 323-330
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:332: info: Metrics per 'main' region
 	Region name    : main
@@ -724,6 +820,7 @@
 	Line numbers   : 332-344
 	Modified       : None
 	std.code.complexity:cyclomatic: 2
+	std.code.complexity:cyclomatic_switch_case_once: 2
 
 ./test.c:349: info: Metrics per 'f1' region
 	Region name    : f1
@@ -732,6 +829,7 @@
 	Line numbers   : 349-349
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test.c:: info: Overall metrics for 'std.code.complexity:cyclomatic' metric
 	Average        : 0.25
@@ -744,11 +842,22 @@
 	             1 : 0.083 : 0.917 :  2	||||||||
 	             2 : 0.083 : 1.000 :  2	||||||||
 
+./test.c:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 0.25
+	Minimum        : 0
+	Maximum        : 2
+	Total          : 6.0
+	Distribution   : 24 regions in total (including 0 suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 0.833 : 0.833 : 20	|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+	             1 : 0.083 : 0.917 :  2	||||||||
+	             2 : 0.083 : 1.000 :  2	||||||||
+
 ./test2.cpp:0: info: Metrics per '__global__' region
 	Region name    : __global__
 	Region type    : global
-	Offsets        : 0-628
-	Line numbers   : 1-53
+	Offsets        : 0-736
+	Line numbers   : 1-66
 	Modified       : None
 
 ./test2.cpp:5: info: Metrics per 'A' region
@@ -765,6 +874,7 @@
 	Line numbers   : 7-10
 	Modified       : None
 	std.code.complexity:cyclomatic: 1
+	std.code.complexity:cyclomatic_switch_case_once: 1
 
 ./test2.cpp:10: info: Metrics per 'method' region
 	Region name    : method
@@ -773,6 +883,7 @@
 	Line numbers   : 10-13
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test2.cpp:13: info: Metrics per 'operator ++' region
 	Region name    : operator ++
@@ -781,32 +892,45 @@
 	Line numbers   : 13-16
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test2.cpp:22: info: Metrics per 'aaa' region
 	Region name    : aaa
 	Region type    : namespace
-	Offsets        : 173-350
-	Line numbers   : 21-39
+	Offsets        : 173-458
+	Line numbers   : 21-52
 	Modified       : None
 
 ./test2.cpp:23: info: Metrics per 'main' region
 	Region name    : main
 	Region type    : function
-	Offsets        : 192-348
-	Line numbers   : 23-38
+	Offsets        : 192-456
+	Line numbers   : 23-51
 	Modified       : None
-	std.code.complexity:cyclomatic: 2
+	std.code.complexity:cyclomatic: 6
+	std.code.complexity:cyclomatic_switch_case_once: 3
 
 ./test2.cpp:: info: Overall metrics for 'std.code.complexity:cyclomatic' metric
-	Average        : 0.75
+	Average        : 1.75
 	Minimum        : 0
-	Maximum        : 2
-	Total          : 3.0
+	Maximum        : 6
+	Total          : 7.0
 	Distribution   : 4 regions in total (including 0 suppressed)
 	  Metric value : Ratio : R-sum : Number of regions
 	             0 : 0.500 : 0.500 : 2	||||||||||||||||||||||||||||||||||||||||||||||||||
 	             1 : 0.250 : 0.750 : 1	|||||||||||||||||||||||||
-	             2 : 0.250 : 1.000 : 1	|||||||||||||||||||||||||
+	             6 : 0.250 : 1.000 : 1	|||||||||||||||||||||||||
+
+./test2.cpp:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 1.0
+	Minimum        : 0
+	Maximum        : 3
+	Total          : 4.0
+	Distribution   : 4 regions in total (including 0 suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 0.500 : 0.500 : 2	||||||||||||||||||||||||||||||||||||||||||||||||||
+	             1 : 0.250 : 0.750 : 1	|||||||||||||||||||||||||
+	             3 : 0.250 : 1.000 : 1	|||||||||||||||||||||||||
 
 ./test3.cpp:0: info: Metrics per '__global__' region
 	Region name    : __global__
@@ -829,6 +953,7 @@
 	Line numbers   : 38-48
 	Modified       : None
 	std.code.complexity:cyclomatic: 1
+	std.code.complexity:cyclomatic_switch_case_once: 1
 
 ./test3.cpp:53: info: Metrics per 'doFont' region
 	Region name    : doFont
@@ -837,6 +962,7 @@
 	Line numbers   : 53-66
 	Modified       : None
 	std.code.complexity:cyclomatic: 1
+	std.code.complexity:cyclomatic_switch_case_once: 1
 
 ./test3.cpp:72: info: Metrics per 'doFont222' region
 	Region name    : doFont222
@@ -845,6 +971,7 @@
 	Line numbers   : 68-87
 	Modified       : None
 	std.code.complexity:cyclomatic: 2
+	std.code.complexity:cyclomatic_switch_case_once: 2
 
 ./test3.cpp:90: info: Metrics per 'not_closed' region
 	Region name    : not_closed
@@ -860,6 +987,7 @@
 	Line numbers   : 110-120
 	Modified       : None
 	std.code.complexity:cyclomatic: 0
+	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./test3.cpp:102: info: Metrics per '__noname__' region
 	Region name    : __noname__
@@ -886,4 +1014,15 @@
 	             1 : 0.500 : 0.750 : 2	||||||||||||||||||||||||||||||||||||||||||||||||||
 	             2 : 0.250 : 1.000 : 1	|||||||||||||||||||||||||
 
+./test3.cpp:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 1.0
+	Minimum        : 0
+	Maximum        : 2
+	Total          : 4.0
+	Distribution   : 4 regions in total (including 0 suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 0.250 : 0.250 : 1	|||||||||||||||||||||||||
+	             1 : 0.500 : 0.750 : 2	||||||||||||||||||||||||||||||||||||||||||||||||||
+	             2 : 0.250 : 1.000 : 1	|||||||||||||||||||||||||
+
 

+ 3 - 1
metrixpp/tests/general/test_std_code_cs.py

@@ -14,7 +14,9 @@ class Test(tests.common.TestCase):
 
     def test_parser(self):
         
-        runner = tests.common.ToolRunner('collect', ['--std.code.complexity.cyclomatic'])
+        runner = tests.common.ToolRunner('collect',
+                                         ['--std.code.complexity.cyclomatic',
+                                          '--std.code.complexity.cyclomatic_switch_case_once'])
         self.assertExec(runner.run())
 
         runner = tests.common.ToolRunner('view', ['--nest-regions', '--format=xml'])

+ 14 - 0
metrixpp/tests/general/test_std_code_cs/sources/Generics.cs

@@ -53,6 +53,20 @@ public static class Generics
 			{
 				this.Size(capacity);
 			}
+
+			switch(capacity)
+			{
+				case 1:
+					break;
+				case 2:
+					break;
+				case 3:
+					break;
+				case 4:
+					break;
+				default:
+					break;
+			}
 		}
 	}
 	

+ 1 - 1
metrixpp/tests/general/test_std_code_cs/test_parser_limit_default_stdout.gold.txt

@@ -118,7 +118,7 @@
 ./Generics.cs:50: warning: Metric 'std.code.complexity:cyclomatic' for region 'Grow' exceeds the limit.
 	Metric name    : std.code.complexity:cyclomatic
 	Region name    : Grow
-	Metric value   : 1
+	Metric value   : 5
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0

+ 14 - 3
metrixpp/tests/general/test_std_code_cs/test_parser_view_default_stdout.gold.txt

@@ -3,17 +3,28 @@
     <data>
         <aggregated-data>
             <std.code.complexity>
-                <cyclomatic avg="1.15384615" count="39" max="6" min="0" nonzero="False" sup="0" total="45.0">
+                <cyclomatic avg="1.25641026" count="39" max="6" min="0" nonzero="False" sup="0" total="49.0">
                     <distribution-bars>
                         <distribution-bar count="23" metric="0" ratio="0.58974359" />
-                        <distribution-bar count="7" metric="1" ratio="0.17948718" />
+                        <distribution-bar count="6" metric="1" ratio="0.15384615" />
                         <distribution-bar count="1" metric="2" ratio="0.02564103" />
                         <distribution-bar count="1" metric="3" ratio="0.02564103" />
                         <distribution-bar count="3" metric="4" ratio="0.07692308" />
-                        <distribution-bar count="3" metric="5" ratio="0.07692308" />
+                        <distribution-bar count="4" metric="5" ratio="0.1025641" />
                         <distribution-bar count="1" metric="6" ratio="0.02564103" />
                     </distribution-bars>
                 </cyclomatic>
+                <cyclomatic_switch_case_once avg="1.17948718" count="39" max="6" min="0" nonzero="False" sup="0" total="46.0">
+                    <distribution-bars>
+                        <distribution-bar count="23" metric="0" ratio="0.58974359" />
+                        <distribution-bar count="6" metric="1" ratio="0.15384615" />
+                        <distribution-bar count="2" metric="2" ratio="0.05128205" />
+                        <distribution-bar count="1" metric="3" ratio="0.02564103" />
+                        <distribution-bar count="3" metric="4" ratio="0.07692308" />
+                        <distribution-bar count="3" metric="5" ratio="0.07692308" />
+                        <distribution-bar count="1" metric="6" ratio="0.02564103" />
+                    </distribution-bars>
+                </cyclomatic_switch_case_once>
             </std.code.complexity>
         </aggregated-data>
         <file-data />

+ 112 - 37
metrixpp/tests/general/test_std_code_cs/test_parser_view_files_stdout.gold.txt

@@ -26,6 +26,7 @@
             	Line numbers   : 74-89
             	Modified       : None
             	std.code.complexity:cyclomatic: 3
+            	std.code.complexity:cyclomatic_switch_case_once: 3
 
 .   .   .   ./File.cs:95: info: Metrics per 'get' region
             	Region name    : get
@@ -34,6 +35,7 @@
             	Line numbers   : 95-114
             	Modified       : None
             	std.code.complexity:cyclomatic: 2
+            	std.code.complexity:cyclomatic_switch_case_once: 2
 
 .   .   .   ./File.cs:120: info: Metrics per 'get' region
             	Region name    : get
@@ -42,6 +44,7 @@
             	Line numbers   : 120-128
             	Modified       : None
             	std.code.complexity:cyclomatic: 1
+            	std.code.complexity:cyclomatic_switch_case_once: 1
 
 .   .   .   ./File.cs:134: info: Metrics per 'get' region
             	Region name    : get
@@ -50,6 +53,7 @@
             	Line numbers   : 134-142
             	Modified       : None
             	std.code.complexity:cyclomatic: 1
+            	std.code.complexity:cyclomatic_switch_case_once: 1
 
 .   .   .   ./File.cs:148: info: Metrics per 'get' region
             	Region name    : get
@@ -58,6 +62,7 @@
             	Line numbers   : 148-156
             	Modified       : None
             	std.code.complexity:cyclomatic: 1
+            	std.code.complexity:cyclomatic_switch_case_once: 1
 
 .   .   .   ./File.cs:160: info: Metrics per 'Close' region
             	Region name    : Close
@@ -66,6 +71,7 @@
             	Line numbers   : 159-187
             	Modified       : None
             	std.code.complexity:cyclomatic: 4
+            	std.code.complexity:cyclomatic_switch_case_once: 4
 
 .   .   .   ./File.cs:190: info: Metrics per 'SetRecord' region
             	Region name    : SetRecord
@@ -74,6 +80,7 @@
             	Line numbers   : 189-226
             	Modified       : None
             	std.code.complexity:cyclomatic: 6
+            	std.code.complexity:cyclomatic_switch_case_once: 6
 
 .   .   .   ./File.cs:229: info: Metrics per 'FileTable' region
             	Region name    : FileTable
@@ -89,6 +96,7 @@
                 	Line numbers   : 235-240
                 	Modified       : None
                 	std.code.complexity:cyclomatic: 0
+                	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./File.cs:245: info: Metrics per 'GetFile' region
             	Region name    : GetFile
@@ -97,6 +105,7 @@
             	Line numbers   : 244-274
             	Modified       : None
             	std.code.complexity:cyclomatic: 5
+            	std.code.complexity:cyclomatic_switch_case_once: 5
 
 .   .   .   ./File.cs:277: info: Metrics per 'GetFile' region
             	Region name    : GetFile
@@ -105,6 +114,7 @@
             	Line numbers   : 276-285
             	Modified       : None
             	std.code.complexity:cyclomatic: 1
+            	std.code.complexity:cyclomatic_switch_case_once: 1
 
 .   .   .   ./File.cs:288: info: Metrics per 'AllocateFile' region
             	Region name    : AllocateFile
@@ -113,6 +123,7 @@
             	Line numbers   : 287-324
             	Modified       : None
             	std.code.complexity:cyclomatic: 5
+            	std.code.complexity:cyclomatic_switch_case_once: 5
 
 .   .   .   ./File.cs:327: info: Metrics per 'FindFreeFile' region
             	Region name    : FindFreeFile
@@ -121,6 +132,7 @@
             	Line numbers   : 326-358
             	Modified       : None
             	std.code.complexity:cyclomatic: 5
+            	std.code.complexity:cyclomatic_switch_case_once: 5
 
 .   .   .   ./File.cs:361: info: Metrics per 'CloseAll' region
             	Region name    : CloseAll
@@ -129,6 +141,7 @@
             	Line numbers   : 360-387
             	Modified       : None
             	std.code.complexity:cyclomatic: 4
+            	std.code.complexity:cyclomatic_switch_case_once: 4
 
 .   .   .   ./File.cs:391: info: Metrics per 'Write' region
             	Region name    : Write
@@ -137,6 +150,7 @@
             	Line numbers   : 389-394
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./File.cs:398: info: Metrics per 'WriteLine' region
             	Region name    : WriteLine
@@ -145,6 +159,7 @@
             	Line numbers   : 396-401
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./File.cs:405: info: Metrics per 'Tab' region
             	Region name    : Tab
@@ -153,6 +168,7 @@
             	Line numbers   : 403-408
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./File.cs:412: info: Metrics per 'Space' region
             	Region name    : Space
@@ -161,6 +177,7 @@
             	Line numbers   : 410-415
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./File.cs:419: info: Metrics per 'Lock' region
             	Region name    : Lock
@@ -169,6 +186,7 @@
             	Line numbers   : 417-422
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./File.cs:426: info: Metrics per 'Unlock' region
             	Region name    : Unlock
@@ -177,6 +195,7 @@
             	Line numbers   : 424-435
             	Modified       : None
             	std.code.complexity:cyclomatic: 1
+            	std.code.complexity:cyclomatic_switch_case_once: 1
 
 ./File.cs:: info: Overall metrics for 'std.code.complexity:cyclomatic' metric
 	Average        : 2.05263158
@@ -193,25 +212,40 @@
 	             5 : 0.158 : 0.947 :  3	|||||||||||||||
 	             6 : 0.053 : 1.000 :  1	|||||
 
+./File.cs:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 2.05263158
+	Minimum        : 0
+	Maximum        : 6
+	Total          : 39.0
+	Distribution   : 19 regions in total (including 0 suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 0.316 : 0.316 :  6	|||||||||||||||||||||||||||||||
+	             1 : 0.263 : 0.579 :  5	||||||||||||||||||||||||||
+	             2 : 0.053 : 0.632 :  1	|||||
+	             3 : 0.053 : 0.684 :  1	|||||
+	             4 : 0.105 : 0.789 :  2	||||||||||
+	             5 : 0.158 : 0.947 :  3	|||||||||||||||
+	             6 : 0.053 : 1.000 :  1	|||||
+
 ./Generics.cs:0: info: Metrics per '__global__' region
 	Region name    : __global__
 	Region type    : global
-	Offsets        : 0-3134
-	Line numbers   : 1-106
+	Offsets        : 0-3286
+	Line numbers   : 1-120
 	Modified       : None
 
 .   ./Generics.cs:22: info: Metrics per 'Generics' region
     	Region name    : Generics
     	Region type    : class
-    	Offsets        : 1182-3133
-    	Line numbers   : 22-105
+    	Offsets        : 1182-3285
+    	Line numbers   : 22-119
     	Modified       : None
 
 .   .   ./Generics.cs:24: info: Metrics per 'MyArray<T>' region
         	Region name    : MyArray<T>
         	Region type    : class
-        	Offsets        : 1214-1664
-        	Line numbers   : 24-57
+        	Offsets        : 1214-1816
+        	Line numbers   : 24-71
         	Modified       : None
 
 .   .   .   ./Generics.cs:26: info: Metrics per 'NestedClass<Y>' region
@@ -228,6 +262,7 @@
             	Line numbers   : 40-43
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./Generics.cs:45: info: Metrics per 'Size' region
             	Region name    : Size
@@ -236,85 +271,102 @@
             	Line numbers   : 45-48
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./Generics.cs:50: info: Metrics per 'Grow' region
             	Region name    : Grow
             	Region type    : function
-            	Offsets        : 1552-1661
-            	Line numbers   : 50-56
+            	Offsets        : 1552-1813
+            	Line numbers   : 50-70
             	Modified       : None
-            	std.code.complexity:cyclomatic: 1
+            	std.code.complexity:cyclomatic: 5
+            	std.code.complexity:cyclomatic_switch_case_once: 2
 
-.   .   ./Generics.cs:59: info: Metrics per 'IInterface' region
+.   .   ./Generics.cs:73: info: Metrics per 'IInterface' region
         	Region name    : IInterface
         	Region type    : interface
-        	Offsets        : 1668-1775
-        	Line numbers   : 59-63
+        	Offsets        : 1820-1927
+        	Line numbers   : 73-77
         	Modified       : None
 
-.   .   ./Generics.cs:65: info: Metrics per 'Base' region
+.   .   ./Generics.cs:79: info: Metrics per 'Base' region
         	Region name    : Base
         	Region type    : class
-        	Offsets        : 1779-2084
-        	Line numbers   : 65-74
+        	Offsets        : 1931-2236
+        	Line numbers   : 79-88
         	Modified       : None
 
-.   .   .   ./Generics.cs:71: info: Metrics per 'Generics.IInterface.Method2<T>' region
+.   .   .   ./Generics.cs:85: info: Metrics per 'Generics.IInterface.Method2<T>' region
             	Region name    : Generics.IInterface.Method2<T>
             	Region type    : function
-            	Offsets        : 1960-2081
-            	Line numbers   : 70-73
+            	Offsets        : 2112-2233
+            	Line numbers   : 84-87
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
-.   .   ./Generics.cs:76: info: Metrics per 'Derived' region
+.   .   ./Generics.cs:90: info: Metrics per 'Derived' region
         	Region name    : Derived
         	Region type    : class
-        	Offsets        : 2088-2245
-        	Line numbers   : 76-82
+        	Offsets        : 2240-2397
+        	Line numbers   : 90-96
         	Modified       : None
 
-.   .   .   ./Generics.cs:79: info: Metrics per 'Method1<T>' region
+.   .   .   ./Generics.cs:93: info: Metrics per 'Method1<T>' region
             	Region name    : Method1<T>
             	Region type    : function
-            	Offsets        : 2130-2242
-            	Line numbers   : 78-81
+            	Offsets        : 2282-2394
+            	Line numbers   : 92-95
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
-.   .   ./Generics.cs:92: info: Metrics per 'MethodWithConstraint<T,S>' region
+.   .   ./Generics.cs:106: info: Metrics per 'MethodWithConstraint<T,S>' region
         	Region name    : MethodWithConstraint<T,S>
         	Region type    : function
-        	Offsets        : 2698-2798
-        	Line numbers   : 92-94
+        	Offsets        : 2850-2950
+        	Line numbers   : 106-108
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
-.   .   ./Generics.cs:96: info: Metrics per 'MethodWithStructConstraint<T>' region
+.   .   ./Generics.cs:110: info: Metrics per 'MethodWithStructConstraint<T>' region
         	Region name    : MethodWithStructConstraint<T>
         	Region type    : function
-        	Offsets        : 2802-2875
-        	Line numbers   : 96-98
+        	Offsets        : 2954-3027
+        	Line numbers   : 110-112
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
-.   .   ./Generics.cs:100: info: Metrics per 'GetEnumerator' region
+.   .   ./Generics.cs:114: info: Metrics per 'GetEnumerator' region
         	Region name    : GetEnumerator
         	Region type    : function
-        	Offsets        : 2879-3131
-        	Line numbers   : 100-104
+        	Offsets        : 3031-3283
+        	Line numbers   : 114-118
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./Generics.cs:: info: Overall metrics for 'std.code.complexity:cyclomatic' metric
-	Average        : 0.125
+	Average        : 0.625
 	Minimum        : 0
-	Maximum        : 1
-	Total          : 1.0
+	Maximum        : 5
+	Total          : 5.0
+	Distribution   : 8 regions in total (including 0 suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 0.875 : 0.875 : 7	|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+	             5 : 0.125 : 1.000 : 1	||||||||||||
+
+./Generics.cs:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 0.25
+	Minimum        : 0
+	Maximum        : 2
+	Total          : 2.0
 	Distribution   : 8 regions in total (including 0 suppressed)
 	  Metric value : Ratio : R-sum : Number of regions
 	             0 : 0.875 : 0.875 : 7	|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-	             1 : 0.125 : 1.000 : 1	||||||||||||
+	             2 : 0.125 : 1.000 : 1	||||||||||||
 
 ./interface.cs:0: info: Metrics per '__global__' region
 	Region name    : __global__
@@ -358,6 +410,7 @@
             	Line numbers   : 75-83
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./interface.cs:88: info: Metrics per 'get' region
             	Region name    : get
@@ -366,6 +419,7 @@
             	Line numbers   : 88-92
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./interface.cs:98: info: Metrics per 'get' region
             	Region name    : get
@@ -374,6 +428,7 @@
             	Line numbers   : 98-102
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./interface.cs:108: info: Metrics per 'get' region
             	Region name    : get
@@ -382,6 +437,7 @@
             	Line numbers   : 108-112
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./interface.cs:118: info: Metrics per 'get' region
             	Region name    : get
@@ -390,6 +446,7 @@
             	Line numbers   : 118-122
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./interface.cs:128: info: Metrics per 'get' region
             	Region name    : get
@@ -398,6 +455,7 @@
             	Line numbers   : 128-131
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./interface.cs:135: info: Metrics per 'Equals' region
             	Region name    : Equals
@@ -406,6 +464,7 @@
             	Line numbers   : 134-146
             	Modified       : None
             	std.code.complexity:cyclomatic: 1
+            	std.code.complexity:cyclomatic_switch_case_once: 1
 
 .   .   .   ./interface.cs:149: info: Metrics per 'GetHashCode' region
             	Region name    : GetHashCode
@@ -414,6 +473,7 @@
             	Line numbers   : 148-152
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./interface.cs:169: info: Metrics per 'ToTitleCase' region
             	Region name    : ToTitleCase
@@ -422,6 +482,7 @@
             	Line numbers   : 168-195
             	Modified       : None
             	std.code.complexity:cyclomatic: 4
+            	std.code.complexity:cyclomatic_switch_case_once: 4
 
 .   .   .   ./interface.cs:198: info: Metrics per 'I.Deserialization.Callback.OnDeserialization' region
             	Region name    : I.Deserialization.Callback.OnDeserialization
@@ -430,6 +491,7 @@
             	Line numbers   : 197-201
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./interface.cs:204: info: Metrics per 'ToString' region
             	Region name    : ToString
@@ -438,6 +500,7 @@
             	Line numbers   : 203-207
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   .   ./interface.cs:211: info: Metrics per 'IDeserializationCallback.OnDeserialization' region
             	Region name    : IDeserializationCallback.OnDeserialization
@@ -446,6 +509,7 @@
             	Line numbers   : 209-214
             	Modified       : None
             	std.code.complexity:cyclomatic: 0
+            	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./interface.cs:: info: Overall metrics for 'std.code.complexity:cyclomatic' metric
 	Average        : 0.41666667
@@ -458,4 +522,15 @@
 	             1 : 0.083 : 0.917 :  1	||||||||
 	             4 : 0.083 : 1.000 :  1	||||||||
 
+./interface.cs:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 0.41666667
+	Minimum        : 0
+	Maximum        : 4
+	Total          : 5.0
+	Distribution   : 12 regions in total (including 0 suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 0.833 : 0.833 : 10	|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+	             1 : 0.083 : 0.917 :  1	||||||||
+	             4 : 0.083 : 1.000 :  1	||||||||
+
 

+ 3 - 1
metrixpp/tests/general/test_std_code_cs_unit.py

@@ -14,7 +14,9 @@ class Test(tests.common.TestCase):
 
     def test_parser(self):
         
-        runner = tests.common.ToolRunner('collect', ['--std.code.complexity.cyclomatic'])
+        runner = tests.common.ToolRunner('collect',
+                                         ['--std.code.complexity.cyclomatic',
+                                          '--std.code.complexity.cyclomatic_switch_case_once'])
         self.assertExec(runner.run())
 
         runner = tests.common.ToolRunner('view', ['--nest-regions', '--format=xml'])

+ 5 - 0
metrixpp/tests/general/test_std_code_cs_unit/test_parser_view_default_stdout.gold.txt

@@ -8,6 +8,11 @@
                         <distribution-bar count="18" metric="0" ratio="1.0" />
                     </distribution-bars>
                 </cyclomatic>
+                <cyclomatic_switch_case_once avg="0.0" count="18" max="0" min="0" nonzero="False" sup="0" total="0.0">
+                    <distribution-bars>
+                        <distribution-bar count="18" metric="0" ratio="1.0" />
+                    </distribution-bars>
+                </cyclomatic_switch_case_once>
             </std.code.complexity>
         </aggregated-data>
         <file-data />

+ 27 - 0
metrixpp/tests/general/test_std_code_cs_unit/test_parser_view_files_stdout.gold.txt

@@ -19,6 +19,7 @@
         	Line numbers   : 5-9
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:11: info: Metrics per 'testfunction2<T>' region
         	Region name    : testfunction2<T>
@@ -27,6 +28,7 @@
         	Line numbers   : 11-15
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:17: info: Metrics per 'testfunction3<T>' region
         	Region name    : testfunction3<T>
@@ -35,6 +37,7 @@
         	Line numbers   : 17-21
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:23: info: Metrics per 'testfunction4' region
         	Region name    : testfunction4
@@ -43,6 +46,7 @@
         	Line numbers   : 23-27
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:29: info: Metrics per 'testfunction5<T,S>' region
         	Region name    : testfunction5<T,S>
@@ -51,6 +55,7 @@
         	Line numbers   : 29-33
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:35: info: Metrics per 'testfunction6<T,S>' region
         	Region name    : testfunction6<T,S>
@@ -59,6 +64,7 @@
         	Line numbers   : 35-39
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:41: info: Metrics per 'testfunction7<T,S>' region
         	Region name    : testfunction7<T,S>
@@ -67,6 +73,7 @@
         	Line numbers   : 41-46
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:48: info: Metrics per 'testfunction8<T,S>' region
         	Region name    : testfunction8<T,S>
@@ -75,6 +82,7 @@
         	Line numbers   : 48-53
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:55: info: Metrics per 'testfunction9<T,S>' region
         	Region name    : testfunction9<T,S>
@@ -83,6 +91,7 @@
         	Line numbers   : 55-59
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:61: info: Metrics per 'Interface.testfunction10<T,S>' region
         	Region name    : Interface.testfunction10<T,S>
@@ -91,6 +100,7 @@
         	Line numbers   : 61-65
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:67: info: Metrics per 'Interface<T>.testfunction11<T,S>' region
         	Region name    : Interface<T>.testfunction11<T,S>
@@ -99,6 +109,7 @@
         	Line numbers   : 67-71
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:73: info: Metrics per 'Interface<T,S>.testfunction12' region
         	Region name    : Interface<T,S>.testfunction12
@@ -107,6 +118,7 @@
         	Line numbers   : 73-77
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:79: info: Metrics per 'Interface<T,S>.testfunction13<T>' region
         	Region name    : Interface<T,S>.testfunction13<T>
@@ -115,6 +127,7 @@
         	Line numbers   : 79-83
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:85: info: Metrics per 'Interface<T>.testfunction14<T,S>' region
         	Region name    : Interface<T>.testfunction14<T,S>
@@ -123,6 +136,7 @@
         	Line numbers   : 85-89
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:91: info: Metrics per 'Interface<T,S>.testfunction15<T,S>' region
         	Region name    : Interface<T,S>.testfunction15<T,S>
@@ -131,6 +145,7 @@
         	Line numbers   : 91-95
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:97: info: Metrics per 'Interface<T,S>.testfunction16<T>' region
         	Region name    : Interface<T,S>.testfunction16<T>
@@ -139,6 +154,7 @@
         	Line numbers   : 97-101
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:103: info: Metrics per 'Interface<T,S>.testfunction17<T>' region
         	Region name    : Interface<T,S>.testfunction17<T>
@@ -147,6 +163,7 @@
         	Line numbers   : 103-107
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 .   .   ./sample.cs:109: info: Metrics per 'testClass1' region
         	Region name    : testClass1
@@ -204,6 +221,7 @@
         	Line numbers   : 141-145
         	Modified       : None
         	std.code.complexity:cyclomatic: 0
+        	std.code.complexity:cyclomatic_switch_case_once: 0
 
 ./sample.cs:: info: Overall metrics for 'std.code.complexity:cyclomatic' metric
 	Average        : 0.0
@@ -214,4 +232,13 @@
 	  Metric value : Ratio : R-sum : Number of regions
 	             0 : 1.000 : 1.000 : 18	||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 
+./sample.cs:: info: Overall metrics for 'std.code.complexity:cyclomatic_switch_case_once' metric
+	Average        : 0.0
+	Minimum        : 0
+	Maximum        : 0
+	Total          : 0.0
+	Distribution   : 18 regions in total (including 0 suppressed)
+	  Metric value : Ratio : R-sum : Number of regions
+	             0 : 1.000 : 1.000 : 18	||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+
 

+ 3 - 1
metrixpp/tests/general/test_std_code_java.py

@@ -14,7 +14,9 @@ class Test(tests.common.TestCase):
 
     def test_parser(self):
         
-        runner = tests.common.ToolRunner('collect', ['--std.code.complexity.cyclomatic'])
+        runner = tests.common.ToolRunner('collect',
+                                         ['--std.code.complexity.cyclomatic',
+                                          '--std.code.complexity.cyclomatic_switch_case_once'])
         self.assertExec(runner.run())
 
         runner = tests.common.ToolRunner('view', ['--nest-regions', '--format=xml'])

+ 14 - 2
metrixpp/tests/general/test_std_code_java/sources/attrs.java

@@ -3,8 +3,20 @@
 class A
 {
 	@nested_attribute_should_not_be_a_function("word")
-	int function()
+	int function(int parameter)
 	{
-		
+		switch(parameter)
+		{
+			case 1:
+				break;
+			case 2:
+				break;
+			case 3:
+				break;
+			case 4:
+				break;
+			default:
+				break;
+		}
 	}
 }

+ 13 - 2
metrixpp/tests/general/test_std_code_java/test_parser_view_default_stdout.gold.txt

@@ -3,16 +3,27 @@
     <data>
         <aggregated-data>
             <std.code.complexity>
-                <cyclomatic avg="1.05882353" count="119" max="6" min="0" nonzero="False" sup="0" total="126.0">
+                <cyclomatic avg="1.09243697" count="119" max="6" min="0" nonzero="False" sup="0" total="130.0">
                     <distribution-bars>
-                        <distribution-bar count="58" metric="0" ratio="0.48739496" />
+                        <distribution-bar count="57" metric="0" ratio="0.4789916" />
                         <distribution-bar count="31" metric="1" ratio="0.2605042" />
                         <distribution-bar count="15" metric="2" ratio="0.12605042" />
                         <distribution-bar count="8" metric="3" ratio="0.06722689" />
+                        <distribution-bar count="1" metric="4" ratio="0.00840336" />
                         <distribution-bar count="1" metric="5" ratio="0.00840336" />
                         <distribution-bar count="6" metric="6" ratio="0.05042017" />
                     </distribution-bars>
                 </cyclomatic>
+                <cyclomatic_switch_case_once avg="1.06722689" count="119" max="6" min="0" nonzero="False" sup="0" total="127.0">
+                    <distribution-bars>
+                        <distribution-bar count="57" metric="0" ratio="0.4789916" />
+                        <distribution-bar count="32" metric="1" ratio="0.26890756" />
+                        <distribution-bar count="15" metric="2" ratio="0.12605042" />
+                        <distribution-bar count="8" metric="3" ratio="0.06722689" />
+                        <distribution-bar count="1" metric="5" ratio="0.00840336" />
+                        <distribution-bar count="6" metric="6" ratio="0.05042017" />
+                    </distribution-bars>
+                </cyclomatic_switch_case_once>
             </std.code.complexity>
         </aggregated-data>
         <file-data />

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 178 - 12
metrixpp/tests/general/test_std_code_java/test_parser_view_files_stdout.gold.txt