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

Fixed shareus.io/shrs.link #33

Closed
wants to merge 2 commits into from
Closed

Fixed shareus.io/shrs.link #33

wants to merge 2 commits into from

Conversation

whitedemon938
Copy link
Collaborator

No description provided.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Diffusion123 - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Duplicate function definition detected. (link)
Here's what I looked at during the review
  • 🔴 General issues: 1 blocking issue, 3 other issues
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Docstrings: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@@ -288,6 +288,25 @@ async def shareus(url: str) -> str:
except:
raise DDLException("Link Extraction Failed")

async def shareus(url: str) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Duplicate function definition detected.

The function shareus is defined twice with the same signature. This will cause the first implementation to be overwritten. Consider renaming or merging the implementations if this was intentional.

@@ -288,6 +288,25 @@ async def shareus(url: str) -> str:
except:
raise DDLException("Link Extraction Failed")

async def shareus(url: str) -> str:
DOMAIN = f"https://api.shrslink.xyz"
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code_refinement): Consider using a constant for the DOMAIN value.

Since the DOMAIN value does not change, it would be more efficient and cleaner to define it as a constant at the module level, rather than redefining it within each function call.

Suggested change
DOMAIN = f"https://api.shrslink.xyz"
DOMAIN = "https://api.shrslink.xyz"
async def shareus(url: str) -> str:
code = url.split('/')[-1]
headers = {

'Origin':'https://shareus.io',
}
api = f"{DOMAIN}/v?shortid={code}&initial=true&referrer="
id = rget(api, headers=headers).json()['sid']
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (bug_risk): Potential issue with direct access to dictionary keys.

Directly accessing the 'sid' key could raise a KeyError if it is not present in the response. Consider using a safer access method like .get('sid') to avoid runtime exceptions.

Suggested change
id = rget(api, headers=headers).json()['sid']
response = rget(api, headers=headers).json()
id = response.get('sid')

api_2 = f"{DOMAIN}/get_link?sid={id}"
res = rget(api_2, headers=headers)
if res:
final = res.json()['link_info']['destination']
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (bug_risk): Potential nested dictionary access issue.

Similar to the previous comment, directly accessing nested keys ('link_info' and 'destination') could lead to KeyError. Using a safer method to check these keys exists before accessing them would be more robust.

Suggested change
final = res.json()['link_info']['destination']
link_info = res.json().get('link_info')
if link_info:
final = link_info.get('destination')
if final:
return final

@@ -288,6 +288,25 @@ async def shareus(url: str) -> str:
except:
raise DDLException("Link Extraction Failed")

async def shareus(url: str) -> str:
DOMAIN = f"https://api.shrslink.xyz"
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): We've found these issues:

@whitedemon938 whitedemon938 deleted the beta branch April 29, 2024 12:04
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.

1 participant