dsi-icl/optimise

View on GitHub

Showing 1,390 of 1,390 total issues

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

    static getComorbidity(whereObj) {
        return new Promise((resolve, reject) => getEntry('COMORBIDITY', whereObj).then((result) => resolve(result)).catch((error) => reject(ErrorHelper(messages.errorMessages.GETFAIL, error))));
    }
Severity: Major
Found in packages/optimise-core/src/core/comorbidity.js and 9 other locations - About 1 hr to fix
packages/optimise-core/src/core/comorbidity.js on lines 10..12
packages/optimise-core/src/core/concomitantMeds.js on lines 6..8
packages/optimise-core/src/core/demographic.js on lines 24..26
packages/optimise-core/src/core/demographic.js on lines 80..82
packages/optimise-core/src/core/demographic.js on lines 122..124
packages/optimise-core/src/core/patientDiagnosis.js on lines 14..16
packages/optimise-core/src/core/patientPii.js on lines 11..13
packages/optimise-core/src/core/test.js on lines 11..13
packages/optimise-core/src/core/treatment.js on lines 12..14

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 71.

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 10 locations. Consider refactoring.
Open

    static createComorbidity(entryObj) {
        return new Promise((resolve, reject) => createEntry('COMORBIDITY', entryObj).then((result) => resolve(result)).catch((error) => reject(ErrorHelper(messages.errorMessages.GETFAIL, error))));
    }
Severity: Major
Found in packages/optimise-core/src/core/comorbidity.js and 9 other locations - About 1 hr to fix
packages/optimise-core/src/core/comorbidity.js on lines 6..8
packages/optimise-core/src/core/concomitantMeds.js on lines 6..8
packages/optimise-core/src/core/demographic.js on lines 24..26
packages/optimise-core/src/core/demographic.js on lines 80..82
packages/optimise-core/src/core/demographic.js on lines 122..124
packages/optimise-core/src/core/patientDiagnosis.js on lines 14..16
packages/optimise-core/src/core/patientPii.js on lines 11..13
packages/optimise-core/src/core/test.js on lines 11..13
packages/optimise-core/src/core/treatment.js on lines 12..14

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 71.

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 10 locations. Consider refactoring.
Open

    static createConcomitantMed(entryObj) {
        return new Promise((resolve, reject) => createEntry('CONCOMITANT_MED', entryObj).then((result) => resolve(result)).catch((error) => reject(ErrorHelper(messages.errorMessages.GETFAIL, error))));
    }
Severity: Major
Found in packages/optimise-core/src/core/concomitantMeds.js and 9 other locations - About 1 hr to fix
packages/optimise-core/src/core/comorbidity.js on lines 6..8
packages/optimise-core/src/core/comorbidity.js on lines 10..12
packages/optimise-core/src/core/demographic.js on lines 24..26
packages/optimise-core/src/core/demographic.js on lines 80..82
packages/optimise-core/src/core/demographic.js on lines 122..124
packages/optimise-core/src/core/patientDiagnosis.js on lines 14..16
packages/optimise-core/src/core/patientPii.js on lines 11..13
packages/optimise-core/src/core/test.js on lines 11..13
packages/optimise-core/src/core/treatment.js on lines 12..14

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 71.

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 10 locations. Consider refactoring.
Open

    static createDemographic(entryObj) {
        return new Promise((resolve, reject) => createEntry('PATIENT_DEMOGRAPHIC', entryObj).then((result) => resolve(result)).catch((error) => reject(ErrorHelper(message.errorMessages.CREATIONFAIL, error))));
    }
Severity: Major
Found in packages/optimise-core/src/core/demographic.js and 9 other locations - About 1 hr to fix
packages/optimise-core/src/core/comorbidity.js on lines 6..8
packages/optimise-core/src/core/comorbidity.js on lines 10..12
packages/optimise-core/src/core/concomitantMeds.js on lines 6..8
packages/optimise-core/src/core/demographic.js on lines 80..82
packages/optimise-core/src/core/demographic.js on lines 122..124
packages/optimise-core/src/core/patientDiagnosis.js on lines 14..16
packages/optimise-core/src/core/patientPii.js on lines 11..13
packages/optimise-core/src/core/test.js on lines 11..13
packages/optimise-core/src/core/treatment.js on lines 12..14

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 71.

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 10 locations. Consider refactoring.
Open

    static createPatientDiagnosis(entryObj) {
        return new Promise((resolve, reject) => createEntry('PATIENT_DIAGNOSIS', entryObj).then((result) => resolve(result)).catch((error) => reject(ErrorHelper(message.errorMessages.GETFAIL, error))));
    }
Severity: Major
Found in packages/optimise-core/src/core/patientDiagnosis.js and 9 other locations - About 1 hr to fix
packages/optimise-core/src/core/comorbidity.js on lines 6..8
packages/optimise-core/src/core/comorbidity.js on lines 10..12
packages/optimise-core/src/core/concomitantMeds.js on lines 6..8
packages/optimise-core/src/core/demographic.js on lines 24..26
packages/optimise-core/src/core/demographic.js on lines 80..82
packages/optimise-core/src/core/demographic.js on lines 122..124
packages/optimise-core/src/core/patientPii.js on lines 11..13
packages/optimise-core/src/core/test.js on lines 11..13
packages/optimise-core/src/core/treatment.js on lines 12..14

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 71.

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

Function render has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    render() {
        const { patientProfile, match, location, renderedInFrontPage } = this.props;

        let _style = style;
        if (this.props.override_style) {

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

        static createMedicalHistory(entryObj) {
            return new Promise((resolve, reject) => createEntry('MEDICAL_HISTORY', entryObj).then((result) => resolve(result)).catch((error) => reject(ErrorHelper(message.errorMessages.CREATIONFAIL, error))));
        }
    Severity: Major
    Found in packages/optimise-core/src/core/demographic.js and 9 other locations - About 1 hr to fix
    packages/optimise-core/src/core/comorbidity.js on lines 6..8
    packages/optimise-core/src/core/comorbidity.js on lines 10..12
    packages/optimise-core/src/core/concomitantMeds.js on lines 6..8
    packages/optimise-core/src/core/demographic.js on lines 24..26
    packages/optimise-core/src/core/demographic.js on lines 122..124
    packages/optimise-core/src/core/patientDiagnosis.js on lines 14..16
    packages/optimise-core/src/core/patientPii.js on lines 11..13
    packages/optimise-core/src/core/test.js on lines 11..13
    packages/optimise-core/src/core/treatment.js on lines 12..14

    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 71.

    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 10 locations. Consider refactoring.
    Open

        static createImmunisation(entryObj) {
            return new Promise((resolve, reject) => createEntry('PATIENT_IMMUNISATION', entryObj).then((result) => resolve(result)).catch((error) => reject(ErrorHelper(message.errorMessages.CREATIONFAIL, error))));
        }
    Severity: Major
    Found in packages/optimise-core/src/core/demographic.js and 9 other locations - About 1 hr to fix
    packages/optimise-core/src/core/comorbidity.js on lines 6..8
    packages/optimise-core/src/core/comorbidity.js on lines 10..12
    packages/optimise-core/src/core/concomitantMeds.js on lines 6..8
    packages/optimise-core/src/core/demographic.js on lines 24..26
    packages/optimise-core/src/core/demographic.js on lines 80..82
    packages/optimise-core/src/core/patientDiagnosis.js on lines 14..16
    packages/optimise-core/src/core/patientPii.js on lines 11..13
    packages/optimise-core/src/core/test.js on lines 11..13
    packages/optimise-core/src/core/treatment.js on lines 12..14

    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 71.

    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 10 locations. Consider refactoring.
    Open

        static createTest(entryObj) {
            return new Promise((resolve, reject) => createEntry('ORDERED_TESTS', entryObj).then((result) => resolve(result)).catch((error) => reject(ErrorHelper(message.errorMessages.CREATIONFAIL, error))));
        }
    Severity: Major
    Found in packages/optimise-core/src/core/test.js and 9 other locations - About 1 hr to fix
    packages/optimise-core/src/core/comorbidity.js on lines 6..8
    packages/optimise-core/src/core/comorbidity.js on lines 10..12
    packages/optimise-core/src/core/concomitantMeds.js on lines 6..8
    packages/optimise-core/src/core/demographic.js on lines 24..26
    packages/optimise-core/src/core/demographic.js on lines 80..82
    packages/optimise-core/src/core/demographic.js on lines 122..124
    packages/optimise-core/src/core/patientDiagnosis.js on lines 14..16
    packages/optimise-core/src/core/patientPii.js on lines 11..13
    packages/optimise-core/src/core/treatment.js on lines 12..14

    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 71.

    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 10 locations. Consider refactoring.
    Open

        static createTreatment(treatment) {
            return new Promise((resolve, reject) => createEntry('TREATMENTS', treatment).then((result) => resolve(result)).catch((error) => reject(ErrorHelper(message.errorMessages.CREATIONFAIL, error))));
        }
    Severity: Major
    Found in packages/optimise-core/src/core/treatment.js and 9 other locations - About 1 hr to fix
    packages/optimise-core/src/core/comorbidity.js on lines 6..8
    packages/optimise-core/src/core/comorbidity.js on lines 10..12
    packages/optimise-core/src/core/concomitantMeds.js on lines 6..8
    packages/optimise-core/src/core/demographic.js on lines 24..26
    packages/optimise-core/src/core/demographic.js on lines 80..82
    packages/optimise-core/src/core/demographic.js on lines 122..124
    packages/optimise-core/src/core/patientDiagnosis.js on lines 14..16
    packages/optimise-core/src/core/patientPii.js on lines 11..13
    packages/optimise-core/src/core/test.js on lines 11..13

    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 71.

    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

            const body = { data: { add, update, visitId: this.props.match.params.visitId }, patientId: this.props.match.params.patientId, type: 'visit' };
    packages/optimise-ui/src/components/EDSScalculator/calculator.jsx on lines 152..152

    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 71.

    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

            const body = { data: { add, update, visitId: this.props.match.params.visitId }, patientId: this.props.match.params.patientId, type: 'visit' };
    packages/optimise-ui/src/components/editMedicalElements/editEdss.jsx on lines 64..64

    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 71.

    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

                [{
                    offset: 16,
                    length: patientId.length,
                    style: 'BOLD'
                },
    packages/optimise-ui/src/components/editMedicalElements/communicationTemplates.js on lines 42..51

    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 71.

    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

    export const changeEmailAPICall = body => () => apiHelper('/users', { method: 'PUT', body: JSON.stringify(body) })
        .catch(msg => store.dispatch(addError({ error: msg })));
    Severity: Major
    Found in packages/optimise-ui/src/redux/actions/admin.js and 1 other location - About 1 hr to fix
    packages/optimise-ui/src/redux/actions/admin.js on lines 52..53

    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 71.

    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

    export const changePasswordAPICall = body => () => apiHelper('/users', { method: 'PUT', body: JSON.stringify(body) })
        .catch(msg => store.dispatch(addError({ error: msg })));
    Severity: Major
    Found in packages/optimise-ui/src/redux/actions/admin.js and 1 other location - About 1 hr to fix
    packages/optimise-ui/src/redux/actions/admin.js on lines 49..50

    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 71.

    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

                [{
                    offset: 16,
                    length: patientId.length,
                    style: 'BOLD'
                },
    packages/optimise-ui/src/components/editMedicalElements/communicationTemplates.js on lines 28..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 71.

    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

    Function render has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        render() {
            const { params } = this.props.match;
            const { treatments, renderedInFrontPage } = this.props;
            const { wannaUpdate } = this.state;
            if (!treatments) {

      Function createMedicalCondition has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          static createMedicalCondition({ body, user }, res) {
              if (body.hasOwnProperty('patient') && body.hasOwnProperty('startDate') && body.hasOwnProperty('outcome') && body.hasOwnProperty('relation') && body.hasOwnProperty('conditionName') &&
                  ((body.hasOwnProperty('resolvedYear') && typeof body.resolvedYear === 'number') || !body.hasOwnProperty('resolvedYear')) &&
                  typeof body.patient === 'number' && typeof body.startDate === 'string' && typeof body.outcome === 'string' && typeof body.relation === 'number' && typeof body.conditionName === 'number') {
                  const momentStart = moment(body.startDate, moment.ISO_8601);
      Severity: Minor
      Found in packages/optimise-core/src/controllers/demographicDataController.js - 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 _handleSubmit has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          _handleSubmit(ev) {
              ev.preventDefault();
              if (this.state.lastSubmit && (new Date()).getTime() - this.state.lastSubmit < 500 ? true : false)
                  return;
              if (!this.state.newStartDate || !this.state.newStartDate.isValid()) {

      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 14 (exceeds 5 allowed). Consider refactoring.
      Open

          render() {
              const { syncInfo } = this.props;
      
              if (syncInfo.config === undefined || syncInfo.config.host === undefined || syncInfo.config.host === '')
                  return null;
      Severity: Minor
      Found in packages/optimise-ui/src/components/scaffold/syncIndicator.jsx - 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