Skip to content

Commit

Permalink
fix: adds score rounding to avoid floating point errors (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackbrewer committed Sep 28, 2022
1 parent bf1c432 commit 8b2f4cf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const formatResults = ({ results, thresholds }) => {
}));

const shortSummary = categories
.map(({ title, score }) => `${title}: ${score * 100}`)
.map(({ title, score }) => `${title}: ${Math.round(score * 100)}`)
.join(', ');

const formattedReport = makeReplacements(results.report);
Expand Down Expand Up @@ -226,7 +226,7 @@ const processResults = ({ data, errors }) => {

if (summary) {
obj.summary = summary.reduce((acc, item) => {
acc[item.id] = item.score * 100;
acc[item.id] = Math.round(item.score * 100);
return acc;
}, {});
}
Expand Down

0 comments on commit 8b2f4cf

Please sign in to comment.