Skip to content

Commit

Permalink
Fix symlink path resolve mismatch (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankushvangari authored Apr 15, 2024
1 parent ce8822d commit 5f8fe71
Showing 1 changed file with 9 additions and 9 deletions.
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

0 comments on commit 5f8fe71

Please sign in to comment.