Skip to content

Commit

Permalink
Add context to the path_score #659
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Druez <[email protected]>
  • Loading branch information
tdruez committed Apr 6, 2023
1 parent 014a5a0 commit da6e99a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scanpipe/pipes/d2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def path_match(project):

for resource in from_resources:
path_parts = Path(resource.path.lstrip("/")).parts
for index in range(1, len(path_parts)):
path_parts_len = len(path_parts)
for index in range(1, path_parts_len):
current_parts = path_parts[index:]
current_path = "/".join(current_parts)
# The slash "/" prefix matters during the match as we do not want to
Expand All @@ -118,5 +119,7 @@ def path_match(project):
to_resource=match,
relationship=CodebaseRelation.Relationship.PATH_MATCH,
match_type="path",
extra_data={"path_score": len(current_parts)},
extra_data={
"path_score": f"{len(current_parts)}/{path_parts_len-1}",
},
)

0 comments on commit da6e99a

Please sign in to comment.