Showing 99 of 270 total issues
File models.py
has 2260 lines of code (exceeds 250 allowed). Consider refactoring. Open
from typing import Tuple
import uuid
from functools import reduce
import requests
File serializers.py
has 1514 lines of code (exceeds 250 allowed). Consider refactoring. Open
from bothub.common.documents.repositoryqanlplog import RepositoryQANLPLogDocument
from django.conf import settings
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
File views.py
has 1428 lines of code (exceeds 250 allowed). Consider refactoring. Open
import json
import uuid
from django.conf import settings
from django.contrib.auth import get_user_model
File tests.py
has 1355 lines of code (exceeds 250 allowed). Consider refactoring. Open
import requests_mock
from django.conf import settings
from django.core.exceptions import ValidationError
from django.test import TestCase
from django.utils import timezone
File 0040_initial.py
has 1072 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Generated by Django 2.1.11 on 2019-12-09 19:22
import bothub.common.languages
import bothub.common.models
from django.conf import settings
File views.py
has 656 lines of code (exceeds 250 allowed). Consider refactoring. Open
import base64
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.validators import URLValidator
File tasks.py
has 588 lines of code (exceeds 250 allowed). Consider refactoring. Open
import json
import random
import requests
from datetime import timedelta
from urllib.parse import urlencode
File settings.py
has 530 lines of code (exceeds 250 allowed). Consider refactoring. Open
import os
import environ
import sentry_sdk
File languages.py
has 492 lines of code (exceeds 250 allowed). Consider refactoring. Open
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from django.core.exceptions import ValidationError
Function update
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
def update(self, request, *args, **kwargs): # pragma: no cover
serializer = RepositoryTranslatedExporterSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
for_language = serializer.data.get("language", None)
- Read upRead up
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
File utils.py
has 397 lines of code (exceeds 250 allowed). Consider refactoring. Open
import io
import math
import random
import re
import string
Repository
has 37 functions (exceeds 20 allowed). Consider refactoring. Open
class Repository(models.Model):
class Meta:
verbose_name = _("repository")
verbose_name_plural = _("repositories")
unique_together = ["owner", "slug"]
Function get_log
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def get_log(self, obj):
paginate_by = 10
try:
page = int(self.context.get("request").query_params.get("page_intent", 1))
- Read upRead up
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 clone_version
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def clone_version(
repository_id_from_original_version: str,
original_version_id: int,
clone_id: int,
*args,
- Read upRead up
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
File filters.py
has 302 lines of code (exceeds 250 allowed). Consider refactoring. Open
from django.conf import settings
from django.core.exceptions import ValidationError as DjangoValidationError
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext_lazy as _
from django_filters import rest_framework as filters
Function migrate
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def migrate(apps, schema_editor): # pragma: no cover
Repository = apps.get_model("common", "Repository")
RepositoryVersion = apps.get_model("common", "RepositoryVersion")
RepositoryEntityGroup = apps.get_model("common", "RepositoryEntityGroup")
RepositoryEntity = apps.get_model("common", "RepositoryEntity")
- Read upRead up
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
File views.py
has 276 lines of code (exceeds 250 allowed). Consider refactoring. Open
import re
import openpyxl
from django.db.models import Count, Q
from django.http import HttpResponse
NewRepositorySerializer
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class NewRepositorySerializer(serializers.ModelSerializer):
class Meta:
model = RepositoryVersion
fields = [
"repository_version_id",
Function remove_repository_project
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def remove_repository_project(self, request, **kwargs):
repository_version = self.get_object()
repository = repository_version.repository
- Read upRead up
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 clone_repository
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def clone_repository(
source_repository_id: str,
clone_repository_id: str,
new_owner_id: int,
language: str = None,
- Read upRead up
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"