renalreg/radar

View on GitHub

Showing 168 of 557 total issues

Consider simplifying this complex logical expression.
Open

        if a.to_date is None and b.to_date is not None:
            return a
        elif b.to_date is None and a.to_date is not None:
            return b
        elif a.to_date is not None and b.to_date is not None and a.to_date > b.to_date:
Severity: Major
Found in radar/ukrdc_exporter/group_selector.py - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

            if a.from_date < b.from_date:
                return a
            elif b.from_date < a.from_date:
                return b
            elif a.to_date is None and b.to_date is not None:
    Severity: Major
    Found in radar/ukrdc_exporter/group_selector.py - About 1 hr to fix

      Function _select_present has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def _select_present(self, a, b):
              """Return the membership with the latest to date.
      
              Settle ties using the earliest from date and then the newest membership (by ID).
              """
      Severity: Minor
      Found in radar/ukrdc_exporter/group_selector.py - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def main():
          argument_parser = argparse.ArgumentParser()
          argument_parser.add_argument("config")
          argument_parser.add_argument("dest")
          args = argument_parser.parse_args()
      Severity: Minor
      Found in radar/exporter/__main__.py - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def export(self):
              try:
                  patient = self.data[0]
              except IndexError:
                  print('No {} patients found in {}'.format(self.kind.upper(), self.hospital.name))
      Severity: Minor
      Found in radar/exporter/nurture_validator.py - About 55 mins 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 patients_by_recruitment_date has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def patients_by_recruitment_date(group):
          """
          Calculate the number of patients recruited each month to the
          specified group.
          """
      Severity: Minor
      Found in radar/stats.py - About 55 mins 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 intersect_groups_with_user has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def intersect_groups_with_user(user, other_user, user_membership=False, other_user_membership=False):
          """Find the intersection of the groups the patient and user belong to."""
      
          other_group_users = {x.group: x for x in other_user.group_users}
      
      
      Severity: Minor
      Found in radar/permissions.py - About 55 mins 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 __call__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def __call__(self, data):
              field = self.parent.fields[self.field_name]
      
              value = field.get_attribute(data)
      
      
      Severity: Minor
      Found in radar/api/serializers/validators.py - About 55 mins 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 intersect_groups_with_patient has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def intersect_groups_with_patient(user, patient, user_membership=False, patient_membership=False):
          """Find the intersection of the groups the user and patient belong to."""
      
          group_patients = {x.group: x for x in patient.group_patients}
      
      
      Severity: Minor
      Found in radar/permissions.py - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate(self, data):
              data = super(GroupPatientSerializer, self).validate(data)
      
              current_user = self.context["user"]
              instance = self.instance
      Severity: Minor
      Found in radar/api/serializers/group_patients.py - About 55 mins 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 filter_query has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def filter_query(self, query):
              query = super(LogListView, self).filter_query(query)
      
              args = parse_args(LogListRequestSerializer)
      
      
      Severity: Minor
      Found in radar/api/views/logs.py - About 55 mins 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 check_validators has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_validators(self, data):
              errors = {}
      
              for field in self.writable_fields:
                  name = field.name
      Severity: Minor
      Found in radar/marmoset/schema.py - About 55 mins 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_aliases has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def export_aliases(sda_patient, patient):
          q = PatientAlias.query
          q = q.filter(PatientAlias.patient == patient)
          q = q.filter(PatientAlias.source_type == SOURCE_TYPE_MANUAL)
          aliases = q.all()
      Severity: Minor
      Found in radar/ukrdc_exporter/patients.py - About 55 mins 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_attrs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_attrs(data, *attrs):
          """Get the object value at the supplied path."""
      
          value = data
      
      
      Severity: Minor
      Found in radar/utils.py - About 55 mins 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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in radar/recruitment/__init__.py - About 50 mins to fix

        Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Major
        Found in radar/recruitment/__init__.py - About 50 mins to fix

          Function format_date has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def format_date(dt):
              val = dt
              fmt = '%d/%m/%Y'
              if isinstance(dt, (date, datetime)):
                  try:
          Severity: Minor
          Found in radar/exporter/utils.py - About 45 mins 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

          Avoid deeply nested control flow statements.
          Open

                                  if self.ins_data['ins_dia_name'] != '':
                                      row = [''] * len(headers)
                                      row[1] = self.ins_data['pat_id']
                                      self.ins_data['pat_id'] = ''
                                      self.insert_ins_data(row)
          Severity: Major
          Found in radar/exporter/exporters.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if not self.ins_data['ins_dia_date'] or self.ins_data['ins_dia_date'] < record.from_date:
                                        ins_data = self.get_ins_data(record, diagnosis)
            
                                # Search for primary diagnosis and INS data
                                else:
            Severity: Major
            Found in radar/exporter/exporters.py - About 45 mins to fix

              Function login has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def login(self):
                      form = LoginForm(request.form)
              
                      if helpers.validate_form_on_submit(form):
                          username = form.username.data
              Severity: Minor
              Found in radar/admin/views.py - About 45 mins 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