Skip to content
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

report: augment auditRef, not result, with stackPack ref #8633

Merged
merged 1 commit into from
Apr 26, 2019

Conversation

brendankenny
Copy link
Member

Not sure if I can convince everyone we should make this change :) Note that it's contained entirely within the report renderer, so there will be no effect on core, PSI, etc.

In prepareReportResult we smoosh a few things to make report rendering easier, like writing a LH.Audit.Result to the relevant LH.Result.AuditRef and, most recently, writing LH.ReportResult.StackPackDescription to the relevant LH.Audit.Result.

This PR makes it so both LH.Audit.Result and LH.ReportResult.StackPackDescription are written to the auditRef.

On the con side: it makes a certain amount of sense to match stack packs to auditResults as they have a 1:1 match, while there may be multiple auditRefs to a single audit (and thus a stack pack).

However:

  • we should be minimizing and isolating the amount of smooshing we do, both for the sake of "purity" and to reduce confusion in the codebase between almost but not quite identical types like the audit results.
  • this comes up in a few places in our tests where we formerly could assume that audit results were audit results, but now we have to add special cases to handle these mutant objects. See for example the deleting needed to make this PR work. Ideally we wouldn't have to do that
  • the only place we render these we're looping over auditRefs anyway, so we don't save any ease of use either way :)

The solution in this PR keeps modifications contained within LH.ReportResult.AuditRef and makes that deletion in #8536 unnecessary.

(@exterkamp if we land this you won't need any of your changes to util-test.js)

@@ -72,21 +72,21 @@ class Util {
}
}

// For convenience, smoosh all AuditResults into their auditDfn (which has just weight & group)
// For convenience, smoosh all AuditResults into their auditRef (which has just weight & group)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this and "auditMeta" below to their modern names :)

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to me!

@@ -81,8 +81,8 @@ class CategoryRenderer {
this.dom.find('.lh-audit__description', auditEl)
.appendChild(this.dom.convertMarkdownLinkSnippets(audit.result.description));

if (audit.result.stackPacks) {
audit.result.stackPacks.forEach(pack => {
if (audit.stackPacks) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes more sense to me 👍

const clonedSampleResult = JSON.parse(JSON.stringify(sampleResult));
const iconDataURL = 'data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg"%3E%3C/svg%3E';
clonedSampleResult.stackPacks = [{
id: 'snackpack',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆

Copy link
Member

@exterkamp exterkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM love this change, paying down tech debt and making new stuff more clear!

@brendankenny brendankenny merged commit ad0a747 into master Apr 26, 2019
@brendankenny brendankenny deleted the stackref branch April 26, 2019 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants