diff --git a/TODO b/TODO index eaaedaa..01fab2c 100644 --- a/TODO +++ b/TODO @@ -16,7 +16,6 @@ Todo - Determine if perl files are perl5 or perl6. - Use perldoc on pod files. - Add rich LSCOLORS if the environment variable is not set. -- Simplify coloring of mccabe. Just color functions with complexity greater than 10. - Add bandit tool for python. @@ -155,6 +154,7 @@ Done - Add means to pause and unpause all current jobs. - Colourise mccabe. - Have a sandbox for unsafe (or all) tools. +- Simplify coloring of mccabe. Just color functions with complexity greater than 10. A-syntax, B-tests, C-auto docs, D-lint, E-coverage, F-profile, G-tidy, H-import deps A B C D E F G H diff --git a/tools.py b/tools.py index 7083971..502c0bc 100644 --- a/tools.py +++ b/tools.py @@ -340,10 +340,10 @@ def _get_mccabe_line_score(line, python_version): return int(score if python_version == "python3" else score[:-1]) -def _colorize_mccabe(text, python_version, max_score): +def _colorize_mccabe(text, python_version): return fill3.join("", [ termstr.TermStr(line).fg_color(termstr.Color.yellow) - if _get_mccabe_line_score(line, python_version) == max_score else line + if _get_mccabe_line_score(line, python_version) > 10 else line for line in text.splitlines(keepends=True)]) @@ -355,8 +355,7 @@ def python_mccabe(path): max_score = max(_get_mccabe_line_score(line, python_version) for line in stdout.splitlines()) status = Status.failure if max_score > 10 else Status.success - return status, fill3.Text( - _colorize_mccabe(stdout, python_version, max_score)) + return status, fill3.Text(_colorize_mccabe(stdout, python_version)) python_mccabe.dependencies = {"python-mccabe", "python3-mccabe"}