Prechádzať zdrojové kódy

Few more TODOs and improved context help.

avkonst 12 rokov pred
rodič
commit
81bf06b4b4

+ 4 - 1
mainline/core/db/post.py

@@ -28,7 +28,10 @@ class Plugin(core.api.Plugin, core.api.IConfigurable):
         parser.add_option("--general.db-file", default='./metrixpp.db',
                          help="Primary database file to write (by the collector) and post-process (by other tools) [default: %default]")
         parser.add_option("--general.db-file-prev", default=None,
-                         help="Database file with data collected for the past/previous revision [default: %default].")
+                         help="Database file with data collected for the past/previous revision."
+                             " If it is set for the collector tool to perform an incremental/iterative collection,"
+                             " it may reduce the processing time significantly."
+                             " Post-processing tools use it in order to recognise/evaluate change trends. [default: %default].")
     
     def configure(self, options):
         self.dbfile = options.__dict__['general.db_file']

+ 2 - 0
mainline/core/dir.py

@@ -56,6 +56,8 @@ class Plugin(core.api.Plugin, core.api.Parent, core.api.IConfigurable, core.api.
             self.reader.run(self, directory)
         
     def add_exclude_rule(self, re_compiled_pattern):
+        # TODO file name may have special regexp symbols what causes an exception
+        # For example try to run a collection with "--general.db-file=metrix++" option
         self.exclude_rules.append(re_compiled_pattern)
         
     def is_file_excluded(self, file_name):

+ 14 - 3
mainline/core/warn.py

@@ -33,16 +33,24 @@ class Plugin(core.api.Plugin, core.api.IConfigurable):
         self.parser = parser
         parser.add_option("--general.warn", default='all', choices=['new', 'trend', 'touched', 'all'],
                          help="Defines the warnings mode. "
-                         "'off' - no warnings, 'new' - warnings for new regions only, "
+                         "'new' - warnings for new regions only, "
                          "'trend' - warnings for new regions and for bad trend of modified regions, "
                          "'touched' - warnings for new regions and modified regions, "
                          "'all' - all warnings active"
                          "[default: %default]")
 
         parser.add_option("--general.min-limit", action="multiopt",
-                          help='TBD')
+                          help="A threshold per 'namespace:field' metric in order to select regions, "
+                          "which have got metric value less than the specified limit. "
+                          "This option can be specified multiple times, if it is necessary to apply several limits. "
+                          "Should be in the format: <namespace>:<field>:<limit-value>, for example: "
+                          "'std.code.complexity:cyclomatic:7'.") # TODO think about better example
         parser.add_option("--general.max-limit", action="multiopt",
-                          help='TBD')
+                          help="A threshold per 'namespace:field' metric in order to select regions, "
+                          "which have got metric value more than the specified limit. "
+                          "This option can be specified multiple times, if it is necessary to apply several limits. "
+                          "Should be in the format: <namespace>:<field>:<limit-value>, for example: "
+                          "'std.code.complexity:cyclomatic:7'.")
         
     def configure(self, options):
         if options.__dict__['general.warn'] == 'new':
@@ -53,6 +61,9 @@ class Plugin(core.api.Plugin, core.api.IConfigurable):
             self.mode = self.MODE_TOUCHED
         elif options.__dict__['general.warn'] == 'all':
             self.mode = self.MODE_ALL
+            
+        if self.mode != self.MODE_ALL and options.__dict__['general.db-file-prev'] == None:
+            self.parser.error("The mode '" + options.__dict__['general.warn'] + "' for 'general.warn' option requires 'general.db-file-prev' option set")
 
         class Limit(object):
             def __init__(self, limit_type, limit, namespace, field, db_filter):

+ 2 - 1
mainline/export.py

@@ -39,7 +39,8 @@ def main():
     parser = core.cmdparser.MultiOptionParser(usage="Usage: %prog [options] -- <path 1> ... <path N>")
     log_plugin.declare_configuration(parser)
     db_plugin.declare_configuration(parser)
-    parser.add_option("--general.format", default='xml', choices=['txt', 'xml', 'python'], help="Format of the output data [default: %default]")
+    parser.add_option("--general.format", default='xml', choices=['txt', 'xml', 'python'], help="Format of the output data. "
+                      "Possible values are 'xml', 'txt' or 'python' [default: %default]")
     parser.add_option("--general.namespaces", default=None, help="Allows to enumerate namespaces of interest."
                       " If not defined all namespaces available in database file will be processed."
                       " Separate several namespaces by comma, for example 'general,std.code.complexity'"

+ 1 - 1
mainline/ext/std/code/complexity.py

@@ -25,7 +25,7 @@ class Plugin(core.api.Plugin, core.api.Child, core.api.IConfigurable):
     
     def declare_configuration(self, parser):
         parser.add_option("--std.code.complexity.on", action="store_true", default=False,
-                         help="Enables processing of complexity metrics: cyclomatic by McCabe [default: %default]")
+                         help="Enables collection of complexity metrics: cyclomatic by McCabe [default: %default]")
     
     def configure(self, options):
         self.is_active = options.__dict__['std.code.complexity.on']

+ 2 - 0
mainline/limit.py

@@ -105,6 +105,8 @@ def main():
                                 is_modified = False
                             diff = core.db.loader.DiffData(select_data,
                                                            file_data_prev.get_region(prev_id)).get_data(limit.namespace, limit.field)
+                            # TODO if diff is None, probably need to warn about this
+                            # a user may expect data available
 
                 if warn_plugin.is_mode_matched(limit.limit, select_data.get_data(limit.namespace, limit.field), diff, is_modified):
                     exit_code += 1