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 #22

Merged
merged 2 commits into from Apr 28, 2022
Merged

Sourcery refactored master branch #22

merged 2 commits into from Apr 28, 2022

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Apr 28, 2022

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 Honkertonken April 28, 2022 13:15
@sourcery-ai sourcery-ai bot force-pushed the sourcery/master branch 6 times, most recently from 29308f5 to 3572f73 Compare April 28, 2022 13:15
amari_bot = ctx.guild.get_member(339254240012664832)
if amari_bot:
if amari_bot := ctx.guild.get_member(339254240012664832):
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 AmariLevel.amari refactored with the following changes:

Comment on lines -147 to -152
else:
pass
else:
pass
else:
pass
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 AutoKick.on_member_join refactored with the following changes:

Comment on lines -98 to +124
if await self.config.guild(message.guild).enabled():
if (
not isinstance(message.channel, discord.TextChannel)
or message.type != discord.MessageType.default
or message.author.id == self.bot.user.id
or message.author.bot
or message.clean_content is None
or message.author.id in await self.config.guild(message.guild).blacklisted_ids()
if not await self.config.guild(message.guild).enabled():
return
if (
not isinstance(message.channel, discord.TextChannel)
or message.type != discord.MessageType.default
or message.author.id == self.bot.user.id
or message.author.bot
or message.clean_content is None
or message.author.id in await self.config.guild(message.guild).blacklisted_ids()
):
return
content = message.clean_content
dad = ", im dad" if await self.config.guild(message.guild).dad() else " "
if search.search(content):
try:
back = search.search(content).group(1)
await message.reply(
f"Hi {back}{dad}",
allowed_mentions=discord.AllowedMentions(
everyone=False, roles=False, users=False
),
)
except (
discord.HTTPException,
discord.Forbidden,
):
return
content = message.clean_content
if await self.config.guild(message.guild).dad():
dad = ", im dad"
else:
dad = " "
if search.search(content):
try:
back = search.search(content).group(1)
await message.reply(
f"Hi {back}{dad}",
allowed_mentions=discord.AllowedMentions(
everyone=False, roles=False, users=False
),
)
except (
discord.HTTPException,
discord.Forbidden,
):
pass
else:
pass
pass
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 HiBack.on_message_without_command refactored with the following changes:

Comment on lines -91 to +94
search_string=str(query),
search_string=query,
blacklist=["nsfw", "religious", "political", "racist", "sexist"],
)

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 Jokes.jokesearch refactored with the following changes:

Comment on lines -104 to +112
if int(number) < 10:
if number < 10:
j = await jokes()
joke = await j.get_joke(
response_format="txt",
amount=int(number),
amount=number,
blacklist=["nsfw", "religious", "political", "racist", "sexist"],
)

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 Jokes.mulitjoke refactored with the following changes:

@sourcery-ai
Copy link
Contributor Author

sourcery-ai bot commented Apr 28, 2022

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 3.82 ⭐ 2.94 ⭐ -0.88 👍
Method Length 45.11 ⭐ 44.82 ⭐ -0.29 👍
Working memory 8.39 🙂 8.21 🙂 -0.18 👍
Quality 74.39% 🙂 76.03% 1.64% 👍
Other metrics Before After Change
Lines 429 422 -7
Changed files Quality Before Quality After Quality Change
amarilevel/amarilevel.py 48.28% 😞 48.55% 😞 0.27% 👍
autokick/autokick.py 72.74% 🙂 74.32% 🙂 1.58% 👍
buttoninvite/url_button.py 85.41% ⭐ 85.41% ⭐ 0.00%
hiback/hiback.py 75.07% ⭐ 78.24% ⭐ 3.17% 👍
jokes/jokes.py 86.19% ⭐ 86.92% ⭐ 0.73% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
amarilevel/amarilevel.py AmariLevel.amari 10 🙂 181 😞 23 ⛔ 36.44% 😞 Try splitting into smaller methods. Extract out complex expressions
hiback/hiback.py HiBack.on_message_without_command 7 ⭐ 132 😞 13 😞 52.83% 🙂 Try splitting into smaller methods. Extract out complex expressions
autokick/autokick.py AutoKick.on_member_join 10 🙂 140 😞 10 😞 54.30% 🙂 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!

@codeclimate
Copy link

codeclimate bot commented Apr 28, 2022

Code Climate has analyzed commit 92a5e04 and detected 0 issues on this pull request.

View more on Code Climate.

@Honkertonken Honkertonken merged commit 577e496 into master Apr 28, 2022
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