Skip to content

Commit

Permalink
Fix divide by zero bug (Yelp#429)
Browse files Browse the repository at this point in the history
* Fix divide by zero bug

Fixes user reported bug (see [Slack thread](https://ibm-whitewater.slack.com/archives/CDMGJ9QG2/p1620408289067500))

* Fix safety check
  • Loading branch information
justineyster authored and GitHub Enterprise committed May 11, 2021
1 parent d147bf4 commit 8615d2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions detect_secrets/core/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,14 @@ def determine_audit_results(baseline, baseline_path):
audit_results['stats'][audit_result]['count'] += 1
audit_results['stats'][audit_result]['files'][filename] += 1
total += 1
audit_results['stats']['signal'] = str(
(
float(audit_results['stats']['true-positives']['count'])
/
total
) * 100,
)[:4] + '%'
if total > 0:
audit_results['stats']['signal'] = str(
(
float(audit_results['stats']['true-positives']['count'])
/
total
) * 100,
)[:4] + '%'

for plugin_config in baseline['plugins_used']:
plugin_name = plugin_config['name']
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coveragepy==5.0 fails with `Safety level may not be changed inside a transaction
# on python 3.6.0 (xenial)
pip>=19.2
pip>=21.1
coverage<5
flake8==3.5.0
mock
Expand Down

0 comments on commit 8615d2f

Please sign in to comment.