Skip to content

Sourcery refactored Rajkumar branch#163

Open
sourcery-ai[bot] wants to merge 2 commits into
Rajkumarfrom
sourcery/Rajkumar
Open

Sourcery refactored Rajkumar branch#163
sourcery-ai[bot] wants to merge 2 commits into
Rajkumarfrom
sourcery/Rajkumar

Conversation

@sourcery-ai

@sourcery-ai sourcery-ai Bot commented Jul 23, 2022

Copy link
Copy Markdown

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

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

Help us improve this pull request!

@sourcery-ai sourcery-ai Bot requested a review from Awesome-RJ July 23, 2022 13:52
Comment on lines -522 to +527
text = "*{}* has the following settings for the *{}* module:\n\n".format(
escape_markdown(chat.title), CHAT_SETTINGS[module].__mod_name__
) + CHAT_SETTINGS[module].__chat_settings__(chat_id, user.id)
text = f"*{escape_markdown(chat.title)}* has the following settings for the *{CHAT_SETTINGS[module].__mod_name__}* module:\n\n" + CHAT_SETTINGS[
module
].__chat_settings__(
chat_id, user.id
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function settings_button refactored with the following changes:

Comment thread Cutiepii_Robot/events.py

if pattern is not None and not pattern.startswith("(?i)"):
args["pattern"] = "(?i)" + pattern
args["pattern"] = f"(?i){pattern}"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function register refactored with the following changes:

Comment thread Cutiepii_Robot/events.py

if pattern is not None and not pattern.startswith("(?i)"):
args["pattern"] = "(?i)" + pattern
args["pattern"] = f"(?i){pattern}"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function inlinequery refactored with the following changes:

sleep(1)
with open(f'backups/{datenow}.zip', 'rb') as bkp:
nm = f"{bot.username} backup \n" + datenow
nm = f"{bot.username} backup \n{datenow}"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function backup_db refactored with the following changes:

Comment on lines -39 to +44
text = f"Found **{0}** Demon{1} In This Chat!\n\nWould You Like To Hunt {2} ?".format(
demons, 's' if demons > 1 else '',
'Them All' if demons > 1 else 'That Demon')
text = f"Found **0** Demon1 In This Chat!\n\nWould You Like To Hunt 2 ?".format(
demons,
's' if demons > 1 else '',
'Them All' if demons > 1 else 'That Demon',
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function demons refactored with the following changes:

if not data or data is None:
return False
return data
return False if not data or data is None else data

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function check_media refactored with the following changes:

newcity = city.split(",")
if len(newcity[1]) == 2:
city = newcity[0].strip() + "," + newcity[1].strip()
city = f"{newcity[0].strip()},{newcity[1].strip()}"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function weather refactored with the following changes:


def button_expired_error(u: Update):
errmsg = f"This button has expired!"
errmsg = "This button has expired!"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function button_expired_error refactored with the following changes:

if user_id in admin_list:
return True
return False
return user_id in admin_list

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function is_user_admin refactored with the following changes:

if len(res) < 2:
return user_id, ""
return user_id, res[1]
return (user_id, "") if len(res) < 2 else (user_id, res[1])

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function id_from_reply refactored with the following changes:

@sourcery-ai sourcery-ai Bot force-pushed the sourcery/Rajkumar branch from ba1c06f to ed6e2b3 Compare July 23, 2022 13:52
@sourcery-ai sourcery-ai Bot force-pushed the sourcery/Rajkumar branch from ed6e2b3 to 74a30ef Compare July 23, 2022 13:52
@sourcery-ai

sourcery-ai Bot commented Jul 23, 2022

Copy link
Copy Markdown
Author

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 7.68 ⭐ 7.71 ⭐ 0.03 👎
Method Length 71.31 🙂 71.11 🙂 -0.20 👍
Working memory 7.68 🙂 7.69 🙂 0.01 👎
Quality 67.72% 🙂 67.59% 🙂 -0.13% 👎
Other metrics Before After Change
Lines 6003 5980 -23
Changed files Quality Before Quality After Quality Change
Cutiepii_Robot/main.py 51.15% 🙂 50.69% 🙂 -0.46% 👎
Cutiepii_Robot/events.py 93.90% ⭐ 93.81% ⭐ -0.09% 👎
Cutiepii_Robot/modules/cron_jobs.py 65.95% 🙂 65.95% 🙂 0.00%
Cutiepii_Robot/modules/demons.py 40.75% 😞 47.13% 😞 6.38% 👍
Cutiepii_Robot/modules/disable.py 58.39% 🙂 58.41% 🙂 0.02% 👍
Cutiepii_Robot/modules/disasters_new.py 64.88% 🙂 64.52% 🙂 -0.36% 👎
Cutiepii_Robot/modules/logomaker.py 47.94% 😞 49.99% 😞 2.05% 👍
Cutiepii_Robot/modules/memes.py 74.61% 🙂 74.66% 🙂 0.05% 👍
Cutiepii_Robot/modules/weather.py 46.00% 😞 46.00% 😞 0.00%
Cutiepii_Robot/modules/helper_funcs/admin_status_helpers.py 79.26% ⭐ 79.29% ⭐ 0.03% 👍
Cutiepii_Robot/modules/helper_funcs/chat_status.py 80.14% ⭐ 80.69% ⭐ 0.55% 👍
Cutiepii_Robot/modules/helper_funcs/extraction.py 36.42% 😞 35.32% 😞 -1.10% 👎
Cutiepii_Robot/modules/mongo/couples_mongo.py 94.24% ⭐ 93.92% ⭐ -0.32% 👎
Cutiepii_Robot/modules/sql/antichannel_sql.py 89.73% ⭐ 89.70% ⭐ -0.03% 👎
Cutiepii_Robot/modules/sql/antilinkedchannel_sql.py 88.16% ⭐ 88.03% ⭐ -0.13% 👎
Cutiepii_Robot/modules/sql/cleaner_sql.py 81.15% ⭐ 81.22% ⭐ 0.07% 👍
Cutiepii_Robot/modules/sql/feds_sql.py 73.09% 🙂 72.62% 🙂 -0.47% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
Cutiepii_Robot/modules/helper_funcs/extraction.py extract_unt_fedban 25 😞 275 ⛔ 18 ⛔ 22.11% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
Cutiepii_Robot/main.py start 21 😞 260 ⛔ 17 ⛔ 26.20% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
Cutiepii_Robot/modules/helper_funcs/extraction.py extract_user_and_text 20 😞 244 ⛔ 18 ⛔ 26.83% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
Cutiepii_Robot/modules/disable.py DisableAbleCommandHandler.check_update 24 😞 169 😞 20 ⛔ 28.18% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
Cutiepii_Robot/modules/demons.py dimonhandler 34 ⛔ 201 😞 10 😞 32.67% 😞 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!

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