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 Dec 10, 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!

Comment on lines -63 to +64
channels = None
if args.channels:
channels = re.split('\s*,\s*', args.channels)
playlists = None
if args.playlists:
playlists = re.split('\s*,\s*', args.playlists)

channels = re.split('\s*,\s*', args.channels) if args.channels else None
playlists = re.split('\s*,\s*', args.playlists) if args.playlists else 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 add_channel_section refactored with the following changes:

storage = Storage("%s-oauth2.json" % sys.argv[0])
storage = Storage(f"{sys.argv[0]}-oauth2.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 get_authenticated_service refactored with the following changes:

storage = Storage("%s-oauth2.json" % sys.argv[0])
storage = Storage(f"{sys.argv[0]}-oauth2.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 get_authenticated_service refactored with the following changes:

storage = Storage("%s-oauth2.json" % sys.argv[0])
storage = Storage(f"{sys.argv[0]}-oauth2.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 get_authenticated_service refactored with the following changes:

storage = Storage("%s-oauth2.json" % sys.argv[0])
storage = Storage(f"{sys.argv[0]}-oauth2.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 get_authenticated_service refactored with the following changes:

storage = Storage("%s-oauth2.json" % sys.argv[0])
storage = Storage(f"{sys.argv[0]}-oauth2.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 get_authenticated_service refactored with the following changes:

storage = Storage("%s-oauth2.json" % sys.argv[0])
storage = Storage(f"{sys.argv[0]}-oauth2.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 get_authenticated_service refactored with the following changes:

tags = None
if options.keywords:
tags = options.keywords.split(',')

tags = options.keywords.split(',') if options.keywords else 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 initialize_upload refactored with the following changes:

api_service = build(API_SERVICE_NAME, API_VERSION, credentials=credentials)
return api_service
return build(API_SERVICE_NAME, API_VERSION, credentials=credentials)
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_authenticated_service refactored with the following changes:

Comment on lines -23 to +64
if DEVELOPER_KEY == "REPLACE_ME":
self.response.write("""You must set up a project and get an API key
if DEVELOPER_KEY == "REPLACE_ME":
self.response.write("""You must set up a project and get an API key
to run this project. Please visit
<landing page> to do so.""")
else:
youtube = build(
YOUTUBE_API_SERVICE_NAME,
YOUTUBE_API_VERSION,
developerKey=DEVELOPER_KEY)
search_response = youtube.search().list(
q="Hello",
part="id,snippet",
maxResults=5
).execute()
videos = []
channels = []
playlists = []
for search_result in search_response.get("items", []):
else:
youtube = build(
YOUTUBE_API_SERVICE_NAME,
YOUTUBE_API_VERSION,
developerKey=DEVELOPER_KEY)
search_response = youtube.search().list(
q="Hello",
part="id,snippet",
maxResults=5
).execute()

videos = []
channels = []
playlists = []

for search_result in search_response.get("items", []):
if search_result["id"]["kind"] == "youtube#video":
videos.append("%s (%s)" % (search_result["snippet"]["title"],
search_result["id"]["videoId"]))
videos.append(
f'{search_result["snippet"]["title"]} ({search_result["id"]["videoId"]})'
)
elif search_result["id"]["kind"] == "youtube#channel":
channels.append("%s (%s)" % (search_result["snippet"]["title"],
search_result["id"]["channelId"]))
channels.append(
f'{search_result["snippet"]["title"]} ({search_result["id"]["channelId"]})'
)
elif search_result["id"]["kind"] == "youtube#playlist":
playlists.append("%s (%s)" % (search_result["snippet"]["title"],
search_result["id"]["playlistId"]))

template_values = {
'videos': videos,
'channels': channels,
'playlists': playlists
}

self.response.headers['Content-type'] = 'text/plain'
template = JINJA_ENVIRONMENT.get_template('index.html')
self.response.write(template.render(template_values))
playlists.append(
f'{search_result["snippet"]["title"]} ({search_result["id"]["playlistId"]})'
)

template_values = {
'videos': videos,
'channels': channels,
'playlists': playlists
}

self.response.headers['Content-type'] = 'text/plain'
template = JINJA_ENVIRONMENT.get_template('index.html')
self.response.write(template.render(template_values))
Copy link
Author

Choose a reason for hiding this comment

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

Function MainHandler.get refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Dec 10, 2022

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 2.80 ⭐ 2.68 ⭐ -0.12 👍
Method Length 61.99 🙂 62.26 🙂 0.27 👎
Working memory 6.44 🙂 6.58 🙂 0.14 👎
Quality 78.08% 78.04% -0.04% 👎
Other metrics Before After Change
Lines 1711 1704 -7
Changed files Quality Before Quality After Quality Change
python/add_channel_section.py 84.29% ⭐ 85.77% ⭐ 1.48% 👍
python/add_featured_video.py 80.07% ⭐ 80.00% ⭐ -0.07% 👎
python/captions.py 80.65% ⭐ 80.62% ⭐ -0.03% 👎
python/channel_bulletin.py 79.95% ⭐ 79.89% ⭐ -0.06% 👎
python/comment_handling.py 83.78% ⭐ 83.75% ⭐ -0.03% 👎
python/comment_threads.py 79.72% ⭐ 79.68% ⭐ -0.04% 👎
python/create_broadcast.py 82.38% ⭐ 82.34% ⭐ -0.04% 👎
python/create_reporting_job.py 87.27% ⭐ 86.61% ⭐ -0.66% 👎
python/playlist_localizations.py 63.80% 🙂 63.06% 🙂 -0.74% 👎
python/retrieve_reports.py 84.34% ⭐ 84.29% ⭐ -0.05% 👎
python/set_watermark.py 75.30% ⭐ 75.27% ⭐ -0.03% 👎
python/unset_watermark.py 84.82% ⭐ 84.78% ⭐ -0.04% 👎
python/upload_banner.py 76.27% ⭐ 76.23% ⭐ -0.04% 👎
python/upload_thumbnail.py 81.77% ⭐ 81.69% ⭐ -0.08% 👎
python/upload_video.py 79.26% ⭐ 79.56% ⭐ 0.30% 👍
python/yt_analytics_report.py 82.66% ⭐ 82.32% ⭐ -0.34% 👎
python_appengine/search/main.py 53.78% 🙂 51.76% 🙂 -2.02% 👎
python_appengine/user_uploads/main.py 63.04% 🙂 65.22% 🙂 2.18% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
python_appengine/search/main.py MainHandler.get 9 🙂 187 😞 17 ⛔ 40.66% 😞 Try splitting into smaller methods. Extract out complex expressions
python/playlist_localizations.py set_playlist_localization 15 🙂 210 ⛔ 9 🙂 45.68% 😞 Try splitting into smaller methods
python_appengine/user_uploads/main.py MainHandler.post 8 ⭐ 202 😞 11 😞 48.51% 😞 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!


Copy link
Author

Choose a reason for hiding this comment

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

Function MainHandler.post refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
0 participants