From 08d981715cfd7c8da5bcae726b81f56aa8b60548 Mon Sep 17 00:00:00 2001 From: Alexis Date: Mon, 15 Apr 2024 15:54:32 +0200 Subject: [PATCH] Fix the description of the Loc printer, and adjust the maximal width. --- slither/printers/summary/loc.py | 4 ++-- slither/utils/command_line.py | 4 +++- slither/utils/myprettytable.py | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/slither/printers/summary/loc.py b/slither/printers/summary/loc.py index 35bb20fc4b..886803e8e2 100644 --- a/slither/printers/summary/loc.py +++ b/slither/printers/summary/loc.py @@ -17,8 +17,8 @@ class LocPrinter(AbstractPrinter): ARGUMENT = "loc" - HELP = """Count the total number lines of code (LOC), source lines of code (SLOC), \ - and comment lines of code (CLOC) found in source files (SRC), dependencies (DEP), \ + HELP = """Count the total number lines of code (LOC), source lines of code (SLOC), + and comment lines of code (CLOC) found in source files (SRC), dependencies (DEP), and test files (TEST).""" WIKI = "https://github.com/trailofbits/slither/wiki/Printer-documentation#loc" diff --git a/slither/utils/command_line.py b/slither/utils/command_line.py index 330de58baa..21d136a36e 100644 --- a/slither/utils/command_line.py +++ b/slither/utils/command_line.py @@ -396,8 +396,10 @@ def output_printers(printer_classes: List[Type[AbstractPrinter]]) -> None: printers_list = sorted(printers_list, key=lambda element: (element[0])) idx = 1 for (argument, help_info) in printers_list: - table.add_row([str(idx), argument, help_info]) + # Clean multi line HELP info + table.add_row([str(idx), argument, " ".join(x.strip() for x in help_info.splitlines())]) idx = idx + 1 + print(table) diff --git a/slither/utils/myprettytable.py b/slither/utils/myprettytable.py index c34a4035df..ab26e358a6 100644 --- a/slither/utils/myprettytable.py +++ b/slither/utils/myprettytable.py @@ -31,7 +31,8 @@ def __init__( # In this case, we fall back to the default behavior (i.e. printing as much as possible) terminal_column = get_terminal_size((0, 0)).columns if terminal_column != 0: - self.max_width = terminal_column - 2 + # We reduce slightly the max-width to take into account inconsistencies in terminals + self.max_width = terminal_column - 3 else: self.max_width = max_width