dsi-icl/optimise

View on GitHub

Showing 1,390 of 1,390 total issues

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

const schema_v16 = (dbcon) => dbcon().schema.createTable(TABLE_NAME, (table) => {
    table.increments('id').primary();
    table.boolean('participation').notNullable().defaultTo(true);
    table.text('uuid').notNullable();
    table.text('aliasId').notNullable();
Severity: Major
Found in packages/optimise-core/src/db/patients.table.js and 1 other location - About 1 day to fix
packages/optimise-core/src/db/patients.table.js on lines 83..93

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

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

const schema_v1 = (dbcon) => dbcon().schema.createTable(TABLE_NAME, (table) => {
    table.increments('id').primary();
    table.boolean('consent').notNullable().defaultTo(false);
    table.text('uuid').notNullable();
    table.text('aliasId').notNullable();
Severity: Major
Found in packages/optimise-core/src/db/patients.table.js and 1 other location - About 1 day to fix
packages/optimise-core/src/db/patients.table.js on lines 108..118

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

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

File demographicDataController.js has 627 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import ErrorHelper from '../utils/error_helper';
import message from '../utils/message-utils';
import formatToJSON from '../utils/format-response';
import moment from 'moment';
import { DemographicCore, MedicalHistoryCore, ImmunisationCore, PregnancyCore } from '../core/demographic';
Severity: Major
Found in packages/optimise-core/src/controllers/demographicDataController.js - About 1 day to fix

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

        static deleteMedicalCondition({ body, user }, res) {
            if (body.hasOwnProperty('id') && typeof body.id === 'number') {
                MedicalHistoryCore.deleteMedicalHistory(user, { id: body.id }).then((result) => {
                    res.status(200).json(formatToJSON(result));
                    return true;
    packages/optimise-core/src/controllers/demographicDataController.js on lines 123..139
    packages/optimise-core/src/controllers/demographicDataController.js on lines 141..157
    packages/optimise-core/src/controllers/demographicDataController.js on lines 645..662
    packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 87..103
    packages/optimise-core/src/controllers/patientPiiController.js on lines 72..88
    packages/optimise-core/src/controllers/testController.js on lines 79..96

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

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

        static deletePatientPii({ body, user }, res) {
            if (body.hasOwnProperty('id') && typeof body.id === 'number') {
                PatientPiiCore.deletePatientPii(user, { id: body.id }).then((result) => {
                    res.status(200).json(formatToJSON(result));
                    return true;
    packages/optimise-core/src/controllers/demographicDataController.js on lines 123..139
    packages/optimise-core/src/controllers/demographicDataController.js on lines 141..157
    packages/optimise-core/src/controllers/demographicDataController.js on lines 159..175
    packages/optimise-core/src/controllers/demographicDataController.js on lines 645..662
    packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 87..103
    packages/optimise-core/src/controllers/testController.js on lines 79..96

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

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

        static deleteDemographic({ body, user }, res) {
            if (body.hasOwnProperty('id') && typeof body.id === 'number') {
                DemographicCore.deleteDemographic(user, { id: body.id }).then((result) => {
                    res.status(200).json(formatToJSON(result));
                    return true;
    packages/optimise-core/src/controllers/demographicDataController.js on lines 141..157
    packages/optimise-core/src/controllers/demographicDataController.js on lines 159..175
    packages/optimise-core/src/controllers/demographicDataController.js on lines 645..662
    packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 87..103
    packages/optimise-core/src/controllers/patientPiiController.js on lines 72..88
    packages/optimise-core/src/controllers/testController.js on lines 79..96

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

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

        static deletePatientDiagnosis({ body, user }, res) {
            if (body.hasOwnProperty('id') && typeof body.id === 'number') {
                PatientDiagnosisCore.deletePatientDiagnosis(user, { id: body.id }).then((result) => {
                    res.status(200).json(formatToJSON(result));
                    return true;
    packages/optimise-core/src/controllers/demographicDataController.js on lines 123..139
    packages/optimise-core/src/controllers/demographicDataController.js on lines 141..157
    packages/optimise-core/src/controllers/demographicDataController.js on lines 159..175
    packages/optimise-core/src/controllers/demographicDataController.js on lines 645..662
    packages/optimise-core/src/controllers/patientPiiController.js on lines 72..88
    packages/optimise-core/src/controllers/testController.js on lines 79..96

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

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

        static deleteTest({ body, user }, res) {
            if (body.hasOwnProperty('testId') && typeof body.testId === 'number') {
                TestCore.deleteTest(user, { id: body.testId }).then((result) => {
                    res.status(200).json(formatToJSON(result));
                    return true;
    Severity: Major
    Found in packages/optimise-core/src/controllers/testController.js and 6 other locations - About 1 day to fix
    packages/optimise-core/src/controllers/demographicDataController.js on lines 123..139
    packages/optimise-core/src/controllers/demographicDataController.js on lines 141..157
    packages/optimise-core/src/controllers/demographicDataController.js on lines 159..175
    packages/optimise-core/src/controllers/demographicDataController.js on lines 645..662
    packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 87..103
    packages/optimise-core/src/controllers/patientPiiController.js on lines 72..88

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

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

        static deleteImmunisation({ body, user }, res) {
            if (body.hasOwnProperty('id') && typeof body.id === 'number') {
                ImmunisationCore.deleteImmunisation(user, { id: body.id }).then((result) => {
                    res.status(200).json(formatToJSON(result));
                    return true;
    packages/optimise-core/src/controllers/demographicDataController.js on lines 123..139
    packages/optimise-core/src/controllers/demographicDataController.js on lines 159..175
    packages/optimise-core/src/controllers/demographicDataController.js on lines 645..662
    packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 87..103
    packages/optimise-core/src/controllers/patientPiiController.js on lines 72..88
    packages/optimise-core/src/controllers/testController.js on lines 79..96

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

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

        static deletePregnancyEntry({ body, user }, res) {
            if (body.hasOwnProperty('pregnancyEntryId') && typeof body.pregnancyEntryId === 'number') {
                PregnancyCore.deletePregnancyEntry(user, { id: body.pregnancyEntryId }).then((result) => {
                    res.status(200).json(formatToJSON(result));
                    return true;
    packages/optimise-core/src/controllers/demographicDataController.js on lines 123..139
    packages/optimise-core/src/controllers/demographicDataController.js on lines 141..157
    packages/optimise-core/src/controllers/demographicDataController.js on lines 159..175
    packages/optimise-core/src/controllers/patientDiagnosisController.js on lines 87..103
    packages/optimise-core/src/controllers/patientPiiController.js on lines 72..88
    packages/optimise-core/src/controllers/testController.js on lines 79..96

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

    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

    File patientProfile.jsx has 590 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { Component } from 'react';
    import { connect } from 'react-redux';
    import { Redirect } from 'react-router-dom';
    import moment from 'moment';
    import Icon from '../icon';
    Severity: Major
    Found in packages/optimise-ui/src/components/patientProfile/patientProfile.jsx - About 1 day to fix

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

                              {this.state.noEndDate ? null :
                                  (<><label htmlFor='terminatedDate'>End date: </label>
                                      <PickDate startDate={this.state.terminatedDate ? this.state.terminatedDate : moment()} handleChange={this._handleTerminatedDateChange} /><br /><br />
                                      <label>Reason for termination:
                                          <select name='terminatedReason' value={this.state.terminatedReason} onChange={this._handleInputChange}>
      packages/optimise-ui/src/components/editMedicalElements/editMedication.jsx on lines 264..273

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

      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

                      {this.state.noEndDate ? null :
                          (<><label htmlFor='terminatedDate'>End date: </label>
                              <PickDate startDate={this.state.terminatedDate ? this.state.terminatedDate : moment()} handleChange={this._handleTerminatedDateChange} /><br /><br />
                              <label>Reason for termination:
                                  <select name='terminatedReason' value={this.state.terminatedReason} onChange={this._handleChange}>
      packages/optimise-ui/src/components/createMedicalElements/createTreatment.jsx on lines 193..202

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

      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

          constructor() {
              super();
              this.state = {
                  addMore: false,
                  newStartDate: moment(),
      packages/optimise-ui/src/components/editMedicalElements/editPregnancy.jsx on lines 19..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 228.

      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

          constructor() {
              super();
              this.state = {
                  addMore: false,
                  newStartDate: moment(),
      packages/optimise-ui/src/components/medicalData/treatmentInterruptions.jsx on lines 19..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 228.

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

                  for (let i = 0; i < globalMaxTreatments; i++) {
                      line[`lab_test_id_${i + 1}`] = tree.treatments[i] ? tree.treatments[i].lab_test_id : '';
                      line[`lab_test_name_${i + 1}`] = tree.treatments[i] ? tree.treatments[i].lab_test_name : '';
                      line[`lab_test_value_${i + 1}`] = tree.treatments[i] ? tree.treatments[i].lab_test_value : '';
                      line[`lab_test_date_${i + 1}`] = tree.treatments[i] ? tree.treatments[i].lab_test_date : '';
      packages/optimise-core/src/controllers/exportDataController.js on lines 186..191
      packages/optimise-core/src/controllers/exportDataController.js on lines 198..203

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

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

                  for (let i = 0; i < globalMaxMRIs; i++) {
                      line[`mri_id_${i + 1}`] = tree.mri[i] ? tree.mri[i].mri_id : '';
                      line[`mri_result_name_${i + 1}`] = tree.mri[i] ? tree.mri[i].mri_result_name : '';
                      line[`mri_result_value_${i + 1}`] = tree.mri[i] ? tree.mri[i].mri_result_value : '';
                      line[`mri_date_${i + 1}`] = tree.mri[i] ? tree.mri[i].mri_date : '';
      packages/optimise-core/src/controllers/exportDataController.js on lines 186..191
      packages/optimise-core/src/controllers/exportDataController.js on lines 192..197

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

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

                  for (let i = 0; i < globalMaxSAEs; i++) {
                      line[`SAE_type_${i + 1}`] = tree.SAEs[i] ? tree.SAEs[i].SAE_type : '';
                      line[`SAE_start_date_${i + 1}`] = tree.SAEs[i] ? tree.SAEs[i].SAE_start_date : '';
                      line[`SAE_end_date_${i + 1}`] = tree.SAEs[i] ? tree.SAEs[i].SAE_end_date : '';
                      line[`SAE_note_${i + 1}`] = tree.SAEs[i] ? tree.SAEs[i].SAE_note : '';
      packages/optimise-core/src/controllers/exportDataController.js on lines 192..197
      packages/optimise-core/src/controllers/exportDataController.js on lines 198..203

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

      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 startSync has 232 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static async startSync(config) {
      
              if (isSyncing && !config.adminPass)
                  return Promise.resolve();
      
      
      Severity: Major
      Found in packages/optimise-core/src/core/sync.js - About 1 day to fix

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

                case 'DOMINANT':
                    return new Promise((resolve, reject) => dbcon()('PATIENT_DEMOGRAPHIC')
                        .select({ patientId: 'PATIENTS.id' }, 'PATIENTS.aliasId', 'PATIENTS.optimiseConsent', 'PATIENTS.participation', 'DOMINANT_HANDS.value')
                        .leftOuterJoin('PATIENTS', 'PATIENTS.id', 'PATIENT_DEMOGRAPHIC.patient')
                        .leftOuterJoin('DOMINANT_HANDS', 'DOMINANT_HANDS.id', 'PATIENT_DEMOGRAPHIC.dominantHand')
        Severity: Major
        Found in packages/optimise-core/src/utils/controller-utils.js and 3 other locations - About 1 day to fix
        packages/optimise-core/src/utils/controller-utils.js on lines 105..119
        packages/optimise-core/src/utils/controller-utils.js on lines 120..134
        packages/optimise-core/src/utils/controller-utils.js on lines 150..164

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

        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