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

Negative distance (Sourcery refactored) #414

Merged
merged 1 commit into from
Mar 17, 2022

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Mar 17, 2022

Pull Request #413 refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the negative-distance branch, then run:

git fetch origin sourcery/negative-distance
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from amolenaar March 17, 2022 22:14
return 0 if d < 0 else d
return max(d, 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function distance_rectangle_point refactored with the following changes:

cinfo = model.connections.get_connection(self.handle)
if cinfo:
if cinfo := model.connections.get_connection(self.handle):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function ItemHandleMove.start_move refactored with the following changes:

Comment on lines -105 to +104
# find connectable item and its port
sink = self.glue(pos)

# no new connectable item, then diconnect and exit
if sink:
if sink := self.glue(pos):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function ItemHandleMove.connect refactored with the following changes:

This removes the following comments ( why? ):

# find connectable item and its port
# no new connectable item, then diconnect and exit

Comment on lines -366 to +369
self._ports = []
handles = self._handles
for h1, h2 in zip(handles[:-1], handles[1:]):
self._ports.append(LinePort(h1.pos, h2.pos))
self._ports = [
LinePort(h1.pos, h2.pos) for h1, h2 in zip(handles[:-1], handles[1:])
]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function Line._update_ports refactored with the following changes:

@sourcery-ai
Copy link
Contributor Author

sourcery-ai bot commented Mar 17, 2022

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.18%.

Quality metrics Before After Change
Complexity 2.65 ⭐ 2.64 ⭐ -0.01 👍
Method Length 36.73 ⭐ 36.63 ⭐ -0.10 👍
Working memory 7.72 🙂 7.80 🙂 0.08 👎
Quality 76.36% 76.18% -0.18% 👎
Other metrics Before After Change
Lines 1057 1052 -5
Changed files Quality Before Quality After Quality Change
gaphas/geometry.py 68.06% 🙂 68.08% 🙂 0.02% 👍
gaphas/handlemove.py 78.85% ⭐ 78.39% ⭐ -0.46% 👎
gaphas/item.py 83.27% ⭐ 83.15% ⭐ -0.12% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
gaphas/geometry.py intersect_line_line 7 ⭐ 203 😞 15 😞 43.41% 😞 Try splitting into smaller methods. Extract out complex expressions
gaphas/geometry.py point_on_rectangle 17 🙂 136 😞 10 😞 48.80% 😞 Try splitting into smaller methods. Extract out complex expressions
gaphas/item.py Element.__init__ 0 ⭐ 200 😞 13 😞 53.21% 🙂 Try splitting into smaller methods. Extract out complex expressions
gaphas/geometry.py distance_line_point 4 ⭐ 176 😞 8 🙂 60.67% 🙂 Try splitting into smaller methods
gaphas/geometry.py Rectangle.__iadd__ 3 ⭐ 101 🙂 13 😞 60.67% 🙂 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!

Help us improve this quality report!

@danyeaw danyeaw merged commit c72f0d4 into negative-distance Mar 17, 2022
@danyeaw danyeaw deleted the sourcery/negative-distance branch March 17, 2022 23:31
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.

1 participant