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:
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:
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).
"""
- Read upRead up
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()
- Read upRead up
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))
- Read upRead up
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.
"""
- Read upRead up
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}
- Read upRead up
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)
- Read upRead up
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}
- Read upRead up
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
- Read upRead up
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)
- Read upRead up
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
- Read upRead up
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()
- Read upRead up
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
- Read upRead up
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__(
Function __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
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:
- Read upRead up
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)
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:
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
- Read upRead up
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"