diff options
author | hippo91 <guillaume.peillex@gmail.com> | 2021-04-08 15:27:58 +0200 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-04-09 18:45:30 +0200 |
commit | 526780f276f26a10b8d91321b96dbac32f7bf889 (patch) | |
tree | 29eff7555e08f29595f4feacd229e4c407ba0397 /pylint/checkers/raw_metrics.py | |
parent | 5e1928b325bc798f5be1ab94031bf6816d058d9f (diff) | |
download | pylint-git-526780f276f26a10b8d91321b96dbac32f7bf889.tar.gz |
Revert "Refactor - Remove unused and untested code in utils"
This reverts commit 293a7f5e6add850e2f127dd1680a6e43fb1a6949.
Diffstat (limited to 'pylint/checkers/raw_metrics.py')
-rw-r--r-- | pylint/checkers/raw_metrics.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/pylint/checkers/raw_metrics.py b/pylint/checkers/raw_metrics.py index b713c4bf6..bb3a519d4 100644 --- a/pylint/checkers/raw_metrics.py +++ b/pylint/checkers/raw_metrics.py @@ -20,10 +20,12 @@ from pylint.checkers import BaseTokenChecker from pylint.exceptions import EmptyReportError from pylint.interfaces import ITokenChecker from pylint.reporters.ureports.nodes import Table +from pylint.utils import diff_string -def report_raw_stats(sect, stats, _): - """calculate percentage of code / doc / comment / empty""" +def report_raw_stats(sect, stats, old_stats): + """calculate percentage of code / doc / comment / empty + """ total_lines = stats["total_lines"] if not total_lines: raise EmptyReportError() @@ -33,7 +35,12 @@ def report_raw_stats(sect, stats, _): key = node_type + "_lines" total = stats[key] percent = float(total * 100) / total_lines - lines += (node_type, str(total), "%.2f" % percent, "NC", "NC") + old = old_stats.get(key, None) + if old is not None: + diff_str = diff_string(old, total) + else: + old, diff_str = "NC", "NC" + lines += (node_type, str(total), "%.2f" % percent, str(old), diff_str) sect.append(Table(children=lines, cols=5, rheaders=1)) |