Skip to content

Sourcery refactored main branch#66

Open
sourcery-ai[bot] wants to merge 1 commit intomainfrom
sourcery/main
Open

Sourcery refactored main branch#66
sourcery-ai[bot] wants to merge 1 commit intomainfrom
sourcery/main

Conversation

@sourcery-ai
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Mar 28, 2023

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

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from DaTiC0 March 28, 2023 06:47
url = 'https://accounts.google.com/o/oauth2/token'
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
data = 'grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=' + signed_jwt
data = f'grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion={signed_jwt}'
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 get_access_token refactored with the following changes:

Comment on lines -38 to +41
headers = {
'X-GFE-SSL': 'yes',
'Authorization': 'Bearer ' + access_token
}
headers = {'X-GFE-SSL': 'yes', 'Authorization': f'Bearer {access_token}'}
data = report_state_file
response = requests.post(url, headers=headers, json=data)
print('Response: ' + response.text)
print(f'Response: {response.text}')
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 report_state refactored with the following changes:

Comment on lines -54 to +51
success = report_state(access_token, report_state_file)

if success:
if success := report_state(access_token, report_state_file):
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 main refactored with the following changes:

"id": k,
}
DEVICE.update(v)
DEVICE |= v
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 rsync refactored with the following changes:

for device in i['payload']['devices']:
deviceId = device['id']
print('DEVICE ID: ' + deviceId)
print(f'DEVICE ID: {deviceId}')
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 onQuery refactored with the following changes:

Comment on lines -22 to +21
print('Published message with mid {}.'
.format(mid))
print(f'Published message with mid {mid}.')
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 handle_publish refactored with the following changes:

Comment on lines -28 to +26
print('Subscription id {} granted with qos {}.'
.format(mid, granted_qos))
print(f'Subscription id {mid} granted with qos {granted_qos}.')
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 handle_subscribe refactored with the following changes:

Comment on lines -34 to +31
print('Received message on topic {}: {}'
.format(message.topic, message.payload.decode()))
print(f'Received message on topic {message.topic}: {message.payload.decode()}')
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 handle_mytopic refactored with the following changes:

Comment on lines -40 to +36
print('Received message on topic {}: {}'
.format(message.topic, message.payload.decode()))
print(f'Received message on topic {message.topic}: {message.payload.decode()}')
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 handle_ztopic refactored with the following changes:

print("this is authorize")
user = get_current_user()
print("Authorize User: %s" % user)
print(f"Authorize User: {user}")
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 authorize refactored with the following changes:

@sourcery-ai
Copy link
Contributor Author

sourcery-ai bot commented Mar 28, 2023

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 1.75 ⭐ 1.77 ⭐ 0.02 👎
Method Length 44.71 ⭐ 44.71 ⭐ 0.00
Working memory 6.55 🙂 6.69 🙂 0.14 👎
Quality 80.24% 79.69% -0.55% 👎
Other metrics Before After Change
Lines 489 468 -21
Changed files Quality Before Quality After Quality Change
ReportState.py 83.87% ⭐ 83.70% ⭐ -0.17% 👎
action_devices.py 76.18% ⭐ 76.22% ⭐ 0.04% 👍
app.py 67.44% 🙂 67.53% 🙂 0.09% 👍
auth.py 79.92% ⭐ 79.30% ⭐ -0.62% 👎
generate_service_account_file.py 84.75% ⭐ 84.63% ⭐ -0.12% 👎
models.py 94.86% ⭐ 94.17% ⭐ -0.69% 👎
notifications.py 88.57% ⭐ 88.42% ⭐ -0.15% 👎
routes.py 82.85% ⭐ 82.80% ⭐ -0.05% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
action_devices.py actions 7 ⭐ 112 🙂 12 😞 56.87% 🙂 Extract out complex expressions
action_devices.py commands 6 ⭐ 100 🙂 12 😞 59.44% 🙂 Extract out complex expressions
routes.py authorize 2 ⭐ 111 🙂 10 😞 65.54% 🙂 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!

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.

0 participants