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

Item constraint handling #145

Merged
merged 16 commits into from Nov 4, 2020
Merged

Item constraint handling #145

merged 16 commits into from Nov 4, 2020

Conversation

amolenaar
Copy link
Member

@amolenaar amolenaar commented Nov 2, 2020

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?

Item specific constraints are managed in the item. Item needs a reference to a canvas to add/remove constraints to the constraint solver.

Issue Number: N/A

What is the new behavior?

  • Pass the Connections object to the item via its constructor. Constraint lifecycle can be managed from there.
  • Better interface for Position.
  • Items no longer have a canvas reference.
  • Protocols for the View.
  • Updated tests to use fixtures normally

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@amolenaar amolenaar added this to In progress in Gaphas overhaul via automation Nov 2, 2020
@amolenaar amolenaar marked this pull request as draft November 2, 2020 21:48
@amolenaar amolenaar marked this pull request as ready for review November 3, 2020 19:18
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 3, 2020

Sourcery Code Quality Report

Merging this PR leaves code quality unchanged.

Quality metrics Before After Change
Complexity 0.82 ⭐ 0.79 ⭐ -0.03 👍
Method Length 47.01 ⭐ 45.58 ⭐ -1.43 👍
Working memory 5.31 ⭐ 5.42 ⭐ 0.11 👎
Quality 87.75% 87.75% 0.00%
Other metrics Before After Change
Lines 4165 4028 -137
Changed files Quality Before Quality After Quality Change
examples/demo.py 88.92% ⭐ 88.58% ⭐ -0.34% 👎
examples/exampleitems.py 88.52% ⭐ 87.19% ⭐ -1.33% 👎
examples/simple-box.py 86.55% ⭐ 86.47% ⭐ -0.08% 👎
gaphas/canvas.py 93.98% ⭐ 94.26% ⭐ 0.28% 👍
gaphas/connections.py 84.31% ⭐ 86.79% ⭐ 2.48% 👍
gaphas/connector.py 93.71% ⭐ 93.64% ⭐ -0.07% 👎
gaphas/item.py 91.49% ⭐ 91.57% ⭐ 0.08% 👍
gaphas/position.py 93.24% ⭐ 92.81% ⭐ -0.43% 👎
gaphas/segment.py 76.58% ⭐ 76.55% ⭐ -0.03% 👎
gaphas/painter/handlepainter.py 77.54% ⭐ 77.52% ⭐ -0.02% 👎
gaphas/painter/itempainter.py 92.10% ⭐ 92.69% ⭐ 0.59% 👍
gaphas/solver/solver.py 90.08% ⭐ 90.08% ⭐ 0.00%
gaphas/view/gtkview.py 84.42% ⭐ 84.41% ⭐ -0.01% 👎
tests/conftest.py 91.34% ⭐ 95.02% ⭐ 3.68% 👍
tests/test_aspect.py 92.33% ⭐ 92.91% ⭐ 0.58% 👍
tests/test_canvas.py 81.69% ⭐ 80.80% ⭐ -0.89% 👎
tests/test_connections.py 88.96% ⭐ 87.67% ⭐ -1.29% 👎
tests/test_element.py 83.81% ⭐ 84.31% ⭐ 0.50% 👍
tests/test_guide.py 81.97% ⭐ 81.24% ⭐ -0.73% 👎
tests/test_item.py 92.00% ⭐ 94.56% ⭐ 2.56% 👍
tests/test_line.py 87.22% ⭐ 86.87% ⭐ -0.35% 👎
tests/test_position.py 85.03% ⭐ 85.09% ⭐ 0.06% 👍
tests/test_segment.py 79.44% ⭐ 78.45% ⭐ -0.99% 👎
tests/test_tool.py 81.75% ⭐ 83.89% ⭐ 2.14% 👍
tests/test_undo.py 76.67% ⭐ 76.36% ⭐ -0.31% 👎
tests/test_view.py 89.24% ⭐ 88.24% ⭐ -1.00% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
examples/demo.py create_window 9 🙂 850 ⛔ 16 ⛔ 31.96% 😞 Try splitting into smaller methods. Extract out complex expressions
gaphas/view/gtkview.py GtkView.update_back_buffer 22 😞 231 ⛔ 11 😞 35.15% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
gaphas/painter/handlepainter.py HandlePainter._draw_handles 15 🙂 220 ⛔ 13 😞 37.74% 😞 Try splitting into smaller methods. Extract out complex expressions
gaphas/view/gtkview.py GtkView.get_handle_at_point 18 🙂 149 😞 9 🙂 48.65% 😞 Try splitting into smaller methods
gaphas/view/gtkview.py GtkView.get_port_at_point 11 🙂 125 😞 13 😞 49.95% 😞 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


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.

Copy link
Member

@danyeaw danyeaw left a comment

Choose a reason for hiding this comment

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

This is a smart refactoring to better separate the item constraints from the canvas!

Do we need to update the README and constraint.rst, or would you prefer that we create a separate PR to update the docs with all the changes so far?

@amolenaar
Copy link
Member Author

Good point. Let me do that in a separate PR, so I can first see what the impact of the changes in on Gaphor.

@amolenaar amolenaar merged commit c3e2084 into master Nov 4, 2020
Gaphas overhaul automation moved this from In progress to Done Nov 4, 2020
@amolenaar amolenaar deleted the item-constraints branch November 4, 2020 14:33
amolenaar added a commit to gaphor/gaphor that referenced this pull request Nov 4, 2020
danyeaw pushed a commit to gaphor/gaphor that referenced this pull request Nov 13, 2020
@amolenaar amolenaar added this to the 3.0 milestone Nov 17, 2020
@danyeaw danyeaw added the chore label Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants