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

handle PYL-E1305 (Sourcery refactored) #23

Closed
wants to merge 1 commit into from
Closed

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Nov 8, 2021

Pull Request #22 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 master branch, then run:

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

Help us improve this pull request!

Comment on lines -1286 to +1293
if get_fedlog:
if eval(get_fedlog):
bot.send_message(
get_fedlog,
"*{}* has updated federation rules for fed *{}*".format(
user.first_name, getfed["fname"]
),
parse_mode="markdown",
)
if get_fedlog and eval(get_fedlog):
bot.send_message(
get_fedlog,
"*{}* has updated federation rules for fed *{}*".format(
user.first_name, getfed["fname"]
),
parse_mode="markdown",
)
Copy link
Author

Choose a reason for hiding this comment

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

Function set_frules refactored with the following changes:

Comment on lines -1426 to +1437
if cek.get("status"):
if jam <= int(cek.get("value")):
waktu = time.strftime(
"%H:%M:%S %d/%m/%Y", time.localtime(cek.get("value"))
)
update.effective_message.reply_text(
"You can backup your data once every 30 minutes!\nYou can back up data again at `{}`".format(
waktu
),
parse_mode=ParseMode.MARKDOWN,
)
return
if user.id not in SUDO_USERS:
put_chat(chat.id, new_jam, chat_data)
else:
if user.id not in SUDO_USERS:
put_chat(chat.id, new_jam, chat_data)
if cek.get("status") and jam <= int(cek.get("value")):
waktu = time.strftime(
"%H:%M:%S %d/%m/%Y", time.localtime(cek.get("value"))
)
update.effective_message.reply_text(
"You can backup your data once every 30 minutes!\nYou can back up data again at `{}`".format(
waktu
),
parse_mode=ParseMode.MARKDOWN,
)
return
if user.id not in SUDO_USERS:
put_chat(chat.id, new_jam, chat_data)
Copy link
Author

Choose a reason for hiding this comment

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

Function fed_ban_list refactored with the following changes:

Comment on lines -1694 to +1693
if cek.get("status"):
if jam <= int(cek.get("value")):
waktu = time.strftime(
"%H:%M:%S %d/%m/%Y", time.localtime(cek.get("value"))
)
update.effective_message.reply_text(
"You can get your data once every 30 minutes!\nYou can get data again at `{}`".format(
waktu
),
parse_mode=ParseMode.MARKDOWN,
)
return
if user.id not in SUDO_USERS:
put_chat(chat.id, new_jam, chat_data)
else:
if user.id not in SUDO_USERS:
put_chat(chat.id, new_jam, chat_data)
if cek.get("status") and jam <= int(cek.get("value")):
waktu = time.strftime(
"%H:%M:%S %d/%m/%Y", time.localtime(cek.get("value"))
)
update.effective_message.reply_text(
"You can get your data once every 30 minutes!\nYou can get data again at `{}`".format(
waktu
),
parse_mode=ParseMode.MARKDOWN,
)
return
if user.id not in SUDO_USERS:
put_chat(chat.id, new_jam, chat_data)
Copy link
Author

Choose a reason for hiding this comment

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

Function fed_import_bans refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Nov 8, 2021

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.65%.

Quality metrics Before After Change
Complexity 48.82 ⛔ 44.91 ⛔ -3.91 👍
Method Length 181.07 😞 179.90 😞 -1.17 👍
Working memory 18.54 ⛔ 18.45 ⛔ -0.09 👍
Quality 30.72% 😞 31.37% 😞 0.65% 👍
Other metrics Before After Change
Lines 2437 2418 -19
Changed files Quality Before Quality After Quality Change
tg_bot/modules/feds.py 30.72% 😞 31.37% 😞 0.65% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
tg_bot/modules/feds.py fed_ban 133 ⛔ 852 ⛔ 31 ⛔ 0.78% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
tg_bot/modules/feds.py fed_import_bans 108 ⛔ 770 ⛔ 31 ⛔ 0.88% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
tg_bot/modules/feds.py unfban 60 ⛔ 524 ⛔ 19 ⛔ 6.95% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
tg_bot/modules/feds.py fed_ban_list 40 ⛔ 595 ⛔ 25 ⛔ 7.65% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
tg_bot/modules/feds.py fed_stat_user 57 ⛔ 406 ⛔ 16 ⛔ 10.76% ⛔ Refactor to reduce nesting. 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!

@Ryomen-Sukuna Ryomen-Sukuna deleted the sourcery/master branch November 8, 2021 17:10
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

1 participant