DataViews/CodeMetrics.py

changeset 4425
2f51c66b3120
parent 4021
195a471c327b
child 4566
a2e8f3c420ec
child 4632
ca310db386ed
--- a/DataViews/CodeMetrics.py	Thu Sep 03 18:38:19 2015 +0200
+++ b/DataViews/CodeMetrics.py	Thu Sep 03 19:15:51 2015 +0200
@@ -244,9 +244,13 @@
             stats.inc('nloc')
         elif tok.type == COMMENT:
             stats.inc('comments')
+            if tok.line.strip() == tok.text:
+                stats.inc('commentlines')
         elif tok.type == EMPTY:
             if parser.tokenlist[idx - 1].type == token.OP:
                 stats.inc('nloc')
+            elif parser.tokenlist[idx - 1].type == COMMENT:
+                continue
             else:
                 stats.inc('empty')
         elif tok.type == INDENT:
@@ -261,6 +265,8 @@
     summarize(total, 'lines', parser.lines)
     summarize(total, 'bytes', len(text))
     summarize(total, 'comments', stats.getCounter('TOTAL ', 'comments'))
+    summarize(total, 'commentlines',
+              stats.getCounter('TOTAL ', 'commentlines'))
     summarize(total, 'empty lines', stats.getCounter('TOTAL ', 'empty'))
     summarize(total, 'non-commentary lines',
               stats.getCounter('TOTAL ', 'nloc'))

eric ide

mercurial