Browse Source

fixed test and improved docs

avkonst 11 years ago
parent
commit
4b68b9536b

+ 16 - 1
mainline/doc/home.html

@@ -322,9 +322,24 @@ file: __global__: comment
               <tr>
               <tr>
                 <td>std.code.complexity.cyclomatic</td>
                 <td>std.code.complexity.cyclomatic</td>
                 <td>McCabe cyclomatic complexity metric.</td>
                 <td>McCabe cyclomatic complexity metric.</td>
-                <td><ul><li>Identification of highly complex code for review and refactoring.</li>
+                <td colspan="2"><ul><li>Identification of highly complex code for review and refactoring.</li>
                     <li>Preventing complex functions (complexity is a reason of many defects and a reason of expensive maintaintenance).</li></ul></td>
                     <li>Preventing complex functions (complexity is a reason of many defects and a reason of expensive maintaintenance).</li></ul></td>
               </tr>
               </tr>
+              <tr>
+                <td>std.code.complexity.maxindent</td>
+                <td>Maximum level of indentation of blocks within a region. For example, the following class has got 
+                	the metric equal to 1 and the function has got it equal to 2:
+                	<pre class="prettyprint">
+class WeekClass {
+  int isWeekend(int day) {
+    if (day == 6 || day == 7) {
+      return true;
+    }
+    return false;
+}
+</pre>
+                	</td>
+              </tr>
               <tr>
               <tr>
                 <td>std.suppress</td>
                 <td>std.suppress</td>
                 <td>An option enables collection of Metrix++ suppressions and 2 metrics: 'std.suppress:count' and 
                 <td>An option enables collection of Metrix++ suppressions and 2 metrics: 'std.suppress:count' and 

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

@@ -86,10 +86,10 @@ class Plugin(mpp.api.Plugin, mpp.api.MetricPluginMixin, mpp.api.Child, mpp.api.I
             self.count_if_active('cyclomatic', data, alias=alias)
             self.count_if_active('cyclomatic', data, alias=alias)
             self.count_if_active('maxindent', data, alias=alias)
             self.count_if_active('maxindent', data, alias=alias)
 
 
-    def _maxindent_count_initialize(self, data, alias):
+    def _maxindent_count_initialize(self, data, alias, region):
         return (0, {'cur_level': 0})
         return (0, {'cur_level': 0})
     
     
-    def _maxindent_count(self, data, alias, text, begin, end, m, count, counter_data):
+    def _maxindent_count(self, data, alias, text, begin, end, m, count, counter_data, region, marker):
         if m.group(0) == '{':
         if m.group(0) == '{':
             counter_data['cur_level'] += 1
             counter_data['cur_level'] += 1
             if counter_data['cur_level'] > count:
             if counter_data['cur_level'] > count:

+ 2 - 2
mainline/mpp/api.py

@@ -1145,7 +1145,7 @@ class MetricPluginMixin(object):
                 counter_data = {}
                 counter_data = {}
                 count = 0
                 count = 0
                 if hasattr(self, '_' + metric_name + '_count_initialize'):
                 if hasattr(self, '_' + metric_name + '_count_initialize'):
-                    (count, counter_data) = self.__getattribute__('_' + metric_name + '_count_initialize')(data, alias)
+                    (count, counter_data) = self.__getattribute__('_' + metric_name + '_count_initialize')(data, alias, region)
                 for marker in data.iterate_markers(
                 for marker in data.iterate_markers(
                                 filter_group = field_data[1],
                                 filter_group = field_data[1],
                                 region_id = region.get_id(),
                                 region_id = region.get_id(),
@@ -1154,7 +1154,7 @@ class MetricPluginMixin(object):
                     begin = marker.get_offset_begin()
                     begin = marker.get_offset_begin()
                     end = marker.get_offset_end()
                     end = marker.get_offset_end()
                     for m in pattern_to_search.finditer(text, begin, end):
                     for m in pattern_to_search.finditer(text, begin, end):
-                        count = counter_callback(data, alias, text, begin, end, m, count, counter_data)
+                        count = counter_callback(data, alias, text, begin, end, m, count, counter_data, region, marker)
                 region.set_data(namespace, metric_name, count)
                 region.set_data(namespace, metric_name, count)
         else:
         else:
             for region in data.iterate_regions(filter_group=field_data[5]):
             for region in data.iterate_regions(filter_group=field_data[5]):

+ 0 - 7
mainline/tests/system/test_boost_parts.py

@@ -84,13 +84,6 @@ class Test(tests.common.TestCase):
                                          use_prev=True)
                                          use_prev=True)
         self.assertExec(runner.run())
         self.assertExec(runner.run())
 
 
-        runner = tests.common.ToolRunner('limit',
-                                         ['--log-level=INFO',
-                                          '--max-limit=std.code.complexity:cyclomatic:15'],
-                                         check_stderr=[(0, -1)],
-                                         exit_code=9)
-        self.assertExec(runner.run())
-
         runner = tests.common.ToolRunner('limit',
         runner = tests.common.ToolRunner('limit',
                                          ['--log-level=INFO',
                                          ['--log-level=INFO',
                                           '--max-limit=std.code.complexity:cyclomatic:15',
                                           '--max-limit=std.code.complexity:cyclomatic:15',