Skip to content

Commit 1d0a17e

Browse files
committed
fix: apply 98% confidence threshold and NOASSERTION semantics in license detection IN-1105
1 parent 2537232 commit 1d0a17e

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

services/apps/git_integration/src/crowdgit/services/license/license_service.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ async def detect(self, repo_path: str) -> str | None:
3737
if matched_files
3838
else None
3939
)
40+
41+
# Mirror GitHub's threshold — below 98% similarity the match is unreliable.
42+
# Downgrade low-confidence matches to NOASSERTION so the distinction is clean:
43+
# NULL = no license file found
44+
# NOASSERTION = found a license file but couldn't reliably identify it
45+
# The UI should display NOASSERTION as "Other".
46+
if spdx_id and spdx_id != "NOASSERTION" and confidence is not None and confidence < 98:
47+
self.logger.info(
48+
f"License downgraded to NOASSERTION: confidence {confidence}% below threshold in {repo_path}"
49+
)
50+
return "NOASSERTION"
51+
4052
if spdx_id:
4153
self.logger.info(
4254
f"License detected: {spdx_id} (confidence={confidence}) in {repo_path}"

0 commit comments

Comments
 (0)