Skip to content

Commit

Permalink
tempoary: cast boolean scores when creating arithmetic mean score.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Mar 9, 2018
1 parent e4784a2 commit 89c48f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lighthouse-core/scoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ class ReportScoring {
static arithmeticMean(items) {
const results = items.reduce(
(result, item) => {
const score = Number(item.score) || 0;
// HACK. remove this in the next PR
// Srsly. The score inconsitency has been very bad.
let itemScore = item.score;
if (typeof item.score === 'boolean') {
itemScore = item.score ? 100 : 0;
}

const score = Number(itemScore) || 0;
const weight = Number(item.weight) || 0;
return {
weight: result.weight + weight,
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/test/runner-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ describe('Runner', () => {
assert.equal(results.initialUrl, url);
assert.equal(gatherRunnerRunSpy.called, true, 'GatherRunner.run was not called');
assert.equal(results.audits['content-width'].name, 'content-width');
assert.equal(results.audits['content-width'].score, 100);
assert.equal(results.audits['content-width'].score, true);
assert.equal(results.reportCategories[0].score, 100);
assert.equal(results.reportCategories[0].audits[0].id, 'content-width');
});
Expand Down

0 comments on commit 89c48f7

Please sign in to comment.