renalreg/radar

View on GitHub

Showing 168 of 557 total issues

Function convert_results has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def convert_results(patient, sda_lab_orders):
    user = get_import_user()

    results = list()

Severity: Minor
Found in radar/ukrdc_importer/results.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 validate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, serial_data):
        # Validating reconsent letter sent and returned dates make sense
        errors_dict = {}

        if serial_data['reconsent_letter_sent_date']:
Severity: Minor
Found in radar/api/serializers/consents.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 17 (exceeds 5 allowed). Consider refactoring.
Open

    def export(self, sheet, errorfmt, warningfmt):
        entries = [entry for entry in self.patient.entries if entry.form.slug == 'socio-economic']
        if entries:
            for entry in entries:
                data = get_form_data(entry, slice(1, -4), 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 export has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def export(self, sheet, errorfmt, warningfmt):
        entries = [entry for entry in self.patient.entries if entry.form.slug == 'anthropometrics']
        if entries:
            for entry in entries:

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 setup has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def setup(app):
    alport.register_views(app)
    consents.register_views(app)
    consultants.register_views(app)
    demographics.register_views(app)
Severity: Major
Found in radar/api/views/__init__.py - About 2 hrs to fix

    File views.py has 258 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """Admin views."""
    import glob
    import io
    import os
    
    
    Severity: Minor
    Found in radar/admin/views.py - About 2 hrs to fix

      Function create_renal_imaging_f has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_renal_imaging_f():
          def create_renal_imaging(patient, source_group, source_type, n):
              for _ in range(n):
                  renal_imaging = RenalImaging()
                  renal_imaging.patient = patient
      Severity: Minor
      Found in radar/fixtures/renal_imaging.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 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def export(self, sheet, errorfmt=None, warningfmt=None):
              recorded = False
              for diagnosis in self.diagnoses:
                  if diagnosis.diagnosis not in self.primary_diagnoses:
                      continue
      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 get_rows has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_rows(self):
              observations = queries.get_observations()
              for observation in observations:
                  self._columns.append(column(observation.short_name))
      
      
      Severity: Minor
      Found in radar/exporter/exporters.py - About 1 hr 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 update_system_groups has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      def update_system_groups(patient):
          """Check that patient system group still has some children groups."""
      
          systems = patient.systems
          if len(systems) == 1:
      Severity: Minor
      Found in radar/api/views/group_patients.py - About 1 hr 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_patients has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_patients(n, data=True):
          hospital_groups = Group.query.filter(Group.type == GROUP_TYPE.HOSPITAL).all()
          cohort_groups = Group.query.filter(Group.type == GROUP_TYPE.COHORT).all()
      
          source_types = [SOURCE_TYPE_MANUAL, SOURCE_TYPE_UKRDC]
      Severity: Minor
      Found in radar/fixtures/patients.py - About 1 hr 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 main has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def main():
          logging.basicConfig(level=logging.INFO)
      
          parser = argparse.ArgumentParser()
          group = parser.add_mutually_exclusive_group()
      Severity: Minor
      Found in radar/ukrdc_exporter/__main__.py - About 1 hr 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 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def export(self, sheet, errorfmt=None, warningfmt=None):
              visit_dates = [i.data.get('date') for i in self.patient.entries if i.form.slug == 'nurtureckd']
              visit_dates = [datetime.datetime.strptime(i, '%Y-%m-%d').date() for i in visit_dates]
      
              # TODO: clean this stuff up.
      Severity: Minor
      Found in radar/exporter/nurture_validator.py - About 1 hr 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 14 (exceeds 5 allowed). Consider refactoring.
      Open

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

          def consent_status(self):
              """Return what consent status patient is in."""
              if self.year_of_death:
                  return CONSENT_STATUS.OK
      
      
      Severity: Minor
      Found in radar/models/patients.py - About 1 hr 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 has_object_permission has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def has_object_permission(self, request, user, obj):
              if not super(SystemSourceObjectPermission, self).has_object_permission(request, user, obj):
                  return False
      
              if is_safe_method(request):
      Severity: Minor
      Found in radar/api/permissions.py - About 1 hr 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_results_f has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_results_f():
          observations = Observation.query.filter(Observation.value_type == OBSERVATION_VALUE_TYPE.REAL).all()
      
          def create_results(patient, source_group, source_type, x, y):
              for observation in random.sample(observations, min(x, len(observations))):
      Severity: Minor
      Found in radar/fixtures/results.py - About 1 hr 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 make_row has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def make_row(self, record, diagnosis):
              '''
              Returns a list that represents the content of a single row
              in a CSV file that provides data about a patients diagnoses.
      
      
      Severity: Minor
      Found in radar/exporter/exporters.py - About 1 hr 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 validate_is_bot has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate_is_bot(self, is_bot):
              current_user = self.context['user']
              instance = self.instance
      
              if instance is None:
      Severity: Minor
      Found in radar/api/serializers/users.py - About 1 hr 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 ckd_epi_egfr_calculated_with_ethnicity has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def ckd_epi_egfr_calculated_with_ethnicity(self):
              if self.observation.short_name.lower() != "creatinine" or not self.value:
                  return ""
      
              black_ethnicities = (
      Severity: Minor
      Found in radar/models/results.py - About 1 hr 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