bothub-it/bothub-engine

View on GitHub

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
Severity: Major
Found in bothub/common/models.py - About 6 days to fix

    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
    Severity: Major
    Found in bothub/api/v2/repository/serializers.py - About 4 days to fix

      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
      Severity: Major
      Found in bothub/api/v2/repository/views.py - About 3 days to fix

        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
        Severity: Major
        Found in bothub/common/tests.py - About 3 days to fix

          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
          Severity: Major
          Found in bothub/common/migrations/0040_initial.py - About 2 days to fix

            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
            Severity: Major
            Found in bothub/api/v2/nlp/views.py - About 1 day to fix

              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
              Severity: Major
              Found in bothub/common/tasks.py - About 1 day to fix

                File settings.py has 530 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import os
                
                import environ
                import sentry_sdk
                
                
                Severity: Major
                Found in bothub/settings.py - About 1 day to fix

                  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
                  
                  
                  
                  Severity: Minor
                  Found in bothub/common/languages.py - About 7 hrs to fix

                    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)
                    Severity: Minor
                    Found in bothub/api/v2/translation/views.py - About 5 hrs 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

                    File utils.py has 397 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import io
                    import math
                    import random
                    import re
                    import string
                    Severity: Minor
                    Found in bothub/utils.py - About 5 hrs to fix

                      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"]
                      Severity: Minor
                      Found in bothub/common/models.py - About 4 hrs to fix

                        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))
                        Severity: Minor
                        Found in bothub/api/v2/evaluate/serializers.py - About 4 hrs 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 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,
                        Severity: Minor
                        Found in bothub/common/tasks.py - About 3 hrs 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

                        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
                        Severity: Minor
                        Found in bothub/api/v2/repository/filters.py - About 3 hrs to fix

                          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")
                          Severity: Minor
                          Found in bothub/common/migrations/0060_migrate_labels.py - About 2 hrs 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

                          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
                          Severity: Minor
                          Found in bothub/api/v2/translation/views.py - About 2 hrs to fix

                            NewRepositorySerializer has 21 functions (exceeds 20 allowed). Consider refactoring.
                            Open

                            class NewRepositorySerializer(serializers.ModelSerializer):
                                class Meta:
                                    model = RepositoryVersion
                                    fields = [
                                        "repository_version_id",
                            Severity: Minor
                            Found in bothub/api/v2/repository/serializers.py - About 2 hrs to fix

                              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
                              
                              
                              Severity: Minor
                              Found in bothub/api/v2/repository/views.py - About 2 hrs 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 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,
                              Severity: Minor
                              Found in bothub/common/tasks.py - About 2 hrs 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