the-deep/server

View on GitHub

Showing 114 of 159 total issues

File dashboard_schema.py has 1019 lines of code (exceeds 999 allowed). Consider refactoring.
Open

import graphene
from dataclasses import dataclass
 
from django.db.models import Count, Sum, Avg, Case, Value, When
from django.contrib.postgres.aggregates.general import ArrayAgg
Severity: Major
Found in apps/assessment_registry/dashboard_schema.py - About 2 hrs to fix

    Function add_entries has a Cognitive Complexity of 25 (exceeds 12 allowed). Consider refactoring.
    Open

    def add_entries(self, entries):
    iterable_entries = entries[:Export.PREVIEW_ENTRY_SIZE] if self.is_preview else entries
    for i, entry in enumerate(iterable_entries):
    # Export each entry
    # Start building rows and export data for each exportable
    Severity: Minor
    Found in apps/export/entries/excel_exporter.py - About 2 hrs to fix

    Function extract has a Cognitive Complexity of 25 (exceeds 12 allowed). Consider refactoring.
    Open

    def extract(book):
    options = book.options if book.options else {}
    Sheet.objects.filter(book=book).delete() # Delete all previous sheets
    with book.get_file() as ods_file:
    workbook = pyexcel_ods.get_data(ods_file)
    Severity: Minor
    Found in apps/tabular/extractor/ods.py - About 2 hrs to fix

    Function add_entries_from_excel_data_for_static_column has a Cognitive Complexity of 25 (exceeds 12 allowed). Consider refactoring.
    Open

    def add_entries_from_excel_data_for_static_column(
    self,
    exportable,
    entry,
    lead,
    Severity: Minor
    Found in apps/export/entries/excel_exporter.py - About 2 hrs to fix

    Function get_assessment_export_summary has a Cognitive Complexity of 25 (exceeds 12 allowed). Consider refactoring.
    Open

    def get_assessment_export_summary(assessment, planned_assessment=False):
    """
    Returns json summary of all the tabs in the assessment including lead info
    """
    template = assessment.project.assessment_template
    Severity: Minor
    Found in apps/ary/export/summary.py - About 2 hrs to fix

    Function load_exportables has a Cognitive Complexity of 24 (exceeds 12 allowed). Consider refactoring.
    Open

    def load_exportables(self, exportables, regions=None):
    # Take all exportables that contains excel info
    widget_exportables = {
    exportable.widget_key: exportable
    for exportable in exportables.filter(
    Severity: Minor
    Found in apps/export/entries/excel_exporter.py - About 2 hrs to fix

    Function custom_exception_handler has a Cognitive Complexity of 24 (exceeds 12 allowed). Consider refactoring.
    Open

    def custom_exception_handler(exc, context):
    # First the get response by django rest framework
    response = exception_handler(exc, context)
     
    # For 500 errors, we create new response
    Severity: Minor
    Found in deep/exception_handler.py - About 2 hrs to fix

    File serializers.py has 1008 lines of code (exceeds 999 allowed). Consider refactoring.
    Open

    import logging
    from typing import Callable
    from django.conf import settings
    from django.shortcuts import get_object_or_404
     
     
    Severity: Major
    Found in apps/analysis/serializers.py - About 2 hrs to fix

      Function process has a Cognitive Complexity of 23 (exceeds 12 allowed). Consider refactoring.
      Open

      def process(docx, pptx=False, img_dir=None):
      text = u''
       
      # unzip the docx in memory
      zipf = zipfile.ZipFile(docx)
      Severity: Minor
      Found in utils/extractor/formats/docx.py - About 2 hrs to fix

      Function assessments_to_rows has a Cognitive Complexity of 21 (exceeds 12 allowed). Consider refactoring.
      Open

      def assessments_to_rows(self):
      for index, assessment in enumerate(self._assessments):
      rows = RowsBuilder(self.split, self.group, split=False)
      lead = assessment.lead
      rows.add_value_list([
      Severity: Minor
      Found in apps/export/assessments/excel_exporter.py - About 1 hr to fix

      Function get_group_by has a Cognitive Complexity of 20 (exceeds 12 allowed). Consider refactoring.
      Open

      def get_group_by(self, select, order_by):
      """
      Original SQLCompiler.get_group_by produces type error with tuple(params) when checking
      with seen in the last if statement. This is fixed in the newer version (checking on 3.0).
      """
      Severity: Minor
      Found in deep/compiler.py - About 1 hr to fix

      Function field_to_schema has a Cognitive Complexity of 20 (exceeds 12 allowed). Consider refactoring.
      Open

      def field_to_schema(field, camelcase=True):
      # title = force_text(field.label) if field.label else ''
      # if camelcase:
      # title = to_camelcase(title)
      # description = force_text(field.help_text) if field.help_text else ''
      Severity: Minor
      Found in apps/docs/inspectors.py - About 1 hr to fix

      Function add_rows_of_value_lists has a Cognitive Complexity of 19 (exceeds 12 allowed). Consider refactoring.
      Open

      def add_rows_of_value_lists(self, rows, col_span=1):
      # From a list of lists, for each list
      # Duplicate all rows and append each value of
      # that list to one set of rows
       
       
      Severity: Minor
      Found in apps/export/formats/xlsx.py - About 1 hr to fix

      Function save has a Cognitive Complexity of 19 (exceeds 12 allowed). Consider refactoring.
      Open

      def save(self):
      code = self.initial_data['code']
      strings = self.initial_data.get('strings') or []
      link_collections = self.initial_data.get('links') or {}
       
       
      Severity: Minor
      Found in apps/lang/serializers.py - About 1 hr to fix

      Function generate_chart has a Cognitive Complexity of 19 (exceeds 12 allowed). Consider refactoring.
      Open

      def generate_chart(field, chart_type, images_format=['svg']):
      params = {
      'x_label': field.title,
      'y_label': 'count',
      'x_params': {},
      Severity: Minor
      Found in apps/tabular/viz/renderer.py - About 1 hr to fix

      Function get_summary_json has a Cognitive Complexity of 19 (exceeds 12 allowed). Consider refactoring.
      Open

      def get_summary_json(self):
      # Formatting of underscored keywords, by default is upper case as given
      # by default_format() function below
      formatting = {
      'priority_sectors': lambda x: 'Most Unmet Needs Sectors',
      Severity: Minor
      Found in apps/ary/models.py - About 1 hr to fix

      Function validate_comment_type has a Cognitive Complexity of 18 (exceeds 12 allowed). Consider refactoring.
      Open

      def validate_comment_type(self, comment_type):
      # No validation needed for edit since we don't allow changing it
      if self.instance:
      if self.instance.comment_type != comment_type:
      raise serializers.ValidationError('Changing comment type is not allowed')
      Severity: Minor
      Found in apps/quality_assurance/serializers.py - About 1 hr to fix

      Function generate_assessments has a Cognitive Complexity of 18 (exceeds 12 allowed). Consider refactoring.
      Open

      def generate_assessments(self, project: Project, leads: typing.List[Lead]):
      # Organization data
      assessment_organization_types = [c[0] for c in AssessmentRegistryOrganization.Type.choices]
      organizations = list(
      Organization.objects.only('id')[:300]

      Function matrix2d_attribute_data_convertor has a Cognitive Complexity of 17 (exceeds 12 allowed). Consider refactoring.
      Open

      def matrix2d_attribute_data_convertor(data):
      value = data.get('value') or {}
      new_value = {}
      for row_key, row_data in value.items():
      new_row_data = {}
      Severity: Minor
      Found in apps/deep_migration/management/commands/migrate_af_changes_v2_v3.py - About 1 hr to fix

      Function get_score_json has a Cognitive Complexity of 17 (exceeds 12 allowed). Consider refactoring.
      Open

      def get_score_json(self):
      if not self.score:
      return {}
       
      pillars_raw = self.score['pillars'] or {}
      Severity: Minor
      Found in apps/ary/models.py - About 1 hr to fix
      Severity
      Category
      Status
      Source
      Language