Skip to content

Commit

Permalink
No need to check for suppressions (#126)
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Brown <[email protected]>
  • Loading branch information
ericwb authored Aug 16, 2023
1 parent 7e6bb6e commit 9268705
Showing 1 changed file with 38 additions and 39 deletions.
77 changes: 38 additions & 39 deletions precli/renderers/detailed.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,45 +65,44 @@ def render(self, results: list[Result], metrics: Metrics):
)
self.console.print(code)

if not result.suppression:
for fix in result.fixes:
self.console.print(
f"Suggested fix: {fix.description}",
style=style,
)
start_line = fix.deleted_location.start_line
end_line = fix.deleted_location.end_line
start_column = fix.deleted_location.start_column
end_column = fix.deleted_location.end_column
line_before = linecache.getline(
filename=result.location.file_name,
lineno=start_line - 1,
)
code = linecache.getline(
filename=result.location.file_name,
lineno=start_line,
)
line_after = linecache.getline(
filename=result.location.file_name,
lineno=start_line + 1,
)
code = (
code[:start_column]
+ fix.inserted_content
+ code[end_column:]
)
code = line_before + code + line_after
for _ in range(start_line - 2):
code = "\n" + code
code = syntax.Syntax(
code,
"python",
line_numbers=True,
line_range=(start_line - 1, end_line + 1),
highlight_lines=(start_line, end_line),
)
self.console.print(code)
self.console.print()
for fix in result.fixes:
self.console.print(
f"Suggested fix: {fix.description}",
style=style,
)
start_line = fix.deleted_location.start_line
end_line = fix.deleted_location.end_line
start_column = fix.deleted_location.start_column
end_column = fix.deleted_location.end_column
line_before = linecache.getline(
filename=result.location.file_name,
lineno=start_line - 1,
)
code = linecache.getline(
filename=result.location.file_name,
lineno=start_line,
)
line_after = linecache.getline(
filename=result.location.file_name,
lineno=start_line + 1,
)
code = (
code[:start_column]
+ fix.inserted_content
+ code[end_column:]
)
code = line_before + code + line_after
for _ in range(start_line - 2):
code = "\n" + code
code = syntax.Syntax(
code,
"python",
line_numbers=True,
line_range=(start_line - 1, end_line + 1),
highlight_lines=(start_line, end_line),
)
self.console.print(code)
self.console.print()

# Print the summary
table = Table(
Expand Down

0 comments on commit 9268705

Please sign in to comment.