Browse Source

suppressions plugin for limit tool.

avkonst 11 years ago
parent
commit
675583f63a

+ 2 - 0
mainline/core/db/loader.py

@@ -866,6 +866,8 @@ class Loader(object):
             namespace = self.get_namespace(name)
             data = self.db.aggregate_rows(name, path_like = final_path_like)
             for field in data.keys():
+                if namespace.get_field_packager(field).get_python_type() == str:
+                    continue
                 if namespace.get_field_packager(field).is_non_zero() == True:
                     data[field]['min'] = None
                     data[field]['avg'] = None

+ 26 - 0
mainline/ext/std/code/length.ini

@@ -0,0 +1,26 @@
+;
+;    Metrix++, Copyright 2009-2013, Metrix++ Project
+;    Link: http://metrixplusplus.sourceforge.net
+;    
+;    This file is a part of Metrix++ Tool.
+;    
+;    Metrix++ is free software: you can redistribute it and/or modify
+;    it under the terms of the GNU General Public License as published by
+;    the Free Software Foundation, version 3 of the License.
+;    
+;    Metrix++ is distributed in the hope that it will be useful,
+;    but WITHOUT ANY WARRANTY; without even the implied warranty of
+;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;    GNU General Public License for more details.
+;    
+;    You should have received a copy of the GNU General Public License
+;    along with Metrix++.  If not, see <http://www.gnu.org/licenses/>.
+;
+
+[Plugin]
+version: 1.1
+package: std.code
+module:  length
+class:   Plugin
+depends: None
+enabled: True

+ 51 - 0
mainline/ext/std/code/length.py

@@ -0,0 +1,51 @@
+#
+#    Metrix++, Copyright 2009-2013, Metrix++ Project
+#    Link: http://metrixplusplus.sourceforge.net
+#    
+#    This file is a part of Metrix++ Tool.
+#    
+#    Metrix++ is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, version 3 of the License.
+#    
+#    Metrix++ is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#    GNU General Public License for more details.
+#    
+#    You should have received a copy of the GNU General Public License
+#    along with Metrix++.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+import core.api
+
+class Plugin(core.api.Plugin, core.api.Child, core.api.IConfigurable):
+    
+    def declare_configuration(self, parser):
+        parser.add_option("--std.code.length:size", "--scls", action="store_true", default=False,
+                         help="Enables collection of size metric (in number of symbols per region) [default: %default]")
+    
+    def configure(self, options):
+        self.is_active = options.__dict__['std.code.length:size']
+        
+    def initialize(self):
+        if self.is_active == True:
+            # trigger version property set
+            core.api.Plugin.initialize(self)
+            namespace = self.get_plugin_loader().get_database_loader().create_namespace(self.get_name(), support_regions = True)
+            namespace.add_field('size', int)
+            core.api.subscribe_by_parents_interface(core.api.ICode, self, 'callback')
+
+    def callback(self, parent, data, is_updated):
+        is_updated = is_updated or self.is_updated
+        if is_updated == True:
+            for region in data.iterate_regions():
+                size = 0
+                start_pos = region.get_offset_begin()
+                for sub_id in region.iterate_subregion_ids():
+                    # exclude sub regions, like enclosed classes
+                    size += data.get_region(sub_id).get_offset_begin() - start_pos
+                    start_pos = data.get_region(sub_id).get_offset_end()
+                size += region.get_offset_end() - start_pos
+                region.set_data(self.get_name(), 'size', size)
+

+ 4 - 4
mainline/ext/std/suppress.py

@@ -25,7 +25,7 @@ import re
 class Plugin(core.api.Plugin, core.api.Child, core.api.IConfigurable):
     
     def declare_configuration(self, parser):
-        parser.add_option("--std.suppress.code", "--ssc", action="store_true", default=False,
+        parser.add_option("--std.suppress", "--ss", action="store_true", default=False,
                          help="If set (True), suppression markers are collected from comments in code. "
                               "Suppressions are used by post-processing tools, like limit, to remove false-positive warnings. "
                               "Suppressions should be in the first comment block of a region (function/class/interface). "
@@ -34,7 +34,7 @@ class Plugin(core.api.Plugin, core.api.Child, core.api.IConfigurable):
                               " [default: %default]")
     
     def configure(self, options):
-        self.is_active = options.__dict__['std.suppress.code']
+        self.is_active = options.__dict__['std.suppress']
         
     def initialize(self):
         if self.is_active == True:
@@ -74,9 +74,9 @@ class Plugin(core.api.Plugin, core.api.Child, core.api.IConfigurable):
                         if namespace == None or namespace.get_field_packager(field) == None:
                             core.export.cout.cout(data.get_path(), region.get_cursor(),
                                                   core.export.cout.SEVERITY_WARNING,
-                                                  "Suppressed metric '" + namespace_name + "/" + field +
+                                                  "Suppressed metric '" + namespace_name + ":" + field +
                                                     "' is not being collected",
-                                                  [("Metric name", namespace_name + "/" + field),
+                                                  [("Metric name", namespace_name + ":" + field),
                                                    ("Region name", region.get_name())])
                             continue 
                         count += 1

+ 11 - 0
mainline/tests/general/test_basic/test_help_collect_default_stdout.gold.txt

@@ -44,3 +44,14 @@ Options:
   --std.code.java.files=STD.CODE.JAVA.FILES
                         Enumerates filename extensions to match Java files
                         [default: *.java]
+  --std.code.length:size, --scls
+                        Enables collection of size metric (in number of
+                        symbols per region) [default: False]
+  --std.suppress, --ss  If set (True), suppression markers are collected from
+                        comments in code. Suppressions are used by post-
+                        processing tools, like limit, to remove false-positive
+                        warnings. Suppressions should be in the first comment
+                        block of a region (function/class/interface). Format
+                        of suppressions: 'metrix++: suppress metric-name'. For
+                        example: 'metrix++: suppress
+                        std.code.complexity:cyclomatic'.  [default: False]

+ 3 - 0
mainline/tests/general/test_basic/test_help_limit_default_stdout.gold.txt

@@ -44,3 +44,6 @@ Options:
                         set, exceeded limits are sorted (the worst is the
                         first) and only first GENERAL.HOTSPOTS limits are
                         printed. [default: none]
+  --disable-suppressions, --ds
+                        If not set (none), all suppressions are ignored and
+                        associated warnings are printed. [default: False]

+ 12 - 8
mainline/tests/general/test_basic/test_workflow_limit_default_stdout.gold.txt

@@ -1,32 +1,36 @@
-./simple.cpp:10: warning: Metric 'std.code.complexity/cyclomatic' for region 'A' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:10: warning: Metric 'std.code.complexity:cyclomatic' for region 'A' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : A
 	Metric value   : 3
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple.cpp:23: warning: Metric 'std.code.complexity/cyclomatic' for region 'func' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:23: warning: Metric 'std.code.complexity:cyclomatic' for region 'func' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : func
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple.cpp:27: warning: Metric 'std.code.complexity/cyclomatic' for region 'embeded' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:27: warning: Metric 'std.code.complexity:cyclomatic' for region 'embeded' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : embeded
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple.cpp:39: warning: Metric 'std.code.complexity/cyclomatic' for region 'never' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:39: warning: Metric 'std.code.complexity:cyclomatic' for region 'never' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : never
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 

+ 18 - 12
mainline/tests/general/test_basic/test_workflow_limit_second_stdout.gold.txt

@@ -1,48 +1,54 @@
-./simple.cpp:10: warning: Metric 'std.code.complexity/cyclomatic' for region 'A' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:10: warning: Metric 'std.code.complexity:cyclomatic' for region 'A' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : A
 	Metric value   : 3
 	Modified       : False
 	Change trend   : 0
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple.cpp:23: warning: Metric 'std.code.complexity/cyclomatic' for region 'func' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:23: warning: Metric 'std.code.complexity:cyclomatic' for region 'func' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : func
 	Metric value   : 1
 	Modified       : False
 	Change trend   : 0
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple.cpp:27: warning: Metric 'std.code.complexity/cyclomatic' for region 'embeded' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:27: warning: Metric 'std.code.complexity:cyclomatic' for region 'embeded' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : embeded
 	Metric value   : 2
 	Modified       : True
 	Change trend   : +1
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple.cpp:41: warning: Metric 'std.code.complexity/cyclomatic' for region 'never' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:41: warning: Metric 'std.code.complexity:cyclomatic' for region 'never' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : never
 	Metric value   : 1
 	Modified       : True
 	Change trend   : 0
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple.cpp:55: warning: Metric 'std.code.complexity/cyclomatic' for region 'new_func_complex' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:55: warning: Metric 'std.code.complexity:cyclomatic' for region 'new_func_complex' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : new_func_complex
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple2.cpp:10: warning: Metric 'std.code.complexity/cyclomatic' for region 'New_A' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple2.cpp:10: warning: Metric 'std.code.complexity:cyclomatic' for region 'New_A' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : New_A
 	Metric value   : 3
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 

+ 18 - 12
mainline/tests/general/test_basic/test_workflow_limit_second_warn_all_stdout.gold.txt

@@ -1,48 +1,54 @@
-./simple.cpp:10: warning: Metric 'std.code.complexity/cyclomatic' for region 'A' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:10: warning: Metric 'std.code.complexity:cyclomatic' for region 'A' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : A
 	Metric value   : 3
 	Modified       : False
 	Change trend   : 0
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple.cpp:23: warning: Metric 'std.code.complexity/cyclomatic' for region 'func' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:23: warning: Metric 'std.code.complexity:cyclomatic' for region 'func' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : func
 	Metric value   : 1
 	Modified       : False
 	Change trend   : 0
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple.cpp:27: warning: Metric 'std.code.complexity/cyclomatic' for region 'embeded' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:27: warning: Metric 'std.code.complexity:cyclomatic' for region 'embeded' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : embeded
 	Metric value   : 2
 	Modified       : True
 	Change trend   : +1
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple.cpp:41: warning: Metric 'std.code.complexity/cyclomatic' for region 'never' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:41: warning: Metric 'std.code.complexity:cyclomatic' for region 'never' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : never
 	Metric value   : 1
 	Modified       : True
 	Change trend   : 0
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple.cpp:55: warning: Metric 'std.code.complexity/cyclomatic' for region 'new_func_complex' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:55: warning: Metric 'std.code.complexity:cyclomatic' for region 'new_func_complex' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : new_func_complex
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple2.cpp:10: warning: Metric 'std.code.complexity/cyclomatic' for region 'New_A' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple2.cpp:10: warning: Metric 'std.code.complexity:cyclomatic' for region 'New_A' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : New_A
 	Metric value   : 3
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 

+ 6 - 4
mainline/tests/general/test_basic/test_workflow_limit_second_warn_new_stdout.gold.txt

@@ -1,16 +1,18 @@
-./simple.cpp:55: warning: Metric 'std.code.complexity/cyclomatic' for region 'new_func_complex' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:55: warning: Metric 'std.code.complexity:cyclomatic' for region 'new_func_complex' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : new_func_complex
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple2.cpp:10: warning: Metric 'std.code.complexity/cyclomatic' for region 'New_A' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple2.cpp:10: warning: Metric 'std.code.complexity:cyclomatic' for region 'New_A' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : New_A
 	Metric value   : 3
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 

+ 12 - 8
mainline/tests/general/test_basic/test_workflow_limit_second_warn_touched_stdout.gold.txt

@@ -1,32 +1,36 @@
-./simple.cpp:27: warning: Metric 'std.code.complexity/cyclomatic' for region 'embeded' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:27: warning: Metric 'std.code.complexity:cyclomatic' for region 'embeded' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : embeded
 	Metric value   : 2
 	Modified       : True
 	Change trend   : +1
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple.cpp:41: warning: Metric 'std.code.complexity/cyclomatic' for region 'never' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:41: warning: Metric 'std.code.complexity:cyclomatic' for region 'never' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : never
 	Metric value   : 1
 	Modified       : True
 	Change trend   : 0
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple.cpp:55: warning: Metric 'std.code.complexity/cyclomatic' for region 'new_func_complex' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:55: warning: Metric 'std.code.complexity:cyclomatic' for region 'new_func_complex' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : new_func_complex
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple2.cpp:10: warning: Metric 'std.code.complexity/cyclomatic' for region 'New_A' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple2.cpp:10: warning: Metric 'std.code.complexity:cyclomatic' for region 'New_A' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : New_A
 	Metric value   : 3
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 

+ 9 - 6
mainline/tests/general/test_basic/test_workflow_limit_second_warn_trend_stdout.gold.txt

@@ -1,24 +1,27 @@
-./simple.cpp:27: warning: Metric 'std.code.complexity/cyclomatic' for region 'embeded' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:27: warning: Metric 'std.code.complexity:cyclomatic' for region 'embeded' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : embeded
 	Metric value   : 2
 	Modified       : True
 	Change trend   : +1
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple.cpp:55: warning: Metric 'std.code.complexity/cyclomatic' for region 'new_func_complex' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple.cpp:55: warning: Metric 'std.code.complexity:cyclomatic' for region 'new_func_complex' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : new_func_complex
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./simple2.cpp:10: warning: Metric 'std.code.complexity/cyclomatic' for region 'New_A' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./simple2.cpp:10: warning: Metric 'std.code.complexity:cyclomatic' for region 'New_A' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : New_A
 	Metric value   : 3
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 

+ 36 - 24
mainline/tests/general/test_std_code_cpp/test_parser_limit_default_stdout.gold.txt

@@ -1,96 +1,108 @@
-./operator_test.hpp:6: warning: Metric 'std.code.complexity/cyclomatic' for region 'policy_mcr' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./operator_test.hpp:6: warning: Metric 'std.code.complexity:cyclomatic' for region 'policy_mcr' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : policy_mcr
 	Metric value   : 2
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./operator_test.hpp:71: warning: Metric 'std.code.complexity/cyclomatic' for region 'operator &&' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./operator_test.hpp:71: warning: Metric 'std.code.complexity:cyclomatic' for region 'operator &&' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : operator &&
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./operator_test.hpp:72: warning: Metric 'std.code.complexity/cyclomatic' for region 'operator ||' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./operator_test.hpp:72: warning: Metric 'std.code.complexity:cyclomatic' for region 'operator ||' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : operator ||
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./test.c:147: warning: Metric 'std.code.complexity/cyclomatic' for region 'uppercase' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./test.c:147: warning: Metric 'std.code.complexity:cyclomatic' for region 'uppercase' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : uppercase
 	Metric value   : 2
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./test.c:216: warning: Metric 'std.code.complexity/cyclomatic' for region 'reset' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./test.c:216: warning: Metric 'std.code.complexity:cyclomatic' for region 'reset' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : reset
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./test.c:296: warning: Metric 'std.code.complexity/cyclomatic' for region 'save' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./test.c:296: warning: Metric 'std.code.complexity:cyclomatic' for region 'save' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : save
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./test.c:332: warning: Metric 'std.code.complexity/cyclomatic' for region 'main' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./test.c:332: warning: Metric 'std.code.complexity:cyclomatic' for region 'main' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : main
 	Metric value   : 2
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./test2.cpp:7: warning: Metric 'std.code.complexity/cyclomatic' for region 'A' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./test2.cpp:7: warning: Metric 'std.code.complexity:cyclomatic' for region 'A' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : A
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./test2.cpp:23: warning: Metric 'std.code.complexity/cyclomatic' for region 'main' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./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
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./test3.cpp:39: warning: Metric 'std.code.complexity/cyclomatic' for region 'doColor' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./test3.cpp:39: warning: Metric 'std.code.complexity:cyclomatic' for region 'doColor' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : doColor
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./test3.cpp:53: warning: Metric 'std.code.complexity/cyclomatic' for region 'doFont' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./test3.cpp:53: warning: Metric 'std.code.complexity:cyclomatic' for region 'doFont' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : doFont
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./test3.cpp:72: warning: Metric 'std.code.complexity/cyclomatic' for region 'doFont222' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./test3.cpp:72: warning: Metric 'std.code.complexity:cyclomatic' for region 'doFont222' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : doFont222
 	Metric value   : 2
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 

+ 48 - 32
mainline/tests/general/test_std_code_cs/test_parser_limit_default_stdout.gold.txt

@@ -1,128 +1,144 @@
-./File.cs:74: warning: Metric 'std.code.complexity/cyclomatic' for region 'get' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./File.cs:74: warning: Metric 'std.code.complexity:cyclomatic' for region 'get' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : get
 	Metric value   : 3
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./File.cs:95: warning: Metric 'std.code.complexity/cyclomatic' for region 'get' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./File.cs:95: warning: Metric 'std.code.complexity:cyclomatic' for region 'get' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : get
 	Metric value   : 2
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./File.cs:120: warning: Metric 'std.code.complexity/cyclomatic' for region 'get' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./File.cs:120: warning: Metric 'std.code.complexity:cyclomatic' for region 'get' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : get
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./File.cs:134: warning: Metric 'std.code.complexity/cyclomatic' for region 'get' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./File.cs:134: warning: Metric 'std.code.complexity:cyclomatic' for region 'get' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : get
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./File.cs:148: warning: Metric 'std.code.complexity/cyclomatic' for region 'get' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./File.cs:148: warning: Metric 'std.code.complexity:cyclomatic' for region 'get' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : get
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./File.cs:160: warning: Metric 'std.code.complexity/cyclomatic' for region 'Close' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./File.cs:160: warning: Metric 'std.code.complexity:cyclomatic' for region 'Close' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : Close
 	Metric value   : 4
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./File.cs:190: warning: Metric 'std.code.complexity/cyclomatic' for region 'SetRecord' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./File.cs:190: warning: Metric 'std.code.complexity:cyclomatic' for region 'SetRecord' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : SetRecord
 	Metric value   : 6
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./File.cs:245: warning: Metric 'std.code.complexity/cyclomatic' for region 'GetFile' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./File.cs:245: warning: Metric 'std.code.complexity:cyclomatic' for region 'GetFile' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : GetFile
 	Metric value   : 5
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./File.cs:277: warning: Metric 'std.code.complexity/cyclomatic' for region 'GetFile' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./File.cs:277: warning: Metric 'std.code.complexity:cyclomatic' for region 'GetFile' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : GetFile
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./File.cs:288: warning: Metric 'std.code.complexity/cyclomatic' for region 'AllocateFile' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./File.cs:288: warning: Metric 'std.code.complexity:cyclomatic' for region 'AllocateFile' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : AllocateFile
 	Metric value   : 5
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./File.cs:327: warning: Metric 'std.code.complexity/cyclomatic' for region 'FindFreeFile' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./File.cs:327: warning: Metric 'std.code.complexity:cyclomatic' for region 'FindFreeFile' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : FindFreeFile
 	Metric value   : 5
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./File.cs:361: warning: Metric 'std.code.complexity/cyclomatic' for region 'CloseAll' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./File.cs:361: warning: Metric 'std.code.complexity:cyclomatic' for region 'CloseAll' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : CloseAll
 	Metric value   : 4
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./File.cs:426: warning: Metric 'std.code.complexity/cyclomatic' for region 'Unlock' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./File.cs:426: warning: Metric 'std.code.complexity:cyclomatic' for region 'Unlock' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : Unlock
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./Generics.cs:50: warning: Metric 'std.code.complexity/cyclomatic' for region 'Grow' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./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
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./interface.cs:135: warning: Metric 'std.code.complexity/cyclomatic' for region 'Equals' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./interface.cs:135: warning: Metric 'std.code.complexity:cyclomatic' for region 'Equals' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : Equals
 	Metric value   : 1
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 
-./interface.cs:169: warning: Metric 'std.code.complexity/cyclomatic' for region 'ToTitleCase' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./interface.cs:169: warning: Metric 'std.code.complexity:cyclomatic' for region 'ToTitleCase' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : ToTitleCase
 	Metric value   : 4
 	Modified       : None
 	Change trend   : None
 	Limit          : 0.0
+	Suppressed     : False
 

+ 18 - 12
mainline/tests/general/test_std_code_java/test_parser_limit_default_stdout.gold.txt

@@ -1,48 +1,54 @@
-./ArrayUtils.java:59: warning: Metric 'std.code.complexity/cyclomatic' for region 'removeAt' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./ArrayUtils.java:59: warning: Metric 'std.code.complexity:cyclomatic' for region 'removeAt' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : removeAt
 	Metric value   : 6
 	Modified       : None
 	Change trend   : None
 	Limit          : 5.0
+	Suppressed     : False
 
-./ArrayUtils.java:84: warning: Metric 'std.code.complexity/cyclomatic' for region 'removeAt' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./ArrayUtils.java:84: warning: Metric 'std.code.complexity:cyclomatic' for region 'removeAt' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : removeAt
 	Metric value   : 6
 	Modified       : None
 	Change trend   : None
 	Limit          : 5.0
+	Suppressed     : False
 
-./ArrayUtils.java:120: warning: Metric 'std.code.complexity/cyclomatic' for region 'equalContents' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./ArrayUtils.java:120: warning: Metric 'std.code.complexity:cyclomatic' for region 'equalContents' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : equalContents
 	Metric value   : 6
 	Modified       : None
 	Change trend   : None
 	Limit          : 5.0
+	Suppressed     : False
 
-./ArrayUtils.java:140: warning: Metric 'std.code.complexity/cyclomatic' for region 'equals' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./ArrayUtils.java:140: warning: Metric 'std.code.complexity:cyclomatic' for region 'equals' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : equals
 	Metric value   : 6
 	Modified       : None
 	Change trend   : None
 	Limit          : 5.0
+	Suppressed     : False
 
-./ArrayUtils.java:177: warning: Metric 'std.code.complexity/cyclomatic' for region 'equals' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./ArrayUtils.java:177: warning: Metric 'std.code.complexity:cyclomatic' for region 'equals' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : equals
 	Metric value   : 6
 	Modified       : None
 	Change trend   : None
 	Limit          : 5.0
+	Suppressed     : False
 
-./BinaryHeapPriorityQueue.java:156: warning: Metric 'std.code.complexity/cyclomatic' for region 'heapifyDown' exceeds the limit.
-	Metric name    : std.code.complexity/cyclomatic
+./BinaryHeapPriorityQueue.java:156: warning: Metric 'std.code.complexity:cyclomatic' for region 'heapifyDown' exceeds the limit.
+	Metric name    : std.code.complexity:cyclomatic
 	Region name    : heapifyDown
 	Metric value   : 6
 	Modified       : None
 	Change trend   : None
 	Limit          : 5.0
+	Suppressed     : False
 

+ 22 - 10
mainline/tests/general/test_std_suppress.py

@@ -25,21 +25,33 @@ import tests.common
 
 class Test(tests.common.TestCase):
 
-    def test_parser(self):
+    def test_basic(self):
         
-        runner = tests.common.ToolRunner('collect', ['--std.code.complexity.cyclomatic'])
-        self.assertExec(runner.run())
-
-        runner = tests.common.ToolRunner('view')
-        self.assertExec(runner.run())
-        
-        dirs_list = [os.path.join('.', each) for each in os.listdir(self.get_content_paths().cwd)]
-        runner = tests.common.ToolRunner('view', opts_list=['--format=txt'], dirs_list=dirs_list, prefix='files')
+        runner = tests.common.ToolRunner('collect', ['--std.suppress',
+                                                     '--std.code.complexity.cyclomatic',
+                                                     '--std.code.length:size'])
         self.assertExec(runner.run())
 
         runner = tests.common.ToolRunner('limit',
                                          ['--max-limit=std.code.complexity:cyclomatic:0'],
-                                         exit_code=12)
+                                         exit_code=1)
+
+        runner = tests.common.ToolRunner('limit',
+                                         ['--max-limit=std.code.complexity:cyclomatic:0', '--disable-suppressions'],
+                                         exit_code=8)
+
+        runner = tests.common.ToolRunner('limit',
+                                         ['--max-limit=std.code.length:size:0'],
+                                         exit_code=7)
+
+        runner = tests.common.ToolRunner('limit',
+                                         ['--max-limit=std.code.length:size:0', '--disable-suppressions'],
+                                         exit_code=24)
+
+        runner = tests.common.ToolRunner('limit',
+                                         ['--max-limit=std.code.complexity:cyclomatic:0', '--max-limit=std.code.length:size:0'],
+                                         exit_code=8)
+        
         self.assertExec(runner.run())
 
 if __name__ == '__main__':

+ 21 - 21
mainline/tests/general/test_std_suppress/sources/test.c

@@ -1,10 +1,10 @@
 /* comment here per global region
  *
- *	metrix++:	suppress std.general:size
+ *	metrix++:	suppress std.code.length:size
  */
 
 
-/*metrix++: suppress	std.general:size*/
+/*metrix++: suppress	std.code.length:size*/
 int func()
 {
 	/* comment here */
@@ -12,25 +12,25 @@ int func()
 
 int func2()
 {
-	/*metrix++: suppress std.general:size*/
+	/*metrix++: suppress std.code.length:size*/
 }
 
-/* metrix++: suppress std.general:size */
+/* metrix++: suppress std.code.length:size */
 int func3()
 {
-	/* metrix++: suppress std.general:size*/
+	/* metrix++: suppress std.code.length:size*/
 }
 
 
 /* bla-bla */
-/* metrix++: suppress std.general:size */
+/* metrix++: suppress std.code.length:size */
 /* bla-bla */
 int func4()
 {
-	/* metrix++: suppress std.general:size*/
+	/* metrix++: suppress std.code.length:size*/
 }
 
-/* metrix++: suppress std.general:size */
+/* metrix++: suppress std.code.length:size */
 struct cl1
 {
 
@@ -38,12 +38,12 @@ struct cl1
 
 struct cl2
 {
-	/* metrix++: suppress std.general:size*/
+	/* metrix++: suppress std.code.length:size*/
 
 };
 
 // bla-bla
-//metrix++: suppress std.general:size
+//metrix++: suppress std.code.length:size
 // bla-bla
 struct cl3
 {
@@ -64,9 +64,9 @@ int nu_suppress_func()
 
 struct cl2
 {
-	/* metrix++: suppress std.general:size per class */
+	/* metrix++: suppress std.code.length:size per class */
 
-	/* metrix++: suppress std.general:size per function */
+	/* metrix++: suppress std.code.length:size per function */
 	int func4()
 	{
 
@@ -84,28 +84,28 @@ struct suppresed_for_invalid_metric
 
 };
 
-/* metrix++: suppress std.general:invlaid_metric */
+/* metrix++: suppress std.code.length:invlaid_metric */
 struct suppresed_for_invalid_metric
 {
 
 };
 
 /* metrix++: suppress invalid:metric */
-/* metrix++: suppress std.general:size */
+/* metrix++: suppress std.code.length:size */
 struct suppressed_for_size_and_invalid_metric
 {
 
 };
 
 /* metrix++: suppress invalid:metric */
-/* metrix++: suppress std.general:size */
+/* metrix++: suppress std.code.length:size */
 /* metrix++: suppress std.code.complexity:cyclomatic */
 int suppressed_for_size_and_complexity_and_invalid_metric()
 {
 	if (1) return;
 }
 
-// metrix++: suppress std.general:size asdas
+// metrix++: suppress std.code.length:size asdas
 // metrix++: suppress std.code.complexity:cyclomatic adsad
 int func7()
 {
@@ -118,13 +118,13 @@ int nu_suppress_for_size()
 	if (1) return;
 }
 
-// metrix++: suppress std.general:size adsad
+// metrix++: suppress std.code.length:size adsad
 int no_suppress_for_cyclomatic_complexity()
 {
 	if (1) return;
 }
 
-// metrix++: suppress std.general:size long-long
+// metrix++: suppress std.code.length:size long-long
 // description why it was suppressed
 // metrix++: suppress std.code.complexity:cyclomatic
 int func8()
@@ -132,7 +132,7 @@ int func8()
 	if (1) return;
 }
 
-/* metrix++: suppress std.general:size long-long */
+/* metrix++: suppress std.code.length:size long-long */
 /* description why it was suppressed */
 /* metrix++: suppress std.code.complexity:cyclomatic */
 int func9()
@@ -143,12 +143,12 @@ int func9()
 // metrix++: suppress std.code.complexity:cyclomatic adsad
 int bad_suppress_for_size()
 {
-	// metrix++: suppress std.general:size
+	// metrix++: suppress std.code.length:size
 
 	if (1) return;
 }
 
-/* metrix++: suppress std.general:size long-long
+/* metrix++: suppress std.code.length:size long-long
  * description why it was suppressed
  * metrix++: suppress std.code.complexity:cyclomatic */
 int func10()

+ 2 - 2
mainline/tools/info.py

@@ -64,8 +64,8 @@ def main(tool_args):
         print "\t" + each.name + "\t=>\t" + each.value + prev_value_str
 
     print "\nMetrics:"
-    for each in loader.iterate_namespace_names():
-        for field in loader.get_namespace(each).iterate_field_names():
+    for each in sorted(loader.iterate_namespace_names()):
+        for field in sorted(loader.get_namespace(each).iterate_field_names()):
             prev_value_str = ""
             if loader_prev != None:
                 prev = None

+ 47 - 20
mainline/tools/limit.py

@@ -47,12 +47,16 @@ def main(tool_args):
     parser.add_option("--hotspots", "--hs", default=None, help="If not set (none), all exceeded limits are printed."
                       " If set, exceeded limits are sorted (the worst is the first) and only first HOTSPOTS limits are printed."
                       " [default: %default]", type=int)
+    parser.add_option("--disable-suppressions", "--ds", action="store_true", default=False,
+                      help = "If not set (none), all suppressions are ignored"
+                             " and associated warnings are printed. [default: %default]")
 
     (options, args) = parser.parse_args(tool_args)
     log_plugin.configure(options)
     db_plugin.configure(options)
     warn_plugin.configure(options)
     hotspots = options.__dict__['hotspots']
+    no_suppress = options.__dict__['disable_suppressions']
 
     loader_prev = core.db.loader.Loader()
     if db_plugin.dbfile_prev != None:
@@ -132,22 +136,32 @@ def main(tool_args):
                             diff = core.db.loader.DiffData(select_data,
                                                            file_data_prev.get_region(prev_id)).get_data(limit.namespace, limit.field)
 
-                if warn_plugin.is_mode_matched(limit.limit, select_data.get_data(limit.namespace, limit.field), diff, is_modified):
-                    exit_code += 1
-                    region_cursor = 0
-                    region_name = ""
-                    if select_data.get_region() != None:
-                        region_cursor = select_data.get_region().cursor
-                        region_name = select_data.get_region().name
-                    report_limit_exceeded(select_data.get_path(),
-                                      region_cursor,
-                                      limit.namespace,
-                                      limit.field,
-                                      region_name,
-                                      select_data.get_data(limit.namespace, limit.field),
-                                      diff,
-                                      limit.limit,
-                                      is_modified)
+                if (warn_plugin.is_mode_matched(limit.limit,
+                                                select_data.get_data(limit.namespace, limit.field),
+                                                diff,
+                                                is_modified) == False):
+                    continue
+                
+                is_sup = is_metric_suppressed(limit.namespace, limit.field, loader, select_data)
+                if is_sup == True and no_suppress == False:
+                    continue    
+                
+                exit_code += 1
+                region_cursor = 0
+                region_name = ""
+                if select_data.get_region() != None:
+                    region_cursor = select_data.get_region().cursor
+                    region_name = select_data.get_region().name
+                report_limit_exceeded(select_data.get_path(),
+                                  region_cursor,
+                                  limit.namespace,
+                                  limit.field,
+                                  region_name,
+                                  select_data.get_data(limit.namespace, limit.field),
+                                  diff,
+                                  limit.limit,
+                                  is_modified,
+                                  is_sup)
     return exit_code
 
 
@@ -176,14 +190,27 @@ def get_list_of_modified_files(loader, loader_prev):
     
     return None
 
-def report_limit_exceeded(path, cursor, namespace, field, region_name, stat_level, trend_value, stat_limit, is_modified):
-    message = "Metric '" + namespace + "/" + field + "' for region '" + region_name + "' exceeds the limit."
-    details = [("Metric name", namespace + "/" + field),
+def is_metric_suppressed(metric_namespace, metric_field, loader, select_data):
+    data = loader.load_file_data(select_data.get_path())
+    if select_data.get_region() != None:
+        data = data.get_region(select_data.get_region().get_id())
+    
+    sup_data = data.get_data('std.suppress', 'list')
+    if sup_data != None and sup_data.find('[' + metric_namespace + ':' + metric_field + ']') != -1:
+        return True
+    return False
+
+def report_limit_exceeded(path, cursor, namespace, field, region_name,
+                          stat_level, trend_value, stat_limit,
+                          is_modified, is_suppressed):
+    message = "Metric '" + namespace + ":" + field + "' for region '" + region_name + "' exceeds the limit."
+    details = [("Metric name", namespace + ":" + field),
                ("Region name", region_name),
                ("Metric value", stat_level),
                ("Modified", is_modified),
                ("Change trend", '{0:{1}}'.format(trend_value, '+' if trend_value else '')),
-               ("Limit", stat_limit)]
+               ("Limit", stat_limit),
+               ("Suppressed", is_suppressed)]
     core.export.cout.cout(path, cursor, core.export.cout.SEVERITY_WARNING, message, details)