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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jul 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 YaMraaJ-debug July 28, 2022 04:11
sys.path.append(os.getcwd()+"/.lib/")
sys.path.append(f"{os.getcwd()}/.lib/")
Copy link
Author

Choose a reason for hiding this comment

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

Lines 4-12 refactored with the following changes:

resp_js = session.get('https://www.instagram.com/'+usrname+'/?__a=1').text
resp_js = session.get(f'https://www.instagram.com/{usrname}/?__a=1').text
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_page refactored with the following changes:

Comment on lines -31 to +43
if xdict != {}:
print(f"{su} {re}most used %s :" % text)
i = 0
for key, val in xdict.items():
if len(mail) == 1:
if key in mail[0]:
continue
print(f" {gr}%s : {wh}%s" % (key, val))
i += 1
if i > 4:
break
print()
else:
pass

if xdict == {}:
return
print(f"{su} {re}most used %s :" % text)
i = 0
for key, val in xdict.items():
if len(mail) == 1 and key in mail[0]:
continue
print(f" {gr}%s : {wh}%s" % (key, val))
i += 1
if i > 4:
break
print()

Copy link
Author

Choose a reason for hiding this comment

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

Function exinfo refactored with the following changes:

Comment on lines -68 to +74

resp_js = get_page(usrname)
js = json.loads(resp_js)
js = js['graphql']['user']

if js['is_private'] != False:
is_private = True

if js['edge_owner_to_timeline_media']['count'] > 12:
pass
else:

if js['edge_owner_to_timeline_media']['count'] <= 12:
Copy link
Author

Choose a reason for hiding this comment

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

Function user_info refactored with the following changes:

@@ -112,7 +108,6 @@ def user_info(usrname):

def highlight_post_info(i):

postinfo = {}
Copy link
Author

Choose a reason for hiding this comment

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

Function highlight_post_info refactored with the following changes:

Comment on lines -202 to +192

posts = []

for x in range(total_uploads):
posts.append(highlight_post_info(x))

posts = [highlight_post_info(x) for x in range(total_uploads)]
Copy link
Author

Choose a reason for hiding this comment

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

Function post_info refactored with the following changes:

if match == None:
if match 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 validate_mail refactored with the following changes:

data = requests.get("http://tinyurl.com/api-create.php?url=" + url)
data = requests.get(f"http://tinyurl.com/api-create.php?url={url}")
Copy link
Author

Choose a reason for hiding this comment

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

Function urlshortner refactored with the following changes:

output = {k: v for k, v in sorted(with_count.items(), reverse=True, key=lambda item: item[1])}
return output
return dict(sorted(with_count.items(), reverse=True, key=lambda item: item[1]))
Copy link
Author

Choose a reason for hiding this comment

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

Function sort_list refactored with the following changes:

exinfo = {}
email = r.findall(r"[_a-z0-9-\.]+[@@]{1}[a-z0-9]+\.[a-z0-9]+", stri.lower())
exinfo['email'] = email

exinfo = {'email': email}
Copy link
Author

Choose a reason for hiding this comment

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

Function find refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Jul 28, 2022

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 9.40 🙂 7.78 ⭐ -1.62 👍
Method Length 78.47 🙂 76.53 🙂 -1.94 👍
Working memory 6.27 🙂 5.86 ⭐ -0.41 👍
Quality 65.56% 🙂 68.05% 🙂 2.49% 👍
Other metrics Before After Change
Lines 323 306 -17
Changed files Quality Before Quality After Quality Change
main.py 81.95% ⭐ 81.80% ⭐ -0.15% 👎
.lib/api.py 55.04% 🙂 58.33% 🙂 3.29% 👍
.lib/check_mail.py 71.36% 🙂 71.36% 🙂 0.00%
.lib/local.py 87.35% ⭐ 88.58% ⭐ 1.23% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
.lib/api.py highlight_post_info 7 ⭐ 295 ⛔ 12 😞 42.85% 😞 Try splitting into smaller methods. Extract out complex expressions
.lib/api.py post_info 23 😞 148 😞 10 😞 43.20% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
.lib/api.py exinfo 18 🙂 168 😞 61.62% 🙂 Try splitting into smaller methods
.lib/api.py user_info 3 ⭐ 178 😞 7 🙂 63.83% 🙂 Try splitting into smaller methods
.lib/check_mail.py validate_mail 4 ⭐ 121 😞 6 ⭐ 71.36% 🙂 Try splitting into smaller methods

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