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-9677 Improve class migration short-circuit logic + consumer communication #82

Merged
merged 21 commits into from
Mar 2, 2020

Conversation

aaronlademann-wf
Copy link
Contributor

@aaronlademann-wf aaronlademann-wf commented Feb 19, 2020

NOTE: I'd recommend just reading through the advanced_props_and_state_migrator_test.dart file without attempting to make sense of the diff.

Motivation

Currently, when the codemod runs the AdvancedPropsAndStateClassMigrator, the migrator does not short-circuit if a custom superclass, or one or more mixins is not present in the map of "known converted classes" that the migrators update as classes are converted.

This is done because we have no way to control the order in which classes are visited by the suggestor. This means that just because a superclass or mixin is not present in the map of "known converted classes" at the time the subclass is visited - does not mean it will never be converted.

We also need to improve how we communicate to the consumer when our codemod short-circuits because of public API detection / superclasses from external libs.

Changes

  1. Expand the role of the ClassToMixinConverter class to record visits, as well as record whether the class that was visited was converted.
    1. This allows us to short-circuit other migrations when a class that another class extends from / mixes in:
      1. Was visited, but not converted
      2. Was never visited (meaning it lives in an external lib)
  2. Run the AdvancedPropsAndStateClassMigrator twice during the migration.
    1. On the first run, short-circuit - but do not add FIXME comments when an unknown/unconverted superclass or mixin is encountered.
    2. On the second run, short-circuit AND add FIXME comments when an unknown/unconverted superclass or mixin is encountered.
  3. Add a --convert-classes-with-external-superclasses flag that can be set to force the conversion of classes that extend from or mix in classes that do not live in the same library.
  4. Add a MigrationDecision class that is responsible for determining when short-circuits occur during migrations, as well as storing a reason comment that we will apply to keep the consumers informed about what they can do to either migrate the classes manually, or to make some adjustments before running the migration script again.
  5. Move the StubbedPropsAndStateClassRemover so that it runs with the knowledge of which classes have been converted.
  6. Misc. logic updates to handle additional edge cases while testing the migrators in graph_ui.
  7. Add crap-tons of tests.

Review

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

Please review: @joebingham-wk @sydneyjodon-wk @greglittlefield-wf

QA Checklist

  • Tests were updated and provide good coverage of the changeset and other affected code
  • Manual testing was performed if needed

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

+ The advanced class migrator shouldn’t be removing @props() / @AbstractProps() annotations - we have another migrator for that.  The removal of these annotations was causing the “companion” classes to not be removed when the class first had its annotation removed.
+ Also, the annotations should remain on the concrete class - not moved to the mixin
# Conflicts:
#	lib/src/boilerplate_suggestors/boilerplate_utilities.dart
#	lib/src/executables/boilerplate_upgrade.dart
#	test/boilerplate_suggestors/advanced_props_and_state_class_migrator_test.dart
#	test/boilerplate_suggestors/simple_props_and_state_class_migrator_test.dart
#	test/boilerplate_suggestors/stubbed_props_and_state_class_remover_test.dart
@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.

@aaronlademann-wf aaronlademann-wf changed the title [wip] CPLAT-9677 CPLAT-9677 Improve class migration short-circuit logic + consumer communication Feb 19, 2020
@aaronlademann-wf aaronlademann-wf marked this pull request as ready for review February 19, 2020 22:44
Copy link
Contributor

@joebingham-wk joebingham-wk left a comment

Choose a reason for hiding this comment

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

Got through most of the changes, but it's dense so I thought I'd just send out what I had and finish up the review after lunch!

Overall, I like the new architecture for comments and keeping track of migrating decisions. I think it works well and makes it clear (or as clear as I can imagine) when comments should be posted. So that's awesome and I don't have any feedback on changes to how that works.

Otherwise just found some nits and small things!

Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

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

Forgot to post this when I started reviewing a couple days ago 🤦‍♂

Starting another pass now...

Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

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

Final pass!

Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

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

+10

@greglittlefield-wf greglittlefield-wf merged commit cda95df into CPLAT-9205-new-boilerplate-codemod Mar 2, 2020
@greglittlefield-wf
Copy link
Contributor

@rmconsole-wf

@greglittlefield-wf
Copy link
Contributor

@Workiva/release-management-p

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.

6 participants