Skip to content

Commit

Permalink
Clean up rebase cruft
Browse files Browse the repository at this point in the history
  • Loading branch information
robdodson committed Jan 4, 2018
1 parent 4e78c97 commit eec0f53
Showing 1 changed file with 0 additions and 61 deletions.
61 changes: 0 additions & 61 deletions lighthouse-core/report/v2/report-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,6 @@ class ReportGeneratorV2 {
return REPORT_TEMPLATES;
}

<<<<<<< HEAD
=======
/**
* Computes the weighted-average of the score of the list of items.
* @param {!Array<{score: number|undefined, weight: number|undefined}>} items
* @return {number}
*/
static arithmeticMean(items) {
const results = items.reduce((result, item) => {
const score = Number(item.score) || 0;
const weight = Number(item.weight) || 0;
return {
weight: result.weight + weight,
sum: result.sum + score * weight,
};
}, {weight: 0, sum: 0});

return (results.sum / results.weight) || 0;
}
>>>>>>> Add non-applicable test reporting for a11y

/**
* Replaces all the specified strings in source without serial replacements.
Expand All @@ -84,47 +64,6 @@ class ReportGeneratorV2 {
.join(firstReplacement.replacement);
}

<<<<<<< HEAD
=======
/**
* Returns the report JSON object with computed scores.
* @param {{categories: !Object<string, {id: string|undefined, weight: number|undefined, audits: !Array<{id: string, weight: number|undefined}>}>}} config
* @param {!Object<{score: ?number|boolean|undefined}>} resultsByAuditId
* @return {{score: number, categories: !Array<{audits: !Array<{score: number, result: !Object}>}>}}
*/
generateReportJson(config, resultsByAuditId) {
const categories = Object.keys(config.categories).map(categoryId => {
const category = config.categories[categoryId];
category.id = categoryId;

const audits = category.audits.map(audit => {
const result = resultsByAuditId[audit.id];
// Cast to number to catch `null` and undefined when audits error
let auditScore = Number(result.score) || 0;
if (typeof result.score === 'boolean') {
auditScore = result.score ? 100 : 0;
}
// If a result was not applicable, meaning its checks did not run against anything on
// the page, force it's weight to 0. It will not count during the arithmeticMean() but
// will still be included in the final report json and displayed in the report as
// "Not Applicable".
if (result.notApplicable) {
auditScore = 100;
audit.weight = 0;
result.informative = true;
}

return Object.assign({}, audit, {result, score: auditScore});
});

const categoryScore = ReportGeneratorV2.arithmeticMean(audits);
return Object.assign({}, category, {audits, score: categoryScore});
});

const overallScore = ReportGeneratorV2.arithmeticMean(categories);
return {score: overallScore, categories};
}
>>>>>>> wip not applicable reporting

/**
* Returns the report HTML as a string with the report JSON and renderer JS inlined.
Expand Down

0 comments on commit eec0f53

Please sign in to comment.