Simplify coloring of mccabe.
Just color lines with greater than 10 complexity.
This commit is contained in:
parent
721cc28d03
commit
c72a163cfc
2 changed files with 4 additions and 5 deletions
2
TODO
2
TODO
|
|
@ -16,7 +16,6 @@ Todo
|
||||||
- Determine if perl files are perl5 or perl6.
|
- Determine if perl files are perl5 or perl6.
|
||||||
- Use perldoc on pod files.
|
- Use perldoc on pod files.
|
||||||
- Add rich LSCOLORS if the environment variable is not set.
|
- 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.
|
- Add bandit tool for python.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -155,6 +154,7 @@ Done
|
||||||
- Add means to pause and unpause all current jobs.
|
- Add means to pause and unpause all current jobs.
|
||||||
- Colourise mccabe.
|
- Colourise mccabe.
|
||||||
- Have a sandbox for unsafe (or all) tools.
|
- 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-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
|
A B C D E F G H
|
||||||
|
|
|
||||||
7
tools.py
7
tools.py
|
|
@ -340,10 +340,10 @@ def _get_mccabe_line_score(line, python_version):
|
||||||
return int(score if python_version == "python3" else score[:-1])
|
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("", [
|
return fill3.join("", [
|
||||||
termstr.TermStr(line).fg_color(termstr.Color.yellow)
|
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)])
|
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)
|
max_score = max(_get_mccabe_line_score(line, python_version)
|
||||||
for line in stdout.splitlines())
|
for line in stdout.splitlines())
|
||||||
status = Status.failure if max_score > 10 else Status.success
|
status = Status.failure if max_score > 10 else Status.success
|
||||||
return status, fill3.Text(
|
return status, fill3.Text(_colorize_mccabe(stdout, python_version))
|
||||||
_colorize_mccabe(stdout, python_version, max_score))
|
|
||||||
python_mccabe.dependencies = {"python-mccabe", "python3-mccabe"}
|
python_mccabe.dependencies = {"python-mccabe", "python3-mccabe"}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue