-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filterPasses -> validatePasses #608
Changes from 1 commit
8ab91aa
bff2480
b59ffe0
60464e2
2152197
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,29 +106,20 @@ function cleanTrace(trace) { | |
return trace; | ||
} | ||
|
||
function filterPasses(passes, audits, rootPath) { | ||
function validatePasses(passes, audits, rootPath) { | ||
const requiredGatherers = getGatherersNeededByAudits(audits); | ||
|
||
// Make sure we only have the gatherers that are needed by the audits | ||
// that have been listed in the config. | ||
const filteredPasses = passes.map(pass => { | ||
const freshPass = Object.assign({}, pass); | ||
|
||
freshPass.gatherers = freshPass.gatherers.filter(gatherer => { | ||
// Note if we are running gathers that are not needed by the audits listed in the config | ||
passes.forEach(pass => { | ||
pass.gatherers.forEach(gatherer => { | ||
const GathererClass = GatherRunner.getGathererClass(gatherer, rootPath); | ||
const isGatherRequiredByAudits = requiredGatherers.has(GathererClass.name); | ||
if (isGatherRequiredByAudits === false) { | ||
log.warn('config', `Skipping ${GathererClass.name} gatherer as no audit requires it.`); | ||
log.warn('config', `${GathererClass.name} is included, however no audit requires it.`); | ||
} | ||
return isGatherRequiredByAudits; | ||
}); | ||
|
||
return freshPass; | ||
}) | ||
|
||
// Now remove any passes which no longer have gatherers. | ||
.filter(p => p.gatherers.length > 0); | ||
return filteredPasses; | ||
}); | ||
return passes; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't return passes anymore |
||
} | ||
|
||
function getGatherersNeededByAudits(audits) { | ||
|
@@ -294,9 +285,9 @@ class Config { | |
this._audits = configJSON.audits ? expandAudits( | ||
filterAudits(configJSON.audits, auditWhitelist), this._configDir | ||
) : null; | ||
// filterPasses expects audits to have been expanded | ||
// validatePasses expects audits to have been expanded | ||
this._passes = configJSON.passes ? | ||
filterPasses(configJSON.passes, this._audits, this._configDir) : | ||
validatePasses(configJSON.passes, this._audits, this._configDir) : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was also serving to make a copy of the |
||
null; | ||
this._auditResults = configJSON.auditResults ? Array.from(configJSON.auditResults) : null; | ||
this._artifacts = null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Note/Log