renalreg/radar

View on GitHub

Showing 168 of 557 total issues

File exporters.py has 1597 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import re

from radar.exporter import queries
from radar.exporter.utils import (
    format_date,
Severity: Major
Found in radar/exporter/exporters.py - About 4 days to fix

    File nurture_validator.py has 786 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    Script to do simple validations on nurture export.
    """
    
    from collections import defaultdict, OrderedDict
    Severity: Major
    Found in radar/exporter/nurture_validator.py - About 1 day to fix

      Function get_rows has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_rows(self):
              '''
              Gets all the primary diagnosis data for a specific cohort
      
              :yield: yields CSV row for writting to file
      Severity: Minor
      Found in radar/exporter/exporters.py - About 1 day 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

      Patient has 75 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Patient(db.Model, MetaModelMixin):
          __tablename__ = "patients"
      
          id = Column(Integer, Sequence("patients_seq"), primary_key=True)
          comments = Column(String)
      Severity: Major
      Found in radar/models/patients.py - About 1 day to fix

        File patients.py has 482 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from datetime import datetime
        from enum import Enum
        
        from sqlalchemy import (
            Boolean,
        Severity: Minor
        Found in radar/models/patients.py - About 7 hrs to fix

          File results.py has 422 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          from collections import OrderedDict
          from datetime import date
          from enum import Enum
          from itertools import chain
          import math
          Severity: Minor
          Found in radar/models/results.py - About 6 hrs to fix

            Function export_medications has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
            Open

            def export_medications(sda_container, patient, group):
                q = Medication.query
                q = q.filter(Medication.patient == patient)
                q = q.filter(Medication.source_group == group)
                q = q.filter(Medication.source_type == SOURCE_TYPE_MANUAL)
            Severity: Minor
            Found in radar/ukrdc_exporter/medications.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 demographics_column_factory has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
            Open

            def demographics_column_factory(config):
                """Returns a column based on the config."""
            
                if config["anonymised"]:
            
            
            Severity: Minor
            Found in radar/exporter/exporters.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 revisit has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            Open

            def revisit():
            
                nurtureins = Group.query.filter_by(code='NURTUREINS').first()
                nurtureckd = Group.query.filter_by(code='NURTURECKD').first()
            
            
            Severity: Minor
            Found in radar/exporter/revisit.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 __init__.py has 325 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            from asyncio import protocols
            import calendar
            from datetime import datetime
            import itertools
            import logging
            Severity: Minor
            Found in radar/recruitment/__init__.py - About 3 hrs to fix

              File generics.py has 316 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              from functools import wraps
              import uuid
              
              from cornflake import fields, serializers
              from cornflake.exceptions import ValidationError
              Severity: Minor
              Found in radar/api/views/generics.py - About 3 hrs to fix

                Function get_rows has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_rows(self):
                        self._columns.extend(
                            column(item.lower()) for item in SUPPORTIVE_MEDICATIONS.keys()
                        )
                
                
                Severity: Minor
                Found in radar/exporter/exporters.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 patient_search.py has 307 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                from curses.ascii import NUL
                from sqlalchemy import and_, case, desc, extract, func, null, or_
                from sqlalchemy.orm import aliased, subqueryload
                
                from radar.database import db
                Severity: Minor
                Found in radar/patient_search.py - About 3 hrs to fix

                  File patient_addresses.py has 296 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  #! -*- coding: utf-8 -*-
                  from collections import OrderedDict
                  
                  from sqlalchemy import Column, Date, ForeignKey, Index, String
                  from sqlalchemy import Integer
                  Severity: Minor
                  Found in radar/models/patient_addresses.py - About 3 hrs to fix

                    Function validate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def validate(self, data):
                            data = super(UserSerializer, self).validate(data)
                    
                            current_user = self.context['user']
                            instance = self.instance
                    Severity: Minor
                    Found in radar/api/serializers/users.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

                    Function list_patients has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def list_patients():
                        args = parse_args(PatientListRequestSerializer)
                    
                        builder = PatientQueryBuilder(current_user)
                    
                    
                    Severity: Minor
                    Found in radar/api/views/patients.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 get_rows has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def get_rows(self):
                            headers = [col[0] for col in self._columns]
                            yield headers
                    
                            for result in self._query:
                    Severity: Minor
                    Found in radar/exporter/exporters.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 create_groups has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def create_groups():
                        for groups in batches:
                            for x in groups:
                                group = Group()
                                group.type = x['type']
                    Severity: Minor
                    Found in radar/fixtures/groups.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 export has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def export(self, sheet, errorfmt=None, warningfmt=None):
                            medications = self.patient.medications
                            if medications:
                                for instance in medications:
                                    data = [getattr(instance, field) for field in self.fields]
                    Severity: Minor
                    Found in radar/exporter/nurture_validator.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 create_demographics_f has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def create_demographics_f():
                        def create_demographics(patient, source_group, source_type, gender):
                            old_d = PatientDemographics.query.filter(PatientDemographics.patient == patient).first()
                            new_d = PatientDemographics()
                            new_d.patient = patient
                    Severity: Minor
                    Found in radar/fixtures/patients.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