Skip to content

Commit 7c15b85

Browse files
committed
Add --checklist-limit flag (fix #835)
1 parent 55a2678 commit 7c15b85

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

slither/__main__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ def parse_args(detector_classes, printer_classes): # pylint: disable=too-many-s
472472
"--checklist", help=argparse.SUPPRESS, action="store_true", default=False
473473
)
474474

475+
group_misc.add_argument("--checklist-limit", help=argparse.SUPPRESS, action="store", default="")
476+
475477
parser.add_argument(
476478
"--wiki-detectors", help=argparse.SUPPRESS, action=OutputWiki, default=False
477479
)
@@ -751,7 +753,7 @@ def main_impl(all_detector_classes, all_printer_classes):
751753

752754
# Output our results to markdown if we wish to compile a checklist.
753755
if args.checklist:
754-
output_results_to_markdown(results_detectors)
756+
output_results_to_markdown(results_detectors, args.checklist_limit)
755757

756758
# Dont print the number of result for printers
757759
if number_contracts == 0:

slither/utils/command_line.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def convert_result_to_markdown(txt):
145145
return "".join(ret)
146146

147147

148-
def output_results_to_markdown(all_results):
148+
def output_results_to_markdown(all_results, checklistlimit: str):
149149
checks = defaultdict(list)
150150
info = defaultdict(dict)
151151
for results in all_results:
@@ -154,20 +154,26 @@ def output_results_to_markdown(all_results):
154154

155155
print("Summary")
156156
for check in checks:
157-
print(f" - [{check}](#{check}) ({len(checks[check])} results)")
157+
print(f" - [{check}](#{check}) ({len(checks[check])} results) ({info[check]['impact']})")
158158

159159
counter = 0
160160
for (check, results) in checks.items():
161161
print(f"## {check}")
162162
print(f'Impact: {info[check]["impact"]}')
163163
print(f'Confidence: {info[check]["confidence"]}')
164+
additional = False
165+
if checklistlimit and len(results) > 5:
166+
results = results[0:5]
167+
additional = True
164168
for result in results:
165169
print(" - [ ] ID-" + f"{counter}")
166170
counter = counter + 1
167171
print(result["markdown"])
168172
if result["first_markdown_element"]:
169173
print(result["first_markdown_element"])
170174
print("\n")
175+
if additional:
176+
print(f"**More results were found, check [{checklistlimit}]({checklistlimit})**")
171177

172178

173179
def output_wiki(detector_classes, filter_wiki):

0 commit comments

Comments
 (0)