Skip to content

Commit

Permalink
remove audit ability to dynamically set scoreDisplayMode
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Mar 7, 2018
1 parent cccf448 commit f582bfe
Show file tree
Hide file tree
Showing 13 changed files with 11 additions and 11 deletions.
3 changes: 1 addition & 2 deletions lighthouse-core/audits/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ class Audit {
throw new Error(`Audit score for ${audit.meta.name} is > 1`);
}

const scoreDisplayMode = result.scoreDisplayMode || audit.meta.scoreDisplayMode ||
Audit.SCORING_MODES.BINARY;
const scoreDisplayMode = audit.meta.scoreDisplayMode || Audit.SCORING_MODES.BINARY;

return {
score,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class UnusedBytes extends Audit {
displayValue,
rawValue: wastedMs,
score: UnusedBytes.scoreForWastedMs(wastedMs),
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
extendedInfo: {
value: {
wastedMs,
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/audits/byte-efficiency/offscreen-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class OffscreenImages extends ByteEfficiencyAudit {
name: 'offscreen-images',
description: 'Offscreen images',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText:
'Consider lazy-loading offscreen and hidden images to improve page load speed ' +
'and time to interactive. ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class TotalByteWeight extends ByteEfficiencyAudit {
name: 'total-byte-weight',
description: 'Avoids enormous network payloads',
failureDescription: 'Has enormous network payloads',
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText:
'Large network payloads cost users real money and are highly correlated with ' +
'long load times. [Learn ' +
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/audits/byte-efficiency/unminified-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class UnminifiedCSS extends ByteEfficiencyAudit {
name: 'unminified-css',
description: 'Minify CSS',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText: 'Minifying CSS files can reduce network payload sizes. ' +
'[Learn more](https://developers.google.com/speed/docs/insights/MinifyResources).',
requiredArtifacts: ['CSSUsage', 'devtoolsLogs'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class UnminifiedJavaScript extends ByteEfficiencyAudit {
name: 'unminified-javascript',
description: 'Minify JavaScript',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText: 'Minifying JavaScript files can reduce payload sizes and script parse time. ' +
'[Learn more](https://developers.google.com/speed/docs/insights/MinifyResources).',
requiredArtifacts: ['Scripts', 'devtoolsLogs'],
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/audits/byte-efficiency/unused-css-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class UnusedCSSRules extends ByteEfficiencyAudit {
name: 'unused-css-rules',
description: 'Unused CSS rules',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText: 'Remove unused rules from stylesheets to reduce unnecessary ' +
'bytes consumed by network activity. ' +
'[Learn more](https://developers.google.com/speed/docs/insights/OptimizeCSSDelivery)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class UnusedJavaScript extends ByteEfficiencyAudit {
name: 'unused-javascript',
description: 'Unused JavaScript',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText: 'Remove unused JavaScript to reduce bytes consumed by network activity.',
requiredArtifacts: ['JsUsage', 'devtoolsLogs'],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class UsesOptimizedImages extends ByteEfficiencyAudit {
name: 'uses-optimized-images',
description: 'Optimize images',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText: 'Optimized images load faster and consume less cellular data. ' +
'[Learn more](https://developers.google.com/web/tools/lighthouse/audits/optimize-images).',
requiredArtifacts: ['OptimizedImages', 'devtoolsLogs'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ResponsesAreCompressed extends ByteEfficiencyAudit {
return {
name: 'uses-request-compression',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
description: 'Enable text compression',
helpText: 'Text-based responses should be served with compression (gzip, deflate or brotli)' +
' to minimize total network bytes.' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class UsesResponsiveImages extends ByteEfficiencyAudit {
name: 'uses-responsive-images',
description: 'Properly size images',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText:
'Serve images that are appropriately-sized to save cellular data ' +
'and improve load time. ' +
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/audits/byte-efficiency/uses-webp-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class UsesWebPImages extends ByteEfficiencyAudit {
name: 'uses-webp-images',
description: 'Serve images in next-gen formats',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText: 'Image formats like JPEG 2000, JPEG XR, and WebP often provide better ' +
'compression than PNG or JPEG, which means faster downloads and less data consumption. ' +
'[Learn more](https://developers.google.com/web/tools/lighthouse/audits/webp).',
Expand Down
8 changes: 0 additions & 8 deletions lighthouse-core/test/audits/audit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ describe('Audit', () => {
assert.throws(_ => Audit._normalizeAuditScore(B, {rawValue: true, score: NaN}), re);
assert.throws(_ => Audit._normalizeAuditScore(B, {rawValue: true, score: '50'}), re);
});

it('picks the scoreDisplayMode returned by an audit if provided', () => {
const {scoreDisplayMode} = Audit._normalizeAuditScore(B, {
rawValue: true,
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
});
assert.equal(scoreDisplayMode, Audit.SCORING_MODES.NUMERIC);
});
});

describe('generateAuditResult', () => {
Expand Down

0 comments on commit f582bfe

Please sign in to comment.