Fix #17 [main] - set language to unknown when langdetect cannot detect

the language for some reasons like empty commit message or unknown
language.

Notes: langdetect exception handler seems to be crap and do not use
a Base Exception handler. That's why the catch-all ;-)
This commit is contained in:
Alexandre Dulaunoy 2022-11-27 10:28:01 +01:00
parent 5d19d0d0ab
commit 68f273ee54
Signed by: adulau
GPG key ID: 09E2CD4944E6CBCD

View file

@ -82,9 +82,11 @@ def summary(
else:
potential_vulnerabilities[rcommit.hexsha] = {}
potential_vulnerabilities[rcommit.hexsha]["message"] = rcommit.message
potential_vulnerabilities[rcommit.hexsha]["language"] = langdetect(
rcommit.message
)
try:
lang = langdetect(rcommit.message)
except:
lang = "unknown"
potential_vulnerabilities[rcommit.hexsha]["language"] = lang
potential_vulnerabilities[rcommit.hexsha]["commit-id"] = rcommit.hexsha
potential_vulnerabilities[rcommit.hexsha]["summary"] = rcommit.summary
potential_vulnerabilities[rcommit.hexsha]["stats"] = rcommit.stats.total