MAKENTNU/web

View on GitHub

Showing 230 of 230 total issues

Similar blocks of code found in 5 locations. Consider refactoring.
Open

article_adminpatterns = [
path("", article_views.AdminArticleListView.as_view(), name='admin_article_list'),
path("add/", article_views.ArticleCreateView.as_view(), name='article_create'),
path("<int:pk>/", include(specific_article_adminpatterns)),
Severity: Major
Found in src/news/urls.py and 4 other locations - About 1 hr to fix
src/announcements/urls.py on lines 16..19
src/faq/urls.py on lines 16..19
src/faq/urls.py on lines 26..29
src/makerspace/urls.py on lines 24..27

Similar blocks of code found in 5 locations. Consider refactoring.
Open

category_adminpatterns = [
path("", views.AdminCategoryListView.as_view(), name='admin_category_list'),
path("add/", views.CategoryCreateView.as_view(), name='category_create'),
path("<int:pk>/", include(specific_category_adminpatterns)),
Severity: Major
Found in src/faq/urls.py and 4 other locations - About 1 hr to fix
src/announcements/urls.py on lines 16..19
src/faq/urls.py on lines 16..19
src/makerspace/urls.py on lines 24..27
src/news/urls.py on lines 52..55

Similar blocks of code found in 5 locations. Consider refactoring.
Open

equipment_adminpatterns = [
path("", views.AdminEquipmentListView.as_view(), name='admin_equipment_list'),
path("add/", views.EquipmentCreateView.as_view(), name='equipment_create'),
path("<int:pk>/", include(specific_equipment_adminpatterns)),
Severity: Major
Found in src/makerspace/urls.py and 4 other locations - About 1 hr to fix
src/announcements/urls.py on lines 16..19
src/faq/urls.py on lines 16..19
src/faq/urls.py on lines 26..29
src/news/urls.py on lines 52..55

Cyclomatic complexity is too high in class ArticleDetailView. (6)
Open

class ArticleDetailView(PermissionRequiredMixin, DetailView):
model = Article
template_name = 'news/article/article_detail.html'
context_object_name = 'news_obj'
 
 
Severity: Minor
Found in src/news/views/article.py by radon

Cyclomatic complexity is too high in method post. (6)
Open

def post(self, request):
try:
rating = int(request.POST.get('rating'))
skill_id = int(request.POST.get('skill'))
except ValueError:
Severity: Minor
Found in src/checkin/views.py by radon

Cyclomatic complexity is too high in method get_users_matching_search. (6)
Open

def get_users_matching_search(cls, search_string: str) -> tuple[list[User], list[User]]:
query = Q()
for search_fragment in search_string.split():
user_search_field_subquery = Q()
for field in cls.user_search_fields:
Severity: Minor
Found in src/news/views/event.py by radon

Cyclomatic complexity is too high in method formfield_for_dbfield. (6)
Open

def formfield_for_dbfield(self, db_field, request, **kwargs):
multi_lingual_admin_formfield = create_multi_lingual_admin_formfield(
db_field, request, **kwargs,
enable_changing_rich_text_source=self.enable_changing_rich_text_source,
)
Severity: Minor
Found in src/util/admin_utils.py by radon

Cyclomatic complexity is too high in method can_register. (6)
Open

def can_register(self, user: User):
# Admins should always be allowed
if user.has_perm('news.cancel_ticket'):
return True
 
 
Severity: Minor
Found in src/news/models.py by radon

Cyclomatic complexity is too high in class Command. (6)
Open

class Command(makemessages.Command):
help = (
f"{makemessages.Command.help}"
"\n\nIf no --ignore options are provided, it's by default set to the names of all top-level directories under the 'REPO_DIR' setting,"
" except for the Django source directory (the 'BASE_DIR' setting)."

Cyclomatic complexity is too high in function serve_interpolated. (6)
Open

def serve_interpolated(request, path, *args, **kwargs):
"""
This view extends the functionality of Django's ``serve()`` method
with the same interpolation logic as ``ManifestStaticFilesStorage`` implements.
"""
Severity: Minor
Found in src/web/static.py by radon

Cyclomatic complexity is too high in method clean. (6)
Open

def clean(self):
cleaned_data = super().clean()
user = cleaned_data.get('user')
all_users = cleaned_data.get('all')
 
 
Severity: Minor
Found in src/make_queue/forms/quota.py by radon

Cyclomatic complexity is too high in function has_any_permissions_for. (6)
Open

def has_any_permissions_for(user: User, model__or__app_and_model: Type[models.Model] | str):
"""
:param user: the user to check permissions for
:param model__or__app_and_model: either a model type, a string with the name of a uniquely named model,
or a string of the format "{app_label}.{model_name}"

Cyclomatic complexity is too high in function block_join. (6)
Open

def block_join(object_collection: Sequence | QuerySet, sep="<b>&bull;</b>", multiline=True):
if len(object_collection) == 0:
return ""
 
tag = '<div style="display: inline-block; white-space: nowrap;">'
Severity: Minor
Found in src/util/html_utils.py by radon

Cyclomatic complexity is too high in class MultiLingualRichTextFormField. (6)
Open

class MultiLingualRichTextFormField(MultiLingualFormField):
# Most of the manually added tags, attributes, styles and protocols, are based on the HTML generated by CKEditor
ALLOWED_TAGS = {
*bleach.sanitizer.ALLOWED_TAGS,
"div", "p", "span", "br", "hr", "pre",
Severity: Minor
Found in src/web/multilingual/formfields.py by radon

Cyclomatic complexity is too high in method dispatch. (6)
Open

def dispatch(self, request, *args, **kwargs):
response = super().dispatch(request, *args, **kwargs)
focused_object = self.focused_object
if (
# If the event / time place has no tickets
Severity: Minor
Found in src/news/views/event.py by radon

Cyclomatic complexity is too high in class ContentBoxForm. (6)
Open

class ContentBoxForm(forms.ModelForm):
class Meta:
model = ContentBox
fields = ('title', 'content',)
 
 
Severity: Minor
Found in src/contentbox/forms.py by radon

Cyclomatic complexity is too high in method get_context_data. (6)
Open

def get_context_data(self, **kwargs):
"""
Creates dict with skill titles as keys and
the highest corresponding skill level as its pair value (quick fix) to show on website.
"""
Severity: Minor
Found in src/checkin/views.py by radon

Cyclomatic complexity is too high in method save. (6)
Open

def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
if self.pk is None: # Creation of new object
self._connect_to_user()
else:
old = Printer3DCourse.objects.get(pk=self.pk)
Severity: Minor
Found in src/make_queue/models/course.py by radon

Cyclomatic complexity is too high in method clean. (6)
Open

def clean(self):
"""
Cleans and validates the given form.
 
:return: A dictionary of clean data
Severity: Minor
Found in src/make_queue/forms/reservation.py by radon

Cyclomatic complexity is too high in function login_wrapper. (6)
Open

def login_wrapper(request, backend, *args, **kwargs):
"""
Handles the callback from the social django login. Updating the full name of the user, and possibly their username.
Usernames are found in NTNUs LDAP server using the email to search. For some reason, some users do not have their
email in the NTNU LDAP system. For these users we derive their username from the local part of their email. This
Severity: Minor
Found in src/dataporten/views.py by radon
Severity
Category
Status
Source
Language