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 main branch #4

Closed
wants to merge 1 commit into from
Closed

Conversation

sourcery-ai[bot]
Copy link

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

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!

HELP_DICT = dict()
HELP_DICT = {}
Copy link
Author

Choose a reason for hiding this comment

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

Lines 17-87 refactored with the following changes:

if not len(query)==2:
if len(query) != 2:
Copy link
Author

Choose a reason for hiding this comment

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

Function flex_cmd refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

Comment on lines -694 to +696
if spoiler==False:
if not spoiler:
Copy link
Author

Choose a reason for hiding this comment

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

Function additional_info_btn refactored with the following changes:

Comment on lines -717 to +721
if result[0]==False:
await cq.answer("No Data Available!!!")
return
if result[0]==False:
await cq.answer("No Data Available!!!")
return
Copy link
Author

Choose a reason for hiding this comment

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

Function featured_in_btn refactored with the following changes:

if find_gc==None:
if find_gc is None:
Copy link
Author

Choose a reason for hiding this comment

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

Function list_disabled refactored with the following changes:

Comment on lines -762 to +763
if auth is True:
if auth:
Copy link
Author

Choose a reason for hiding this comment

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

Function get_anime refactored with the following changes:

Comment on lines -869 to +867
if auth is True:
if auth:
Copy link
Author

Choose a reason for hiding this comment

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

Function get_anilist refactored with the following changes:

Comment on lines -993 to +988
if auth is True:
if auth:
Copy link
Author

Choose a reason for hiding this comment

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

Function get_manga refactored with the following changes:

Comment on lines -1040 to +1035
if auth is True:
if auth:
Copy link
Author

Choose a reason for hiding this comment

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

Function get_airing refactored with the following changes:

Comment on lines -1080 to +1078
k = await return_json_senpai(query=query, vars=vars_, auth=False if "user" in req else True, user=int(user))
k = await return_json_senpai(
query=query, vars=vars_, auth="user" not in req, user=int(user)
)

Copy link
Author

Choose a reason for hiding this comment

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

Function get_user refactored with the following changes:

Comment on lines -1168 to +1166
out = []
for i in data:
out.append(f"{i['index']}. `{i['name']}`\n")
out = [f"{i['index']}. `{i['name']}`\n" for i in 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 get_wo refactored with the following changes:

Comment on lines -1192 to +1193
ret = {}
keys = list(index.keys())
for i in range(len(keys)):
if query.lower() in keys[i].lower():
ret[keys[i]] = index[keys[i]]
return ret
return {
keys[i]: index[keys[i]]
for i in range(len(keys))
if query.lower() in keys[i].lower()
}
Copy link
Author

Choose a reason for hiding this comment

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

Function search_filler refactored with the following changes:

Comment on lines -1208 to +1207
total_ep = []
mix_ep = None
filler_ep = None
ac_ep = None
for tol in ttl_ep:
total_ep.append(tol.text)
total_ep = [tol.text for tol in ttl_ep]
Copy link
Author

Choose a reason for hiding this comment

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

Function parse_filler refactored with the following changes:

Comment on lines -162 to +164
if auth == False:
if not auth:
url = "https://graphql.anilist.co"
response = requests.post(url, json={"query": query, "variables": vars}).json()
return requests.post(url, json={"query": query, "variables": vars}).json()
Copy link
Author

Choose a reason for hiding this comment

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

Function return_json_senpai refactored with the following changes:

Comment on lines -188 to +189
th = "st" if x == "1" else "nd" if x == "2" else "rd" if x == "3" else "th"
return th
return "st" if x == "1" else "nd" if x == "2" else "rd" if x == "3" else "th"
Copy link
Author

Choose a reason for hiding this comment

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

Function pos_no refactored with the following changes:

if result[0]!=0 and result[0]!=6:
if result[0] not in [0, 6]:
Copy link
Author

Choose a reason for hiding this comment

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

Function get_btns refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Jun 18, 2021

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 16.45 🙂 15.41 🙂 -1.04 👍
Method Length 165.20 😞 163.96 😞 -1.24 👍
Working memory 15.40 ⛔ 15.23 ⛔ -0.17 👍
Quality 40.00% 😞 40.92% 😞 0.92% 👍
Other metrics Before After Change
Lines 2968 2961 -7
Changed files Quality Before Quality After Quality Change
anibot/init.py 64.56% 🙂 64.67% 🙂 0.11% 👍
anibot/plugins/anilist.py 43.55% 😞 43.64% 😞 0.09% 👍
anibot/plugins/bot.py 34.29% 😞 34.32% 😞 0.03% 👍
anibot/plugins/livechartme.py 58.63% 🙂 58.63% 🙂 0.00%
anibot/plugins/tracemoepy.py 29.89% 😞 29.90% 😞 0.01% 👍
anibot/plugins/watch.py 57.30% 🙂 55.92% 🙂 -1.38% 👎
anibot/utils/data_parser.py 33.62% 😞 36.06% 😞 2.44% 👍
anibot/utils/helper.py 54.60% 🙂 55.11% 🙂 0.51% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
anibot/plugins/bot.py en_dis__able_cmd 63 ⛔ 383 ⛔ 22 ⛔ 6.09% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
anibot/utils/data_parser.py get_anilist 36 ⛔ 649 ⛔ 28 ⛔ 8.20% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
anibot/utils/data_parser.py get_anime 36 ⛔ 639 ⛔ 27 ⛔ 8.42% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
anibot/plugins/anilist.py update_anilist_btn 57 ⛔ 500 ⛔ 16 ⛔ 10.01% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
anibot/utils/helper.py get_btns 32 😞 696 ⛔ 18 ⛔ 14.14% ⛔ 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!

@lostb053 lostb053 closed this Jan 11, 2022
@lostb053 lostb053 deleted the sourcery/main branch January 11, 2022 05:21
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