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

CPLAT-11143 Emit a build error for mismatched components in the new boilerplate #496

Merged
merged 5 commits into from
May 20, 2020

Conversation

greglittlefield-wf
Copy link
Contributor

Motivation

If a component isn't named correctly in the new boilerplate, it won't get associated with the factory and props class the author intended it to be.

Currently, this mismatched component is ignored and the component gets interpreted as a props mapview, and when the consumer invokes the builder, they get a runtime error.

It would be better if it failed the build.

Changes

  • When possible, increase v4_mixinBased confidence of components to above neutral, resulting in mismatched components emitting errors instead of getting silently ignored.
    • Add tests
  • Update runtime error to mention the mismatched component case, for better debugging of edge case mismatched components (with neutral confidences) that don't trigger a build error
  • (Boyscouting) update punctuation in error messages

Release Notes

Emit a build error for mismatched components in the new boilerplate

Review

See CONTRIBUTING.md for more details on review types (+1 / QA +1 / +10) and code review process.

Please review:

QA Checklist

  • Tests were updated and provide good coverage of the changeset and other affected code
  • Manual testing was performed if needed
    • Steps from PR author:
      • Verify in consumer repos that this does not cause any new failures
    • Anything falling under manual testing criteria outlined in CONTRIBUTING.md

Merge Checklist

While we perform many automated checks before auto-merging, some manual checks are needed:

  • A Client Platform member has reviewed these changes
  • There are no unaddressed comments - this check can be automated if reviewers use the "Request Changes" feature
  • For release PRs - Version metadata in Rosie comment is correct

@aviary-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

@greglittlefield-wf
Copy link
Contributor Author

FYI @evanweible-wf @aaronstgeorge-wf

Comment on lines +450 to +463
final confidences = VersionConfidences(
// If the component extends from a base class known to be supported by the new boilerplate,
// has no annotation, is not abstract, and does not have $isClassGenerated, then it's
// most likely intended to be part of a new boilerplate class component declaration.
//
// Make this `likely` so that components that don't get associated with factory/props
// due to naming issues aren't silently ignored.
v4_mixinBased: !classish.hasAbstractKeyword &&
!_overridesIsClassGenerated(classish) &&
mixinBoilerplateBaseClasses.contains(classish.superclass?.nameWithoutPrefix)
? Confidence.likely
: Confidence.neutral,
v2_legacyBackwardsCompat: Confidence.neutral,
v3_legacyDart2Only: Confidence.neutral,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really cool

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I'm super happy that the confidence approach made this kind of change easy

evanweible-wf
evanweible-wf previously approved these changes May 15, 2020
Copy link

@willdrach-wk willdrach-wk left a comment

Choose a reason for hiding this comment

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

One quick little thing but overall looks good!

lib/src/builder/parsing/members_from_ast.dart Outdated Show resolved Hide resolved
Copy link
Contributor

@aaronlademann-wf aaronlademann-wf left a comment

Choose a reason for hiding this comment

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

+1

@rmconsole3-wf rmconsole3-wf changed the title Emit a build error for mismatched components in the new boilerplate CPLAT-11143 Emit a build error for mismatched components in the new boilerplate May 15, 2020
@greglittlefield-wf
Copy link
Contributor Author

QA +1

Copy link

@willdrach-wk willdrach-wk left a comment

Choose a reason for hiding this comment

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

just updating to remove the "request changes" - changes have been reflected

Copy link

@willdrach-wk willdrach-wk left a comment

Choose a reason for hiding this comment

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

fine

@greglittlefield-wf
Copy link
Contributor Author

@Workiva/release-management-p

Copy link

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

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

+1 from RM

@rmconsole2-wf rmconsole2-wf merged commit af3c8f5 into master May 20, 2020
@rmconsole2-wf rmconsole2-wf deleted the catch-mismatched-components branch May 20, 2020 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants