-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Namespace show all (Sourcery refactored) #340
Conversation
d34849b
to
6fe65f0
Compare
e3f2acc
to
5b36697
Compare
if el.association and not (args or kwargs): | ||
if el.association and not args and not kwargs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function format_property refactored with the following changes:
- Simplify logical expression
if el.name: | ||
n.append(el.name) | ||
n.append(el.name) | ||
|
||
name = "".join(n) | ||
|
||
m = [] | ||
m.append(format_multiplicity(el, bare=True)) | ||
|
||
m = [format_multiplicity(el, bare=True)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function format_association_end refactored with the following changes:
- Remove redundant conditional
- Merge append into list assignment
if m and not m.group("mult_u"): | ||
if el.upperValue: | ||
el.upperValue = None | ||
if m and not m.group("mult_u") and el.upperValue: | ||
el.upperValue = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function parse_association_end refactored with the following changes:
- Merge nested if conditions
assert 2 == len(o.formalParameter) | ||
assert len(o.formalParameter) == 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function test_parse_operation_2_params refactored with the following changes:
- Ensure constant in comparison is on the right
assert 1 == len(o.formalParameter) | ||
assert len(o.formalParameter) == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function test_parse_operation_1_param refactored with the following changes:
- Ensure constant in comparison is on the right
# else add it to the item. | ||
# else add it to the item. | ||
if position in ( | ||
Gtk.TreeViewDropPosition.BEFORE, | ||
Gtk.TreeViewDropPosition.AFTER, | ||
): | ||
Gtk.TreeViewDropPosition.BEFORE, | ||
Gtk.TreeViewDropPosition.AFTER, | ||
): | ||
parent_iter = model.iter_parent(iter) | ||
if parent_iter is None: | ||
dest_element = None | ||
else: | ||
dest_element = model.get_value(parent_iter, 0) | ||
|
||
dest_element = None if parent_iter is None else model.get_value(parent_iter, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function NamespaceView.on_drag_data_received refactored with the following changes:
- Replace if statement with if expression
if event.property is not UML.NamedElement.namespace: | ||
return | ||
old_value, new_value = event.old_value, event.new_value | ||
|
||
old_iter = self.iter_for_element(element, old_namespace=old_value) | ||
if old_iter: | ||
self.model.remove(old_iter) | ||
element = event.element | ||
old_iter = self.iter_for_element(element, old_namespace=old_value) | ||
if old_iter: | ||
self.model.remove(old_iter) | ||
|
||
if self._visible(element): | ||
new_iter = self.iter_for_element(new_value) | ||
# Should be either set (sub node) or unset (root node) | ||
if bool(new_iter) == bool(new_value): | ||
self._add(element, new_iter) | ||
if self._visible(element): | ||
new_iter = self.iter_for_element(new_value) | ||
# Should be either set (sub node) or unset (root node) | ||
if bool(new_iter) == bool(new_value): | ||
self._add(element, new_iter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Namespace._on_association_set refactored with the following changes:
- Move assignments closer to their usage
- Add guard clause
element = event.element | ||
|
||
if ( | ||
event.property is UML.Classifier.isAbstract | ||
or event.property is UML.BehavioralFeature.isAbstract | ||
or event.property is UML.NamedElement.name | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Namespace._on_attribute_change refactored with the following changes:
- Move assignments closer to their usage
if element: | ||
diagram.name = f"{element.name} diagram" | ||
else: | ||
diagram.name = "New diagram" | ||
|
||
diagram.name = f'{element.name} diagram' if element else 'New diagram' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Namespace.tree_view_create_diagram refactored with the following changes:
- Replace if statement with if expression
if element: | ||
package.name = f"{element.name} package" | ||
else: | ||
package.name = "New model" | ||
|
||
package.name = f'{element.name} package' if element else 'New model' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Namespace.tree_view_create_package refactored with the following changes:
- Replace if statement with if expression
All fixed by #341 |
Pull Request #336 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
namespace-show-all
branch, then run: