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

Fix #408 where undo on diagram items breaks the model #410

Merged
merged 2 commits into from Aug 20, 2020
Merged

Conversation

amolenaar
Copy link
Member

@amolenaar amolenaar commented Aug 18, 2020

diagram items end up in the ElementFactory, because they emited
ElementCreated and ElementDeleted events.

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Documentation content changes

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Undo does no longer break the model. Instead DiagramItemCreated events are no longer inherited from ElementCreated events. This ensures both code paths do not intervene.

I added DiagramItemDeleted events, to match with the DiagramItemCreated events.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

diagram items end up in the ElementFactory, because they emited
ElementCreated and ElementDeleted events.
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Aug 18, 2020

Sourcery Code Quality Report (beta)

❌  Merging this PR will decrease code quality in the affected files by 0.02 out of 10.

Quality metrics Before After Change
Complexity 0.79 0.79 0.00
Method Length 24.83 25.65 0.82 🔴
Quality 9.32 9.30 -0.02 🔴
Other metrics Before After Change
Lines 745 772 27
Changed files Quality Before Quality After Quality Change
gaphor/core/modeling/diagram.py 9.13 9.14 0.01 🔵
gaphor/core/modeling/elementfactory.py 9.37 9.35 -0.02 🔴
gaphor/core/modeling/event.py 9.61 9.62 0.01 🔵
gaphor/core/modeling/presentation.py 9.53 9.49 -0.04 🔴
tests/test_undo.py 9.06 8.98 -0.08 🔴

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Overall Recommendation
tests/test_undo.py test_class_association_undo_redo 3 199.98 5.89 Split out functionality

Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

@amolenaar amolenaar linked an issue Aug 18, 2020 that may be closed by this pull request
3 tasks
@amolenaar amolenaar requested a review from danyeaw August 18, 2020 15:23
@amolenaar amolenaar added the bug An issue in the application label Aug 18, 2020
@amolenaar amolenaar added this to the 2.0.1 milestone Aug 18, 2020
@danyeaw danyeaw merged commit 7b92917 into master Aug 20, 2020
@danyeaw danyeaw deleted the fix-undo-issue branch August 20, 2020 01:36
@danyeaw
Copy link
Member

danyeaw commented Aug 20, 2020

@amolenaar Nice job fixing this!

@amolenaar amolenaar mentioned this pull request Aug 25, 2020
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue in the application
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Undo breaks model consistency
2 participants