Skip to content

Commit

Permalink
Better short and long rule descriptions
Browse files Browse the repository at this point in the history
The short description should be limited to just one sentence.
While the long description should have both text and markdown
formats for the SARIF output.

Signed-off-by: Eric Brown <[email protected]>
  • Loading branch information
ericwb committed Mar 7, 2024
1 parent 4a385f4 commit 3223c6b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion precli/renderers/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def create_rule_array(self, run: Run):
text=rule.short_description
),
full_description=sarif_om.MultiformatMessageString(
text=rule.full_description
text=rule.full_description,
markdown=rule.full_description
),
message_strings={
"default": sarif_om.MultiformatMessageString(
Expand Down
4 changes: 2 additions & 2 deletions precli/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ def short_description(self) -> str:
:rtype: str
"""
try:
start = self._full_descr.index("\n\n") + 2
start = self._full_descr.index("\n# ") + 3
except ValueError:
start = 0
try:
end = self._full_descr.index("\n##")
end = self._full_descr.index("\n\n")
except ValueError:
end = len(self._full_descr)
return self._full_descr[start:end]
Expand Down

0 comments on commit 3223c6b

Please sign in to comment.