Showing 380 of 1,390 total issues
Avoid deeply nested control flow statements. Open
if (oldData[i].deleted === '-' && Boolean(oldData[i].consent) === true) {
if (oldData[i].study !== 'optimise')
oldData[i].optimiseConsent = oldData[i].study;
else
oldData[i].optimiseConsent = oldData[i].createTime;
Function getEntry
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const getEntry = function (tablename, whereObj, selectedObj, extra) {
return new Promise((resolve, reject) => {
let handle = dbcon()(tablename).select(selectedObj).where(whereObj);
if (extra !== undefined && extra.orderBy !== undefined)
handle = handle.orderBy(extra.orderBy || []);
- 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
switch (fieldType) {
case 5: //'B':
if (inputValue !== '' && !(inputValue === true || inputValue === false || inputValue === 1 || inputValue === 0 || inputValue === '1' || inputValue === '0' || inputValue.toUpperCase() === 'YES' || inputValue.toUpperCase() === 'NO')) {
res.status(400).json(ErrorHelper(`${message.dataMessage.BOOLEANFIELD}${fieldDefinition}`));
return false;
Avoid deeply nested control flow statements. Open
if (eligibleVisits.length > 0) {
const maxVisitId = eligibleVisits[0]['min(`id`)'];
if (maxVisitId !== null && maxVisitId !== undefined) {
await dbcon()('VISIT_DATA').insert([
Avoid deeply nested control flow statements. Open
if (oldData[i].optimiseConsent === null) {
const recordPointsOld = await dbcon()(OLD_TABLE_NAME).where({
uuid: oldData[i].uuid
});
const v15Data = await dbcon()(V15_TABLE_NAME)
Function render
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
render() {
const { fetching, erasePatient } = this.props;
if (fetching) {
return <span></span>;
- 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 _handleSubmit
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
_handleSubmit(ev) {
ev.preventDefault();
if (this.state.lastSubmit && (new Date()).getTime() - this.state.lastSubmit < 500 ? true : false)
return;
- 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 constructor
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
constructor(props) {
super();
this.state = {
id: props.data.id,
drug: props.data.drug ? props.data.drug : '',
- 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 render
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
render() {
const { patientProfile, fields } = this.props;
const { icd11_Hash } = fields;
let _style = style;
- 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 _handleSubmit
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
_handleSubmit(ev) {
ev.preventDefault();
if (this.state.lastSubmit && (new Date()).getTime() - this.state.lastSubmit < 500 ? true : false)
return;
- 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
Consider simplifying this complex logical expression. Open
if (typeof body.pw !== 'string' || typeof body.username !== 'string' || typeof body.isAdmin !== 'number' || typeof body.realname !== 'string' || typeof body.email !== 'string' || !email_reg.test(body.email)) {
res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
return;
}
Consider simplifying this complex logical expression. Open
if ((!body.hasOwnProperty('patient') || !body.hasOwnProperty('DOB') || !body.hasOwnProperty('gender') || !body.hasOwnProperty('dominant_hand')
|| !body.hasOwnProperty('ethnicity') || !body.hasOwnProperty('country_of_origin'))) {
res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
return;
}
Consider simplifying this complex logical expression. Open
if (body.hasOwnProperty('patient') && body.hasOwnProperty('immunisationDate') && body.hasOwnProperty('vaccineName') &&
typeof body.patient === 'number' && typeof body.immunisationDate === 'string' && typeof body.vaccineName === 'string') {
const momentImmun = moment(body.immunisationDate, moment.ISO_8601);
if (!momentImmun.isValid() && body.immunisationDate !== null) {
const msg = message.dateError[momentImmun.invalidAt()] !== undefined ? message.dateError[momentImmun.invalidAt()] : message.userError.INVALIDDATE;
Consider simplifying this complex logical expression. Open
if (body.hasOwnProperty('patient') && body.hasOwnProperty('diagnosis') && body.hasOwnProperty('diagnosisDate') &&
typeof body.patient === 'number' && typeof body.diagnosis === 'number' && typeof body.diagnosisDate === 'string') {
const momentDiagnos = moment(body.diagnosisDate, moment.ISO_8601);
if (!momentDiagnos.isValid() && body.diagnosisDate !== null) {
const msg = messages.dateError[momentDiagnos.invalidAt()] !== undefined ? messages.dateError[momentDiagnos.invalidAt()] : messages.userError.INVALIDDATE;
Consider simplifying this complex logical expression. Open
if ((body.hasOwnProperty('treatmentId') && body.hasOwnProperty('terminationDate')) && body.hasOwnProperty('terminatedReason') &&
typeof body.treatmentId === 'number' && typeof body.terminatedDate === 'string' && typeof body.terminatedReason === 'number') {
const momentTerminated = moment(body.terminatedDate, moment.ISO_8601);
if (!momentTerminated.isValid() && body.terminatedDate !== null) {
res.status(400).json(ErrorHelper(message.dateError[momentTerminated.invalidAt()], new Error(message.userError.INVALIDDATE)));
Consider simplifying this complex logical expression. Open
if (typeof body.patient !== 'number' || typeof body.DOB !== 'string' || typeof body.gender !== 'number' || typeof body.dominant_hand !== 'number'
|| typeof body.ethnicity !== 'number' || typeof body.country_of_origin !== 'number') {
res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
return;
}
Consider simplifying this complex logical expression. Open
if (pregnancyEntries.length) {
const entryOrder = PregnancyEntry._checkEntryOrder(pregnancyEntries[0], this.props.data);
pregnancy = this.props.data.pregnancy.filter(el => el.id === pregnancyEntries[0].pregnancyId);
entryIsTerm = (entryOrder === 'latest' || entryOrder === 'sole entry') && typeof pregnancy[0].outcome === 'number' && pregnancy[0].outcomeDate !== null;
Function updateEntry
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export const updateEntry = function (tablename, { id }, originObj, whereObj, newObj) {
Function createPregnancyImage
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static createPregnancyImage({ body, user }, res) {
if (!body.hasOwnProperty('visitId') || !body.hasOwnProperty('date') || !body.hasOwnProperty('mode') || !body.hasOwnProperty('result')) {
res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
return;
- 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 createPatient
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static createPatient({ body, user }, res) {
if (!(body.hasOwnProperty('aliasId') && body.hasOwnProperty('optimiseConsent'))) {
res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
return false;
}
- 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"