Skip to content

Commit

Permalink
add some logs for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
srijan-deepsource committed Sep 12, 2024
1 parent 9253bf3 commit 74f6f33
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sarif-parser/src/sarif_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def parse(

deepsource_issues: list[Issue] = []
total_report_issues = 0
sanitised_issues_count = 0
for run in sarif_data["runs"]:
total_report_issues += len(run["results"])
for issue in run["results"]:
Expand Down Expand Up @@ -96,6 +97,7 @@ def parse(
issue_code = issue["ruleId"]
if issue_code in issue_map:
issue_code = issue_map[issue_code]["issue_code"]
sanitised_issues_count += 1
else:
# This issue isn't sanitised. Send an alert.
sentry.raise_info(
Expand All @@ -121,9 +123,11 @@ def parse(

logger.info(
"Total issues in SARIF report: %s. \n"
"Issues extracted for the run in files sent for analysis: %s",
"Issues extracted for the run in files sent for analysis: %s. \n"
"Sanitized issues count, with id in map: %s.",
total_report_issues,
len(deepsource_issues),
sanitised_issues_count,
)

return deepsource_issues
Expand Down Expand Up @@ -174,6 +178,8 @@ def run_sarif_parser(
sentry.raise_info(
f"Could not find issue map at {issue_map_path} for analyzer."
)
# Add a log too
logger.warning("Could not find issue map at %s for analyzer.", issue_map_path)

# Run parser
deepsource_issues = []
Expand Down Expand Up @@ -202,5 +208,6 @@ def run_sarif_parser(
"is_passed": len(deepsource_issues) == 0,
"extra_data": {},
}

with open(output_path, "w") as file:
json.dump(issues_dict, file)

0 comments on commit 74f6f33

Please sign in to comment.