feat(stats): moved linter stats to be appended to lint output

closes #396
This commit is contained in:
Christopher Pickering 2022-09-20 08:34:58 +02:00
parent 190ad01ff3
commit 90f023d325
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84

View file

@ -34,22 +34,17 @@ def print_output(
if config.stdin is False or config.lint:
echo()
if config.statistics:
lint_error_count = build_stats_output(
[x.get("lint_message") for x in file_errors], config
)
for error in sorted(file_errors, key=lambda x: next(iter(list(x.values())[0]))):
if error.get("format_message") and config.stdin is False:
# reformat message
format_error_count += build_check_output(error["format_message"], config)
else:
for error in sorted(file_errors, key=lambda x: next(iter(list(x.values())[0]))):
if error.get("format_message") and config.stdin is False:
# reformat message
format_error_count += build_check_output(
error["format_message"], config
)
if error.get("lint_message"):
# lint message
lint_error_count += build_output(error["lint_message"], config)
if error.get("lint_message"):
# lint message
lint_error_count += build_output(error["lint_message"], config)
if config.statistics and config.lint:
build_stats_output([x.get("lint_message") for x in file_errors], config)
tense_message = (
build_quantity(format_error_count) + " would be"
@ -206,6 +201,14 @@ def build_stats_output(errors: List[Optional[Any]], config: Config) -> int:
rule["rule"]["name"]: rule["rule"]["message"] for rule in config.linter_rules
}
echo()
width, _ = shutil.get_terminal_size()
echo(
f"{Fore.GREEN}{Style.BRIGHT}Statistics{Style.RESET_ALL}\n{Style.DIM}"
+ "".join(["" for x in range(1, width)])
+ Style.RESET_ALL
)
if messages and codes:
longest_code = len(max(messages.keys(), key=len))