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

Sourcery refactored master branch #206

Merged
merged 1 commit into from
Jun 12, 2021
Merged

Sourcery refactored master branch #206

merged 1 commit into from
Jun 12, 2021

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Jun 10, 2021

Branch master refactored by Sourcery.

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

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 master branch, then run:

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from Wolfe1 June 10, 2021 20:00
if "FALSE" in suppress.upper():
self.suppress_warnings = False
else:
self.suppress_warnings = True
self.suppress_warnings = "FALSE" not in suppress.upper()
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 APILibrary.suppress_insecure_request_warnings refactored with the following changes:

Comment on lines -215 to +212
elif isinstance(number_of_items, int):
pass
else:
elif not isinstance(number_of_items, int):
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 APILibrary.validate_response_contains_correct_number_of_items refactored with the following changes:

new_response = {}
for item in dir(response):
if item[0] != '_':
new_response[item] = getattr(response, item)
new_response = {
item: getattr(response, item)
for item in dir(response)
if item[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 _convert_resp_to_dict refactored with the following changes:

Comment on lines -34 to +35
stdout = open(os.devnull, 'w')
self.process = subprocess.Popen([path], stdout=stdout)
stdout.close()
with open(os.devnull, 'w') as stdout:
self.process = subprocess.Popen([path], stdout=stdout)
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 WinAppDriver.set_up_driver refactored with the following changes:

Comment on lines +899 to -904
self._wait_until_page_contains_element(each, self.get_appium_timeout())
if count == 0:
self._wait_until_page_contains_element(each, self.get_appium_timeout())
self.mouse_over_and_context_click_element(each)
else:
self._wait_until_page_contains_element(each, self.get_appium_timeout())
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 DesktopLibrary.select_elements_from_context_menu refactored with the following changes:

for x in range(swipe_count):
for _ in range(swipe_count):
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 MobileLibrary.scroll_up_to_text refactored with the following changes:

for x in range(number_of_types):
for _ in range(number_of_types):
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 _ObjectNamespacePlugin.loaded refactored with the following changes:

response = suds_library.call_soap_method(action, *soap_object)
return response
return suds_library.call_soap_method(action, *soap_object)
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 SOAPLibrary.call_soap_method_with_list_object refactored with the following changes:

Comment on lines -161 to +160
for index in range(len(response_dictionary)):
for _ in range(len(response_dictionary)):
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 _build_dict_from_response refactored with the following changes:

if encode:
self._myData = base64.b64decode(data)
else:
self._myData = data
self._myData = base64.b64decode(data) if encode else data
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 WebdriverRemoteMock.push_file refactored with the following changes:

@sourcery-ai
Copy link
Contributor Author

sourcery-ai bot commented Jun 10, 2021

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 7.25 ⭐ 7.27 ⭐ 0.02 👎
Method Length 46.52 ⭐ 46.28 ⭐ -0.24 👍
Working memory 8.06 🙂 8.09 🙂 0.03 👎
Quality 70.80% 🙂 70.68% 🙂 -0.12% 👎
Other metrics Before After Change
Lines 2348 2333 -15
Changed files Quality Before Quality After Quality Change
src/Zoomba/APILibrary.py 52.45% 🙂 51.74% 🙂 -0.71% 👎
src/Zoomba/DesktopLibrary.py 71.66% 🙂 71.72% 🙂 0.06% 👍
src/Zoomba/GUILibrary.py 88.72% ⭐ 89.10% ⭐ 0.38% 👍
src/Zoomba/MobileLibrary.py 86.08% ⭐ 86.08% ⭐ 0.00%
src/Zoomba/SOAPLibrary.py 66.14% 🙂 65.89% 🙂 -0.25% 👎
test/Helpers/webdriverremotemock.py 93.24% ⭐ 93.65% ⭐ 0.41% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
src/Zoomba/APILibrary.py _unmatched_list_check 28 😞 314 ⛔ 19 ⛔ 18.30% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
src/Zoomba/APILibrary.py APILibrary.key_by_key_validator 26 😞 259 ⛔ 16 ⛔ 24.08% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
src/Zoomba/APILibrary.py APILibrary._key_by_key_list 19 😞 126 😞 16 ⛔ 39.47% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
src/Zoomba/APILibrary.py APILibrary.validate_response_contains_expected_response 25 😞 152 😞 11 😞 39.64% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
src/Zoomba/DesktopLibrary.py DesktopLibrary.switch_application_by_name 12 🙂 248 ⛔ 12 😞 40.24% 😞 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!

Help us improve this quality report!

@coveralls
Copy link

coveralls commented Jun 10, 2021

Coverage Status

Coverage remained the same at 100.0% when pulling 36992d5 on sourcery/master into d3a064d on master.

Copy link
Contributor

@Wolfe1 Wolfe1 left a comment

Choose a reason for hiding this comment

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

Tested this out locally with the sample files and everything seems to be good. Each refactor made sense after reading through it. Coverage still at 100%.

@Wolfe1 Wolfe1 self-assigned this Jun 11, 2021
Copy link
Contributor

@neiljhowell neiljhowell left a comment

Choose a reason for hiding this comment

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

WHAT SORCERY IS THIS :D

@Wolfe1 Wolfe1 merged commit 8297e72 into master Jun 12, 2021
@Wolfe1 Wolfe1 deleted the sourcery/master branch June 12, 2021 15:03
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.

3 participants