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 Jun 5, 2020

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^

profile = super(ProfileForm, self).save(*args,**kwargs)
return profile
return super(ProfileForm, self).save(*args,**kwargs)
Copy link
Author

Choose a reason for hiding this comment

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

Function ProfileForm.save refactored with the following changes:

  • Inline variable that is only used once

if "http://" not in self.url and "https://" not in self.url and len(self.url) > 0:
if "http://" not in url and "https://" not in url and len(url) > 0:
Copy link
Author

Choose a reason for hiding this comment

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

Function Profile.get_url refactored with the following changes:

  • Use previously assigned local variable

Comment on lines -115 to +117
followers_count = Activity.objects.filter(to_user__pk=self.pk, activity_type=Activity.FOLLOW).count()
return followers_count
return Activity.objects.filter(
to_user__pk=self.pk, activity_type=Activity.FOLLOW
).count()
Copy link
Author

Choose a reason for hiding this comment

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

Function Profile.get_followers_count refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -126 to +129
following_count = Activity.objects.filter(from_user__pk=self.pk, activity_type=Activity.FOLLOW).count()
return following_count
return Activity.objects.filter(
from_user__pk=self.pk, activity_type=Activity.FOLLOW
).count()
Copy link
Author

Choose a reason for hiding this comment

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

Function Profile.get_following_count refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -17 to +31
if request.method == 'POST':
form = SignUpForm(request.POST)
if not form.is_valid():
messages.add_message(request, messages.ERROR, 'There was some problems while creating your account. Please review some fields before submiting again.')
return render(request, 'auth/signup.html', { 'form': form })
else:
username = form.cleaned_data.get('username')
email = form.cleaned_data.get('email')
password = form.cleaned_data.get('password')
User.objects.create_user(username=username, password=password, email=email)
user = authenticate(username=username, password=password)
login(request, user)
messages.add_message(request, messages.SUCCESS, 'Your account were successfully created.')
return HttpResponseRedirect('/' + username + '/')
else:
if request.method != 'POST':
return render(request, 'auth/signup.html', { 'form': SignUpForm() })
form = SignUpForm(request.POST)
if not form.is_valid():
messages.add_message(request, messages.ERROR, 'There was some problems while creating your account. Please review some fields before submiting again.')
return render(request, 'auth/signup.html', { 'form': form })
else:
username = form.cleaned_data.get('username')
email = form.cleaned_data.get('email')
password = form.cleaned_data.get('password')
User.objects.create_user(username=username, password=password, email=email)
user = authenticate(username=username, password=password)
login(request, user)
messages.add_message(request, messages.SUCCESS, 'Your account were successfully created.')
return HttpResponseRedirect('/' + username + '/')
Copy link
Author

Choose a reason for hiding this comment

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

Function signup refactored with the following changes:

  • Add guard clause

Comment on lines -221 to +225
if question_answer is not None:
if answer.id == question_answer.answer.id:
selected_answer = ' selected-answer'
if (
question_answer is not None
and answer.id == question_answer.answer.id
):
selected_answer = ' selected-answer'
Copy link
Author

Choose a reason for hiding this comment

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

Function build_quality_assessment_table refactored with the following changes:

  • Merge nested if conditions

Comment on lines -463 to +467
success = success + 1
success += 1
except:
error = error + 1
error += 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 _import_articles refactored with the following changes:

  • Replace assignment with augmented assignment

Comment on lines -588 to +590
row = u'''<tr oid="{0}" article-status="{1}">
return u'''<tr oid="{0}" article-status="{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 build_article_table_row refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -16 to +24
authors = list()
authors.append(review.author.profile.get_screen_name())
authors = [review.author.profile.get_screen_name()]
for author in review.co_authors.all():
authors.append(author.profile.get_screen_name())
p = document.add_paragraph(', '.join(authors))
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
document.add_paragraph('')

if 'description' in sections:
if review.description:
document.add_paragraph(review.description)
if 'description' in sections and review.description:
document.add_paragraph(review.description)
Copy link
Author

Choose a reason for hiding this comment

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

Function export_review_to_docx refactored with the following changes:

  • Merge nested if conditions
  • Replace list() with []
  • Merge append into list assignment

i = i + 1
i += 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 settings refactored with the following changes:

  • Replace assignment with augmented assignment

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