-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
profile = super(ProfileForm, self).save(*args,**kwargs) | ||
return profile | ||
return super(ProfileForm, self).save(*args,**kwargs) |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
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() |
There was a problem hiding this comment.
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
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() |
There was a problem hiding this comment.
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
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 + '/') |
There was a problem hiding this comment.
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
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' |
There was a problem hiding this comment.
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
success = success + 1 | ||
success += 1 | ||
except: | ||
error = error + 1 | ||
error += 1 |
There was a problem hiding this comment.
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
row = u'''<tr oid="{0}" article-status="{1}"> | ||
return u'''<tr oid="{0}" article-status="{1}"> |
There was a problem hiding this comment.
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
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
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: