dsi-icl/optimise

View on GitHub

Showing 1,390 of 1,390 total issues

Similar blocks of code found in 6 locations. Consider refactoring.
Open

            if (!momentStart.isValid() && body.start_date !== null) {
                const msg = message.dateError[momentStart.invalidAt()] !== undefined ? message.dateError[momentStart.invalidAt()] : message.userError.INVALIDDATE;
                res.status(400).json(ErrorHelper(msg, new Error(message.userError.INVALIDDATE)));
                return;
            }
packages/optimise-core/src/controllers/demographicDataController.js on lines 57..61
packages/optimise-core/src/controllers/demographicDataController.js on lines 90..94
packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 34..38
packages/optimise-core/src/controllers/testController.js on lines 19..23
packages/optimise-core/src/controllers/visitController.js on lines 38..42

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 120.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

            if (!momentImmun.isValid() && body.immunisationDate !== null) {
                const msg = message.dateError[momentImmun.invalidAt()] !== undefined ? message.dateError[momentImmun.invalidAt()] : message.userError.INVALIDDATE;
                res.status(400).json(ErrorHelper(msg, new Error(message.userError.INVALIDDATE)));
                return;
            }
packages/optimise-core/src/controllers/demographicDataController.js on lines 90..94
packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 34..38
packages/optimise-core/src/controllers/testController.js on lines 19..23
packages/optimise-core/src/controllers/treatmentController.js on lines 160..164
packages/optimise-core/src/controllers/visitController.js on lines 38..42

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 120.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 11 locations. Consider refactoring.
Open

export const deleteDiagnosisAPICall = (body) => dispatch => (
    apiHelper('/patientDiagnosis', { method: 'DELETE', body: JSON.stringify(body.data) })
        .then(() => {
            history.push(body.to);
            dispatch(getPatientProfileById(body.patientId));
Severity: Major
Found in packages/optimise-ui/src/redux/actions/demographicData.js and 10 other locations - About 4 hrs to fix
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 17..22
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 24..28
packages/optimise-ui/src/redux/actions/demographicData.js on lines 126..133
packages/optimise-ui/src/redux/actions/demographicData.js on lines 135..142
packages/optimise-ui/src/redux/actions/tests.js on lines 16..20
packages/optimise-ui/src/redux/actions/tests.js on lines 22..26
packages/optimise-ui/src/redux/actions/treatments.js on lines 15..19
packages/optimise-ui/src/redux/actions/treatments.js on lines 21..25
packages/optimise-ui/src/redux/actions/treatments.js on lines 27..31
packages/optimise-ui/src/redux/actions/treatments.js on lines 33..37

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 11 locations. Consider refactoring.
Open

export const createDiagnosisAPICall = (body) => dispatch => (
    apiHelper('/patientDiagnosis', { method: 'POST', body: JSON.stringify(body.data) })
        .then(() => {
            history.push(body.to);
            dispatch(getPatientProfileById(body.patientId));
Severity: Major
Found in packages/optimise-ui/src/redux/actions/demographicData.js and 10 other locations - About 4 hrs to fix
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 17..22
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 24..28
packages/optimise-ui/src/redux/actions/demographicData.js on lines 126..133
packages/optimise-ui/src/redux/actions/demographicData.js on lines 152..159
packages/optimise-ui/src/redux/actions/tests.js on lines 16..20
packages/optimise-ui/src/redux/actions/tests.js on lines 22..26
packages/optimise-ui/src/redux/actions/treatments.js on lines 15..19
packages/optimise-ui/src/redux/actions/treatments.js on lines 21..25
packages/optimise-ui/src/redux/actions/treatments.js on lines 27..31
packages/optimise-ui/src/redux/actions/treatments.js on lines 33..37

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 11 locations. Consider refactoring.
Open

export const updateTreatmentCall = (body) => dispatch => apiHelper('/treatments', { method: 'PUT', body: JSON.stringify(body.data) })
    .then(() => {
        history.push(body.to);
        dispatch(getPatientProfileById(body.patientId));
    }).catch(err => store.dispatch(addError({ error: err })));
Severity: Major
Found in packages/optimise-ui/src/redux/actions/treatments.js and 10 other locations - About 4 hrs to fix
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 17..22
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 24..28
packages/optimise-ui/src/redux/actions/demographicData.js on lines 126..133
packages/optimise-ui/src/redux/actions/demographicData.js on lines 135..142
packages/optimise-ui/src/redux/actions/demographicData.js on lines 152..159
packages/optimise-ui/src/redux/actions/tests.js on lines 16..20
packages/optimise-ui/src/redux/actions/tests.js on lines 22..26
packages/optimise-ui/src/redux/actions/treatments.js on lines 15..19
packages/optimise-ui/src/redux/actions/treatments.js on lines 21..25
packages/optimise-ui/src/redux/actions/treatments.js on lines 27..31

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 11 locations. Consider refactoring.
Open

export const deleteCEAPICall = (body) => dispatch => apiHelper('/clinicalEvents', { method: 'DELETE', body: JSON.stringify(body.data) })
    .then(() => {
        history.push(body.to);
        dispatch(getPatientProfileById(body.patientId));
    })
Severity: Major
Found in packages/optimise-ui/src/redux/actions/clinicalEvents.js and 10 other locations - About 4 hrs to fix
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 24..28
packages/optimise-ui/src/redux/actions/demographicData.js on lines 126..133
packages/optimise-ui/src/redux/actions/demographicData.js on lines 135..142
packages/optimise-ui/src/redux/actions/demographicData.js on lines 152..159
packages/optimise-ui/src/redux/actions/tests.js on lines 16..20
packages/optimise-ui/src/redux/actions/tests.js on lines 22..26
packages/optimise-ui/src/redux/actions/treatments.js on lines 15..19
packages/optimise-ui/src/redux/actions/treatments.js on lines 21..25
packages/optimise-ui/src/redux/actions/treatments.js on lines 27..31
packages/optimise-ui/src/redux/actions/treatments.js on lines 33..37

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 11 locations. Consider refactoring.
Open

export const createTreatmentInterruptionAPICall = (body) => dispatch => apiHelper('/treatments/interrupt', { method: 'POST', body: JSON.stringify(body.data) })
    .then(() => {
        history.push(body.to);
        dispatch(getPatientProfileById(body.patientId));
    }).catch(err => store.dispatch(addError({ error: err })));
Severity: Major
Found in packages/optimise-ui/src/redux/actions/treatments.js and 10 other locations - About 4 hrs to fix
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 17..22
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 24..28
packages/optimise-ui/src/redux/actions/demographicData.js on lines 126..133
packages/optimise-ui/src/redux/actions/demographicData.js on lines 135..142
packages/optimise-ui/src/redux/actions/demographicData.js on lines 152..159
packages/optimise-ui/src/redux/actions/tests.js on lines 16..20
packages/optimise-ui/src/redux/actions/tests.js on lines 22..26
packages/optimise-ui/src/redux/actions/treatments.js on lines 21..25
packages/optimise-ui/src/redux/actions/treatments.js on lines 27..31
packages/optimise-ui/src/redux/actions/treatments.js on lines 33..37

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 11 locations. Consider refactoring.
Open

export const deleteTestAPICall = (body) => dispatch => apiHelper('/tests', { method: 'DELETE', body: JSON.stringify(body.data) })
    .then(() => {
        history.push(body.to);
        dispatch(getPatientProfileById(body.patientId));
    }).catch(err => store.dispatch(addError({ error: err })));
Severity: Major
Found in packages/optimise-ui/src/redux/actions/tests.js and 10 other locations - About 4 hrs to fix
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 17..22
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 24..28
packages/optimise-ui/src/redux/actions/demographicData.js on lines 126..133
packages/optimise-ui/src/redux/actions/demographicData.js on lines 135..142
packages/optimise-ui/src/redux/actions/demographicData.js on lines 152..159
packages/optimise-ui/src/redux/actions/tests.js on lines 22..26
packages/optimise-ui/src/redux/actions/treatments.js on lines 15..19
packages/optimise-ui/src/redux/actions/treatments.js on lines 21..25
packages/optimise-ui/src/redux/actions/treatments.js on lines 27..31
packages/optimise-ui/src/redux/actions/treatments.js on lines 33..37

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 11 locations. Consider refactoring.
Open

export const updateTestCall = (body) => dispatch => apiHelper('/tests', { method: 'PUT', body: JSON.stringify(body.data) })
    .then(() => {
        history.push(body.to);
        dispatch(getPatientProfileById(body.patientId));
    }).catch(err => store.dispatch(addError({ error: err })));
Severity: Major
Found in packages/optimise-ui/src/redux/actions/tests.js and 10 other locations - About 4 hrs to fix
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 17..22
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 24..28
packages/optimise-ui/src/redux/actions/demographicData.js on lines 126..133
packages/optimise-ui/src/redux/actions/demographicData.js on lines 135..142
packages/optimise-ui/src/redux/actions/demographicData.js on lines 152..159
packages/optimise-ui/src/redux/actions/tests.js on lines 16..20
packages/optimise-ui/src/redux/actions/treatments.js on lines 15..19
packages/optimise-ui/src/redux/actions/treatments.js on lines 21..25
packages/optimise-ui/src/redux/actions/treatments.js on lines 27..31
packages/optimise-ui/src/redux/actions/treatments.js on lines 33..37

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 11 locations. Consider refactoring.
Open

export const updateCECall = (body) => dispatch => apiHelper('/clinicalEvents', { method: 'PUT', body: JSON.stringify(body.data) })
    .then(() => {
        history.push(body.to);
        dispatch(getPatientProfileById(body.patientId));
    }).catch(err => store.dispatch(addError({ error: err })));
Severity: Major
Found in packages/optimise-ui/src/redux/actions/clinicalEvents.js and 10 other locations - About 4 hrs to fix
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 17..22
packages/optimise-ui/src/redux/actions/demographicData.js on lines 126..133
packages/optimise-ui/src/redux/actions/demographicData.js on lines 135..142
packages/optimise-ui/src/redux/actions/demographicData.js on lines 152..159
packages/optimise-ui/src/redux/actions/tests.js on lines 16..20
packages/optimise-ui/src/redux/actions/tests.js on lines 22..26
packages/optimise-ui/src/redux/actions/treatments.js on lines 15..19
packages/optimise-ui/src/redux/actions/treatments.js on lines 21..25
packages/optimise-ui/src/redux/actions/treatments.js on lines 27..31
packages/optimise-ui/src/redux/actions/treatments.js on lines 33..37

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    constructor(props) {
        super(props);
        this.state = { wannaUpdate: false, elementId: props.match.params.elementId };
        this._handleClick = this._handleClick.bind(this);
        this._deleteFunction = this._deleteFunction.bind(this);
packages/optimise-ui/src/components/editMedicalElements/editClinicalEvent.jsx on lines 18..24

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 11 locations. Consider refactoring.
Open

export const deleteTreatmentCall = (body) => dispatch => apiHelper('/treatments', { method: 'DELETE', body: JSON.stringify(body.data) })
    .then(() => {
        history.push(body.to);
        dispatch(getPatientProfileById(body.patientId));
    }).catch(err => store.dispatch(addError({ error: err })));
Severity: Major
Found in packages/optimise-ui/src/redux/actions/treatments.js and 10 other locations - About 4 hrs to fix
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 17..22
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 24..28
packages/optimise-ui/src/redux/actions/demographicData.js on lines 126..133
packages/optimise-ui/src/redux/actions/demographicData.js on lines 135..142
packages/optimise-ui/src/redux/actions/demographicData.js on lines 152..159
packages/optimise-ui/src/redux/actions/tests.js on lines 16..20
packages/optimise-ui/src/redux/actions/tests.js on lines 22..26
packages/optimise-ui/src/redux/actions/treatments.js on lines 15..19
packages/optimise-ui/src/redux/actions/treatments.js on lines 27..31
packages/optimise-ui/src/redux/actions/treatments.js on lines 33..37

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 11 locations. Consider refactoring.
Open

export const deleteTreatmentInterruptionAPICall = (body) => dispatch => apiHelper('/treatments/interrupt', { method: 'DELETE', body: JSON.stringify(body.data) })
    .then(() => {
        history.push(body.to);
        dispatch(getPatientProfileById(body.patientId));
    }).catch(err => store.dispatch(addError({ error: err })));
Severity: Major
Found in packages/optimise-ui/src/redux/actions/treatments.js and 10 other locations - About 4 hrs to fix
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 17..22
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 24..28
packages/optimise-ui/src/redux/actions/demographicData.js on lines 126..133
packages/optimise-ui/src/redux/actions/demographicData.js on lines 135..142
packages/optimise-ui/src/redux/actions/demographicData.js on lines 152..159
packages/optimise-ui/src/redux/actions/tests.js on lines 16..20
packages/optimise-ui/src/redux/actions/tests.js on lines 22..26
packages/optimise-ui/src/redux/actions/treatments.js on lines 15..19
packages/optimise-ui/src/redux/actions/treatments.js on lines 21..25
packages/optimise-ui/src/redux/actions/treatments.js on lines 33..37

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        dataPromises.push(dbcon()('CLINICAL_EVENTS')
            .select('PATIENTS.uuid as USUBJID', 'ADVERSE_EVENT_MEDDRA.name as AELLT')
            .leftOuterJoin('PATIENTS', 'PATIENTS.id', 'CLINICAL_EVENTS.patient')
            .leftOuterJoin('ADVERSE_EVENT_MEDDRA', 'ADVERSE_EVENT_MEDDRA.id', 'CLINICAL_EVENTS.meddra')
            .whereIn('PATIENTS.id', patientList)
packages/optimise-core/src/controllers/exportDataController.js on lines 587..598

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 11 locations. Consider refactoring.
Open

export const updateDemographicAPICall = (body) => dispatch => (
    apiHelper('/demographics/Demographic', { method: 'PUT', body: JSON.stringify(body.data) })
        .then(() => {
            history.push(body.to);
            dispatch(getPatientProfileById(body.patientId));
Severity: Major
Found in packages/optimise-ui/src/redux/actions/demographicData.js and 10 other locations - About 4 hrs to fix
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 17..22
packages/optimise-ui/src/redux/actions/clinicalEvents.js on lines 24..28
packages/optimise-ui/src/redux/actions/demographicData.js on lines 135..142
packages/optimise-ui/src/redux/actions/demographicData.js on lines 152..159
packages/optimise-ui/src/redux/actions/tests.js on lines 16..20
packages/optimise-ui/src/redux/actions/tests.js on lines 22..26
packages/optimise-ui/src/redux/actions/treatments.js on lines 15..19
packages/optimise-ui/src/redux/actions/treatments.js on lines 21..25
packages/optimise-ui/src/redux/actions/treatments.js on lines 27..31
packages/optimise-ui/src/redux/actions/treatments.js on lines 33..37

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    constructor(props) {
        super(props);
        this.state = { wannaUpdate: false, elementId: props.match.params.elementId };
        this._handleClick = this._handleClick.bind(this);
        this._deleteFunction = this._deleteFunction.bind(this);
packages/optimise-ui/src/components/editMedicalElements/editTest.jsx on lines 16..22

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        dataPromises.push(dbcon()('PATIENT_PREGNANCY')
            .select('PATIENTS.uuid as USUBJID', 'ADVERSE_EVENT_MEDDRA.name as AELLT')
            .leftOuterJoin('PATIENTS', 'PATIENTS.id', 'PATIENT_PREGNANCY.patient')
            .leftOuterJoin('ADVERSE_EVENT_MEDDRA', 'ADVERSE_EVENT_MEDDRA.id', 'PATIENT_PREGNANCY.meddra')
            .whereIn('PATIENTS.id', patientList)
packages/optimise-core/src/controllers/exportDataController.js on lines 601..612

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 119.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    _handleClickGivesPregnancyConsent() {
        const { id } = this.props.data;
        const body = {
            patientId: this.props.match.params.patientId,
            data: {
packages/optimise-ui/src/components/patientProfile/patientProfile.jsx on lines 521..531

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 118.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    _handleClickGivesConsent() {
        const { id } = this.props.data;
        const body = {
            patientId: this.props.match.params.patientId,
            data: {
packages/optimise-ui/src/components/patientProfile/patientProfile.jsx on lines 551..561

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 118.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            if (momentStart !== null && !momentStart.isValid()) {
                const msg = message.dateError[momentStart.invalidAt()] !== undefined ? message.dateError[momentStart.invalidAt()] : message.userError.INVALIDDATE;
                res.status(400).json(ErrorHelper(msg, new Error(message.userError.INVALIDDATE)));
                return;
            }
packages/optimise-core/src/controllers/treatmentController.js on lines 208..212

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 116.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language