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

Namespace show all (Sourcery refactored) #340

Closed
wants to merge 1 commit into from

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Jun 2, 2020

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:

git fetch origin sourcery/namespace-show-all
git merge --ff-only FETCH_HEAD
git reset HEAD^

@sourcery-ai sourcery-ai bot force-pushed the sourcery/namespace-show-all branch from e3f2acc to 5b36697 Compare June 2, 2020 09:43
if el.association and not (args or kwargs):
if el.association and not args and not kwargs:
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 format_property refactored with the following changes:

  • Simplify logical expression

Comment on lines -111 to +115
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)]
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 format_association_end refactored with the following changes:

  • Remove redundant conditional
  • Merge append into list assignment

Comment on lines -192 to +193
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
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 parse_association_end refactored with the following changes:

  • Merge nested if conditions

assert 2 == len(o.formalParameter)
assert len(o.formalParameter) == 2
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 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
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 test_parse_operation_1_param refactored with the following changes:

  • Ensure constant in comparison is on the right

Comment on lines -216 to +222
# 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)
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 NamespaceView.on_drag_data_received refactored with the following changes:

  • Replace if statement with if expression

Comment on lines +462 to +475
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)
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 Namespace._on_association_set refactored with the following changes:

  • Move assignments closer to their usage
  • Add guard clause

Comment on lines -485 to -491
element = event.element

if (
event.property is UML.Classifier.isAbstract
or event.property is UML.BehavioralFeature.isAbstract
or event.property is UML.NamedElement.name
):
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 Namespace._on_attribute_change refactored with the following changes:

  • Move assignments closer to their usage

Comment on lines -606 to +603
if element:
diagram.name = f"{element.name} diagram"
else:
diagram.name = "New diagram"

diagram.name = f'{element.name} diagram' if element else 'New diagram'
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 Namespace.tree_view_create_diagram refactored with the following changes:

  • Replace if statement with if expression

Comment on lines -623 to +616
if element:
package.name = f"{element.name} package"
else:
package.name = "New model"

package.name = f'{element.name} package' if element else 'New model'
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 Namespace.tree_view_create_package refactored with the following changes:

  • Replace if statement with if expression

@amolenaar
Copy link
Member

All fixed by #341

@amolenaar amolenaar closed this Jun 3, 2020
@danyeaw danyeaw deleted the sourcery/namespace-show-all branch June 4, 2020 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants