Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix symlink issue in path resolution #112

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading