def _print_error_message(self, violation: Violation) -> str: tool_id = f"{violation.tool_id}".strip() rule = f"{violation.check_id}".strip() link = render_link(rule, violation.link) return f"{Clippy.BOLD}{tool_id} {link}{Clippy.END}"
def _render_hit(self, hit: Hit, max_count: int, check_width: int) -> str: bar_width = (PRINT_WIDTH - check_width - 10 ) # 5 for check, 5 for fixed characters check_str = click.style( render_link( hit.check_id[:check_width], href=hit.link, print_alternative=False, width=check_width, )) count_str = click.style(f"{hit.count:>5d}", dim=True) bar = click.style(Histo._render_bar(hit.count, max_count, bar_width), dim=True) return f" {check_str} {count_str}{bar}"
def __print_error_message(self, violation: Violation) -> str: tool_id = f"{violation.tool_id}".strip() rule = f"{violation.check_id}".strip() full_rule = f"{tool_id}.{rule}" if not violation.link: link = full_rule else: link = render_link(full_rule, violation.link) sev_str = Clippy.SEVERITY_STR.get(violation.severity, "unknown") sev = f"{sev_str}".strip() return f"{Clippy.BOLD}{sev}: {Clippy.BOLD}{link}{Clippy.END}"
def __print_violation(self, violation: Violation, max_message_len: int) -> str: line = f"{violation.line:>3d}" col = f"{violation.column:<2d}" tool_id = f"{violation.tool_id:<14s}" rule = f"{violation.check_id:s}" message = Formatter.ellipsis_trim(violation.message, max_message_len) # save some space for what comes next message = f"{message:<{max_message_len}s}" if not violation.link: link = rule else: link = render_link(rule, violation.link) sev_str = Stylish.SEVERITY_STR.get(violation.severity, "unknown") sev = f"{sev_str:<7s}" return f"{line}:{col} {sev} {message} {tool_id} {link}"
def __print_violation(self, violation: Violation) -> List[str]: message_len = max(Stylish.TERM_WIDTH - 50, 40) line = f"{violation.line:>4d}" col = f"{violation.column:<2d}" tool_id = f"{violation.tool_id:<14s}" rule = f"{violation.check_id:s}" message = textwrap.wrap(violation.message.strip(), message_len) if not violation.link: link = rule else: link = render_link(rule, violation.link) out = [ f"{line}:{col} {click.style(message[0], dim=True):<{message_len + 2 * ANSI_WIDTH}s} {tool_id} {link}" ] for m in message[1:]: out.append( f" {click.style(m, dim=True):<{message_len + 2 * ANSI_WIDTH}s}" ) return out