Skip to content

Commit

Permalink
Merge branch 'main' into generate_report
Browse files Browse the repository at this point in the history
  • Loading branch information
swashko authored Mar 6, 2024
2 parents 7c4aa97 + c17858b commit 67ce4eb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
default_language_version:
python: python3.11
repos:
- repo: https://github.com/psf/black
rev: 22.8.0
Expand Down
23 changes: 14 additions & 9 deletions modelscan/modelscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,23 @@ def _generate_results(self) -> Dict[str, Any]:
report["summary"]["scanned"] = {"total_scanned": len(self._scanned)}

if self._scanned:
report["summary"]["scanned"]["scanned_files"] = [
str(Path(file_name).relative_to(Path(absolute_path)))
for file_name in self._scanned
]
scanned_files = []
for file_name in self._scanned:
resolved_file = Path(file_name).resolve()
scanned_files.append(
str(resolved_file.relative_to(Path(absolute_path)))
)

report["summary"]["scanned"]["scanned_files"] = scanned_files

if self._issues.all_issues:
report["issues"] = [
issue.details.output_json() for issue in self._issues.all_issues
]

for issue in report["issues"]:
issue["source"] = str(
Path(issue["source"]).relative_to(Path(absolute_path))
)
resolved_file = Path(issue["source"]).resolve()
issue["source"] = str(resolved_file.relative_to(Path(absolute_path)))
else:
report["issues"] = []

Expand All @@ -245,8 +248,9 @@ def _generate_results(self) -> Dict[str, Any]:
if error.message:
error_information["description"] = error.message
if error.source is not None:
resolved_file = Path(error.source).resolve()
error_information["source"] = str(
Path(str(error.source)).relative_to(Path(absolute_path))
resolved_file.relative_to(Path(absolute_path))
)

all_errors.append(error_information)
Expand All @@ -261,8 +265,9 @@ def _generate_results(self) -> Dict[str, Any]:
skipped_file_information = {}
skipped_file_information["category"] = str(skipped_file.category.name)
skipped_file_information["description"] = str(skipped_file.message)
resolved_file = Path(skipped_file.source).resolve()
skipped_file_information["source"] = str(
Path(skipped_file.source).relative_to(Path(absolute_path))
resolved_file.relative_to(Path(absolute_path))
)
all_skipped_files.append(skipped_file_information)

Expand Down

0 comments on commit 67ce4eb

Please sign in to comment.