Browse Source

bug fixes.

avkonst 11 years ago
parent
commit
cf6b4ec5b6

+ 1 - 1
mainline/doc/home.html

@@ -307,7 +307,7 @@ file: __global__: comment
               </tr>
               <tr>
                 <td>std.code.lines.code</td>
-                <td>Number of non-blank lines of code excluding preprocessor, comments and strings.</td>
+                <td>Number of non-blank lines of code excluding preprocessor and comments.</td>
                 <td></td>
               </tr>
               <tr>

+ 2 - 1
mainline/ext/std/code/lines.py

@@ -52,7 +52,8 @@ class Plugin(mpp.api.Plugin, mpp.api.SimpleMetricMixin, mpp.api.Child, mpp.api.I
         self.declare_metric(self.is_active_code,
                        self.Field('code', int),
                        self.pattern_line,
-                       mpp.api.Marker.T.CODE)
+                       mpp.api.Marker.T.CODE | mpp.api.Marker.T.STRING,
+                       merge_markers=True)
         self.declare_metric(self.is_active_preprocessor,
                        self.Field('preprocessor', int),
                        self.pattern_line,

+ 7 - 0
mainline/ext/std/tools/info.py

@@ -22,6 +22,8 @@ import mpp.api
 import mpp.cout
 import mpp.utils
 
+import os
+
 class Plugin(mpp.api.Plugin, mpp.api.IRunable):
     
     def run(self, args):
@@ -41,6 +43,11 @@ class Plugin(mpp.api.Plugin, mpp.api.IRunable):
                     prev_value_str = " [modified (was: " + loader_prev.get_property(each.name) + ")]"
             details.append((each.name, each.value + prev_value_str))
         path = self.get_plugin_loader().get_plugin('mpp.dbf').get_dbfile_path()
+        if ('METRIXPLUSPLUS_TEST_MODE' in os.environ.keys() and
+             os.environ['METRIXPLUSPLUS_TEST_MODE'] == "True"):
+            # in tests, paths come as full paths, strip it for consistent gold files
+            # TODO: if there are other path-like arguments, it is better to think about other solution
+            path = os.path.basename(path)
         mpp.cout.notify(path, '', mpp.cout.SEVERITY_INFO, 'Created using plugins and settings:', details)
     
         details = []

+ 10 - 1
mainline/ext/std/tools/limit.py

@@ -69,11 +69,15 @@ def main(plugin, args):
                 filters.append(('file_id', 'IN', modified_file_ids))
             sort_by = None
             limit_by = None
+            limit_warnings = None
             if plugin.hotspots != None:
                 sort_by = limit.field
                 if limit.type == "max":
                     sort_by = "-" + sort_by
-                limit_by = plugin.hotspots
+                if warn_plugin.mode == warn_plugin.MODE_ALL:
+                    # if it is not ALL mode, the tool counts number of printed warnings below
+                    limit_by = plugin.hotspots
+                limit_warnings = plugin.hotspots
             selected_data = loader.load_selected_data(limit.namespace,
                                                    fields = [limit.field],
                                                    path=path,
@@ -86,6 +90,9 @@ def main(plugin, args):
                 continue
             
             for select_data in selected_data:
+                if limit_warnings != None and limit_warnings <= 0:
+                    break
+                
                 is_modified = None
                 diff = None
                 file_data = loader.load_file_data(select_data.get_path())
@@ -131,6 +138,8 @@ def main(plugin, args):
                                   limit.limit,
                                   is_modified,
                                   is_sup)
+                if limit_warnings != None:
+                    limit_warnings -= 1
     return exit_code
 
 

+ 2 - 0
mainline/ext/std/tools/view.py

@@ -296,6 +296,8 @@ def compress_dist(data, columns):
                     next_bar = None
                     # check that consumed all
                     assert((ind + 1) != len(distr) or remaining_count == 0)
+                    if remaining_count == 0:
+                        break
 
             if (float(max_count - min_count) / metric_data['count'] < 0.05 and
                 metric_data['count'] > 1 and

+ 0 - 1
mainline/mpp/api.py

@@ -194,7 +194,6 @@ class Marker(object):
         STRING          = 0x02
         PREPROCESSOR    = 0x04
         CODE            = 0x08
-        ALL_EXCEPT_CODE = 0x07
         ANY             = 0xFF
 
         def to_str(self, group):

+ 2 - 2
mainline/tests/general/test_basic/test_workflow_info_default_stdout.gold.txt

@@ -1,4 +1,4 @@
-D:\Projects\Metrix++\tests\general\test_basic\test_workflow.db:: info: Created using plugins and settings:
+test_workflow.db:: info: Created using plugins and settings:
 	version        : 1.0
 	std.code.complexity:version: 1.1
 	std.code.cpp:version: 1.1
@@ -8,7 +8,7 @@ D:\Projects\Metrix++\tests\general\test_basic\test_workflow.db:: info: Created u
 	std.code.java:version: 1.1
 	std.code.java:files: *.java
 
-D:\Projects\Metrix++\tests\general\test_basic\test_workflow.db:: info: Collected metrics:
+test_workflow.db:: info: Collected metrics:
 	std.code.complexity:cyclomatic: 
 
 :: info: Processed files and checksums:

+ 2 - 2
mainline/tests/general/test_basic/test_workflow_info_second_stdout.gold.txt

@@ -1,4 +1,4 @@
-D:\Projects\Metrix++\tests\general\test_basic\test_workflow.db:: info: Created using plugins and settings:
+test_workflow.db:: info: Created using plugins and settings:
 	version        : 1.0
 	std.code.complexity:version: 1.1
 	std.code.cpp:version: 1.1
@@ -8,7 +8,7 @@ D:\Projects\Metrix++\tests\general\test_basic\test_workflow.db:: info: Created u
 	std.code.java:version: 1.1
 	std.code.java:files: *.java
 
-D:\Projects\Metrix++\tests\general\test_basic\test_workflow.db:: info: Collected metrics:
+test_workflow.db:: info: Collected metrics:
 	std.code.complexity:cyclomatic: 
 
 :: info: Processed files and checksums: