watchdogpolska/poradnia

View on GitHub

Showing 42 of 135 total issues

File test_views.py has 593 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import hashlib
import json
import os
import zipfile
from io import BytesIO
Severity: Major
Found in poradnia/letters/tests/test_views.py - About 1 day to fix

File tests.py has 568 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from datetime import timedelta
from pathlib import Path

import django
from atom.ext.guardian.tests import PermissionStatusMixin
Severity: Major
Found in poradnia/cases/tests.py - About 1 day to fix

File models.py has 526 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import itertools
import logging
import re
from datetime import datetime

Severity: Major
Found in poradnia/cases/models.py - About 1 day to fix

File cbv.py has 390 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import datetime
import json
import logging

import bleach
Severity: Minor
Found in poradnia/letters/views/cbv.py - About 5 hrs to fix

File forms.py has 377 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging

from atom.ext.crispy_forms.forms import HelperMixin, SingleButtonMixin
from atom.ext.tinycontent.forms import GIODOMixin
from atom.forms import PartialMixin
Severity: Minor
Found in poradnia/letters/forms.py - About 5 hrs to fix

File tests.py has 369 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json

from atom.mixins import AdminTestCaseMixin
from django.core import mail
from django.test import RequestFactory
Severity: Minor
Found in poradnia/users/tests.py - About 4 hrs to fix

Function debounce has 93 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function debounce(func, wait, options) {
    var lastArgs,
        lastThis,
        maxWait,
        result,
Severity: Major
Found in poradnia/navsearch/static/navsearch/lodash.debounce.js - About 3 hrs to fix

File cases.py has 297 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from collections import OrderedDict

from ajax_datatable import AjaxDatatableView
from atom.ext.guardian.views import RaisePermissionRequiredMixin
from braces.views import SelectRelatedMixin, UserFormKwargsMixin
Severity: Minor
Found in poradnia/cases/views/cases.py - About 3 hrs to fix

File common.py has 291 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Django settings for poradnia project.

For more information on this file, see
https://docs.djangoproject.com/en/dev/topics/settings/
Severity: Minor
Found in config/settings/common.py - About 3 hrs to fix

Function config has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var config = (function () {
    var appName = json.name;

    var path = {
        npm: './node_modules/',
Severity: Major
Found in gulpfile.js - About 2 hrs to fix

File views.py has 287 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from ajax_datatable import AjaxDatatableView
from atom.ext.crispy_forms.views import FormSetMixin
from atom.views import ActionMessageMixin, ActionView, FormInitialMixin
from braces.views import (
    FormValidMessageMixin,
Severity: Minor
Found in poradnia/advicer/views.py - About 2 hrs to fix

File admin.py has 270 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from django import forms
from django.contrib import admin
from django.contrib.admin import helpers
from django.contrib.auth.admin import UserAdmin as AuthUserAdmin
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
Severity: Minor
Found in poradnia/users/admin.py - About 2 hrs to fix

File views.py has 270 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import locale

from ajax_datatable import AjaxDatatableView
from atom.ext.guardian.views import RaisePermissionRequiredMixin
from braces.views import (
Severity: Minor
Found in poradnia/events/views.py - About 2 hrs to fix

File models.py has 270 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
import re

from allauth.account.models import EmailAddress
from django.contrib.auth.models import AbstractUser, UserManager
Severity: Minor
Found in poradnia/users/models.py - About 2 hrs to fix

Case has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class Case(models.Model):
    STAFF_ORDER_DEFAULT_FIELD = "last_action"
    USER_ORDER_DEFAULT_FIELD = "last_send"
    STATUS = Choices(
        ("0", "free", _("free")),
Severity: Minor
Found in poradnia/cases/models.py - About 2 hrs to fix

File tests.py has 254 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import datetime

from atom.mixins import AdminTestCaseMixin
from django.test import RequestFactory
from django.urls import reverse, reverse_lazy
Severity: Minor
Found in poradnia/advicer/tests.py - About 2 hrs to fix

Function process_django_view has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def process_django_view(app, what, name, obj, options, lines):
    res = get_resolver()
    flat_patterns = []

    def walker(flat_patterns, urlpatterns, namespace=None):
Severity: Minor
Found in docs/conf.py - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function get_html_from_eml_file has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def get_html_from_eml_file(eml_file=None):
    if eml_file is None:
        logger.error("Skipping due to missing eml file.")
        return ""
    eml_bytes = get_bytes_from_file(eml_file)
Severity: Minor
Found in poradnia/letters/utils.py - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function get_initial_queryset has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def get_initial_queryset(self, request=None):
        qs = super().get_initial_queryset(request).select_related().prefetch_related()

        helped_filter = []
        for helped in [("helped_yes", True), ("helped_no", False)]:
Severity: Minor
Found in poradnia/advicer/views.py - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function process_django_model has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def process_django_model(app, what, name, obj, options, lines):
    # This causes import errors if left outside the function
    from django.db import models

    # Only look at objects that inherit from Django's base model class
Severity: Minor
Found in docs/conf.py - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Severity
Category
Status
Source
Language