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 path resolve mismatch #138

Merged
merged 1 commit into from
Apr 15, 2024
Merged
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
18 changes: 9 additions & 9 deletions modelscan/modelscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def _scan_source(
def _generate_results(self) -> Dict[str, Any]:
report: Dict[str, Any] = {}

absolute_path = Path(self._input_path).resolve()
absolute_path = Path(self._input_path)
if Path(self._input_path).is_file():
absolute_path = Path(absolute_path).parent

Expand All @@ -254,9 +254,8 @@ def _generate_results(self) -> Dict[str, Any]:
if 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)))
str(Path(file_name).relative_to(Path(absolute_path)))
)

report["summary"]["scanned"]["scanned_files"] = scanned_files
Expand All @@ -267,8 +266,9 @@ def _generate_results(self) -> Dict[str, Any]:
]

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

Expand All @@ -277,9 +277,10 @@ def _generate_results(self) -> Dict[str, Any]:
for error in self._errors:
error_information = error.to_dict()
if "source" in error_information:
resolved_file = Path(error_information["source"]).resolve()
error_information["source"] = str(
resolved_file.relative_to(Path(absolute_path))
Path(error_information["source"]).relative_to(
Path(absolute_path)
)
)

all_errors.append(error_information)
Expand All @@ -294,9 +295,8 @@ 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(
resolved_file.relative_to(Path(absolute_path))
Path(skipped_file.source).relative_to(Path(absolute_path))
)
all_skipped_files.append(skipped_file_information)

Expand Down
Loading