File test_job_views.py
has 504 lines of code (exceeds 250 allowed). Consider refactoring.
from unittest.mock import patch
from django.contrib.auth.models import User
from django.http import HttpRequest
from django.test import Client, TestCase, override_settings
File test_job_model.py
has 283 lines of code (exceeds 250 allowed). Consider refactoring.
from datetime import datetime, timedelta
from hashlib import sha512
from unittest.mock import patch
import responses
from django.contrib.auth.models import User
Function process_response
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
def process_response(self, request, response):
response["Cache-Control"] = "max-age=%d" % MAX_AGE
if response.status_code != 404:
return response
Function subscribe
has 32 lines of code (exceeds 25 allowed). Consider refactoring.
function subscribe(reg) {
reg.pushManager.getSubscription().then(
function(subscription) {
var metaObj, applicationServerKey, options;
Function unsubscribe
has 28 lines of code (exceeds 25 allowed). Consider refactoring.
function unsubscribe(reg) {
reg.pushManager.getSubscription()
.then(
function(subscription) {
Function handle
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def handle(self, *args, **options):
if not settings.GITHUB_ACCESS_TOKEN or not settings.GITHUB_DEFAULT_REPO:
return "False"
g = Github(settings.GITHUB_ACCESS_TOKEN)
Function initialiseState
has 27 lines of code (exceeds 25 allowed). Consider refactoring.
function initialiseState(reg) {
if (!(reg.showNotification)) {
subBtn.textContent = document.getElementById('push-subscribe').getAttribute("data-push-subscribe-label");
Function section_reshaping
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def section_reshaping(sections, issue_content):
"""
This function enables markdown <h2> to be detected and inserted
in the right section of the original dictionary.
Function setup_labels
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def setup_labels(labels, content):
content["salary_range"] = 10
content["contract_form"] = 1
content["job_level"] = 5
content["remote"] = False
Function handle
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def handle(self, *args, **options):
for user in tqdm(User.objects.exclude(profile__github__isnull=True)):
user_data = {
"github": {
Function format_issue_content
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def format_issue_content(issue_content):
sections = {
"Nossa empresa": "",
"Descrição da vaga": "",
"Local": "",
Function job_view
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def job_view(request, unique_slug):
job = get_object_or_404(Job, unique_slug=unique_slug)
context = {
"job": job,
"logged_in": False,
Function handle
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def handle(self, *args, **options):
driver = driver_factory()
for user in tqdm(
User.objects.filter(profile__linkedin__isnull=False).exclude(
Function handle
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def handle(self, *args, **options):
headers = {
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS 11.1.0; rv:42.0) Gecko/20100101 Firefox/42.0"
}
response = requests.get(
Function test
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def test(sender, instance, created, **kwargs):
if not created or not instance.receive_emails:
return False
message_text = " ".join(
Avoid too many return
statements within this function.
return redirect("/")
Function pythonista_change_password
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def pythonista_change_password(request):
template_name = "user_area/pythonistas-area-password-change.html"
if request.user.has_usable_password():
form = PasswordChangeForm
else:
Function append_social_info_to_context
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def append_social_info_to_context(request):
return_content = {}
try:
user = request.user