the-deep/server

View on GitHub

Showing 114 of 159 total issues

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

def validate_comment_type(self, comment_type):
if self.instance and self.instance.comment_type: # No validation needed for edit
return self.instance.comment_type
 
if comment_type == EntryReviewComment.CommentType.COMMENT:
Severity: Minor
Found in apps/quality_assurance/serializers.py - About 1 hr to fix

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

def _validate_filters(self, data_type, filters):
def _validate_filterset(filter_data, filter_key, filter_set):
filter_data = filter_data.get(filter_key)
if not filter_data:
return
Severity: Minor
Found in apps/export/serializers.py - About 1 hr to fix

Function get_widgets_from_conditional has a Cognitive Complexity of 16 (exceeds 12 allowed). Consider refactoring.
Open

def get_widgets_from_conditional(conditional_widget):
af_widget_qs = Widget.objects.filter(analysis_framework_id=conditional_widget.analysis_framework_id)
widgets = conditional_widget.properties.get('data', {}).get('widgets', [])
for conditional_widget_data in widgets:
widget_data = conditional_widget_data['widget']
Severity: Minor
Found in apps/deep_migration/management/commands/migrate_af_changes_v2_v3.py - About 55 mins to fix

Function _extract_from_tags has a Cognitive Complexity of 16 (exceeds 12 allowed). Consider refactoring.
Open

def _extract_from_tags(page):
for time in page.findAll('time'):
datetime = time.get('datetime', '')
if len(datetime) > 0:
return str_to_date(datetime)
Severity: Minor
Found in utils/date_extractor.py - About 55 mins to fix

Function _generate_for_levels has a Cognitive Complexity of 16 (exceeds 12 allowed). Consider refactoring.
Open

def _generate_for_levels(
self,
levels,
level_entries_map,
valid_levels,
Severity: Minor
Found in apps/export/entries/report_exporter.py - About 55 mins to fix

Function convert_serializer_field has a Cognitive Complexity of 16 (exceeds 12 allowed). Consider refactoring.
Open

def convert_serializer_field(field, is_input=True, convert_choices_to_enum=True, force_optional=False):
"""
Converts a django rest frameworks field to a graphql field
and marks the field as required if we are creating an input type
and the field itself is required
Severity: Minor
Found in utils/graphene/mutation.py - About 55 mins to fix

Function load_exportable_titles has a Cognitive Complexity of 16 (exceeds 12 allowed). Consider refactoring.
Open

def load_exportable_titles(self, data, regions):
export_type = data.get('type')
col_type = data.get('col_type')
exportable_titles = []
 
 
Severity: Minor
Found in apps/export/entries/excel_exporter.py - About 55 mins to fix

Function fetch has a Cognitive Complexity of 16 (exceeds 12 allowed). Consider refactoring.
Open

def fetch(self, params):
results = []
updated_params = copy.deepcopy(params)
 
country = updated_params.pop('country', None)
Severity: Minor
Found in apps/unified_connector/sources/unhcr_portal.py - About 55 mins to fix

Function get has a Cognitive Complexity of 16 (exceeds 12 allowed). Consider refactoring.
Open

def get(self, request, version=None):
project_query = request.GET.get('project')
fields_query = request.GET.get('fields')
 
projects = None
Severity: Minor
Found in apps/project/views.py - About 55 mins to fix

Function add_headers has a Cognitive Complexity of 15 (exceeds 12 allowed). Consider refactoring.
Open

def add_headers(self):
for sheet, headerinfo in self.sheet_headers.items():
header_row = []
sub_header_row = []
for header, info in headerinfo.items():
Severity: Minor
Found in apps/export/assessments/excel_exporter.py - About 45 mins to fix

Function get_project_ary_entry_stats has a Cognitive Complexity of 15 (exceeds 12 allowed). Consider refactoring.
Open

def get_project_ary_entry_stats(project):
"""
NOTE: This is a custom made API for Ary VIz and might not work for all Assessment Frameworks.
"""
# Sample config [Should work what modification if fixture is used to load]
Severity: Minor
Found in apps/ary/stats.py - About 45 mins to fix

Function convert_matrix2d_export has a Cognitive Complexity of 15 (exceeds 12 allowed). Consider refactoring.
Open

def convert_matrix2d_export(self, element):
excel = {
'type': 'multiple',
'titles': ['Dimension', 'Subdimension', 'Sector', 'Subsectors'],
}
Severity: Minor
Found in apps/deep_migration/management/commands/migrate_analysis_framework.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

if column_key not in filter2_values:
filter2_values.append(column_key)
filter2_values.extend(sub_columns)
Severity: Major
Found in apps/entry/widgets/matrix2d_widget.py - About 45 mins to fix

    Function list_resolver has a Cognitive Complexity of 15 (exceeds 12 allowed). Consider refactoring.
    Open

    def list_resolver(
    self, manager, filterset_class, filtering_args, root, info, **kwargs
    ):
    filter_kwargs = {k: v for k, v in kwargs.items() if k in filtering_args}
    if self.accessor:
    Severity: Minor
    Found in utils/graphene/fields.py - About 45 mins to fix

    Function migrate_cna_data has a Cognitive Complexity of 15 (exceeds 12 allowed). Consider refactoring.
    Open

    def migrate_cna_data(old_ary, new_assessment_registry):
    questionnaire = old_ary.questionnaire
    if questionnaire:
    questions = questionnaire.get('cna', None)
    if questions:
    Severity: Minor
    Found in apps/assessment_registry/management/commands/migrate_old_assessments.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

    if len(export_data_values) == 2 and any(export_data_values):
    rows.add_value_list([
    self.date_renderer(deep_date_parse(export_data_values[0], raise_exception=False)),
    self.date_renderer(deep_date_parse(export_data_values[1], raise_exception=False)),
    ])
    Severity: Major
    Found in apps/export/entries/excel_exporter.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

      if not array_item:
      # array item might not have error
      continue
      # fetch array.item.client_id from the initial data
      try:
      Severity: Major
      Found in utils/graphene/error_types.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

        for _level in range(0, level - 1)[::-1]:
        if parent_id:
        _geo_area_titles = admin_levels[_level]['geo_area_titles']
        _geo_area = _geo_area_titles.get(parent_id) or {}
        _title = _geo_area.get('title', '')
        Severity: Major
        Found in apps/export/entries/excel_exporter.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

          if parent_id:
          _geo_area_titles = admin_levels[_level]['geo_area_titles']
          _geo_area = _geo_area_titles.get(parent_id) or {}
          _title = _geo_area.get('title')
          parent_id = _geo_area.get('parent_id')
          Severity: Major
          Found in apps/export/entries/report_exporter.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

            for column in widget_prop['columns']:
            for sub_column in column['subColumns'] or [{'label': ''}]:
            writer.writerow({
            ExportColumn.TITLE: w_title,
            ExportColumn.PILLAR: row['label'],
            Severity: Major
            Found in apps/analysis_framework/export.py - About 45 mins to fix
              Severity
              Category
              Status
              Source
              Language