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

            TreatmentCore.deleteInterruption(user, body.treatmentInterId).then((result) => {
                if (result.body === 0) {
                    res.status(400).json(ErrorHelper(message.errorMessages.DELETEFAIL));
                    return false;
                } else {
packages/optimise-core/src/controllers/treatmentController.js on lines 141..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 158.

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

        TreatmentCore.deleteTreatment(user, body.treatmentId).then((result) => {
            if (result.body === 0) {
                res.status(400).json(ErrorHelper(message.errorMessages.DELETEFAIL));
                return false;
            } else {
packages/optimise-core/src/controllers/treatmentController.js on lines 242..253

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

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

    static getMedicalHistory(whereObj) {
        return new Promise((resolve, reject) => getEntry('MEDICAL_HISTORY', whereObj, '*').then((result) => {
            if (result.length > 0) {
                for (let i = 0; i < result.length; i++) {
                    delete result[i].createdByUser;
Severity: Major
Found in packages/optimise-core/src/core/demographic.js and 2 other locations - About 6 hrs to fix
packages/optimise-core/src/core/demographic.js on lines 7..18
packages/optimise-core/src/core/demographic.js on lines 105..116

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

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

    static getDemographic(whereObj) {
        return new Promise((resolve, reject) => getEntry('PATIENT_DEMOGRAPHIC', whereObj, '*').then((result) => {
            if (result.length > 0) {
                for (let i = 0; i < result.length; i++) {
                    delete result[i].createdByUser;
Severity: Major
Found in packages/optimise-core/src/core/demographic.js and 2 other locations - About 6 hrs to fix
packages/optimise-core/src/core/demographic.js on lines 63..74
packages/optimise-core/src/core/demographic.js on lines 105..116

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

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 edssAlgorithm has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

function edssAlgorithm(FSArrayWithoutAmbulation, ambulationScore) {

    if (FSArrayWithoutAmbulation.length === 0)
        return '';
Severity: Minor
Found in packages/optimise-ui/src/components/EDSScalculator/calculator.jsx - About 6 hrs 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

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

function formatToJSON(obj) {
    const returnedObj = {};
    if (Array.isArray(obj) && obj.length === 1 && typeof obj[0] === 'number') {
        returnedObj.state = obj[0];
        return returnedObj;
Severity: Major
Found in packages/optimise-core/src/utils/format-response.js and 2 other locations - About 5 hrs to fix
packages/optimise-remote-control/src/utils/format-response.js on lines 1..16
packages/optimise-sync/src/utils/format-response.js on lines 1..16

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

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

function formatToJSON(obj) {
    const returnedObj = {};
    if (Array.isArray(obj) && obj.length === 1 && typeof obj[0] === 'number') {
        returnedObj.state = obj[0];
        return returnedObj;
packages/optimise-core/src/utils/format-response.js on lines 1..16
packages/optimise-sync/src/utils/format-response.js on lines 1..16

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

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

function formatToJSON(obj) {
    const returnedObj = {};
    if (Array.isArray(obj) && obj.length === 1 && typeof obj[0] === 'number') {
        returnedObj.state = obj[0];
        return returnedObj;
Severity: Major
Found in packages/optimise-sync/src/utils/format-response.js and 2 other locations - About 5 hrs to fix
packages/optimise-core/src/utils/format-response.js on lines 1..16
packages/optimise-remote-control/src/utils/format-response.js on lines 1..16

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

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

    render() {
        const allVisitDates = this.props.data.visits.filter(el => el.type === 1).map(el => el.visitDate);
        const allTestDates = this.props.data.tests.map(el => el.actualOccurredDate || el.expectedOccurDate);
        const allTreatmentDates = this.props.data.treatments.map(el => el.startDate);
        const allCEDates = [];
Severity: Major
Found in packages/optimise-ui/src/components/patientProfile/timeline.jsx - About 5 hrs to fix

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

        render() {
    
            const { patientProfile, match } = this.props;
            const { params } = match;
            const { pregnancyOutcomes } = this.props.fields;
    Severity: Major
    Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx - About 5 hrs to fix

      Function render has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          render() {
      
              const { patientProfile, match } = this.props;
              const { params } = match;
              const { pregnancyOutcomes } = this.props.fields;
      Severity: Minor
      Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx - About 5 hrs 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 getDerivedStateFromProps has 135 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static getDerivedStateFromProps(props, state) {
      
              let items = [];
              let edssPoints = {};
              let maxTimeStart = state.defaultTimeStart;
      Severity: Major
      Found in packages/optimise-ui/src/components/patientProfile/fullTimeline.jsx - About 5 hrs to fix

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

                            return (
                                <div key={Math.random()} className={style.dataItem}>
                                    <label>{content.definition}{content.unit ? <em> in {content.unit}</em> : ''}</label>
                                    <AntibodyField origVal={origVal ? origVal : null} reference={references[content.id].ref} /><br /><br />
                                </div>
        Severity: Major
        Found in packages/optimise-ui/src/components/medicalData/utils.jsx and 1 other location - About 5 hrs to fix
        packages/optimise-ui/src/components/medicalData/utils.jsx on lines 384..389

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

        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

                            return (
                                <div key={Math.random()} className={style.dataItem}>
                                    <label>{content.definition}{content.unit ? <em> in {content.unit}</em> : ''}</label>
                                    <TextField origVal={origVal ? origVal : null} reference={references[content.id].ref} /><br /><br />
                                </div>
        Severity: Major
        Found in packages/optimise-ui/src/components/medicalData/utils.jsx and 1 other location - About 5 hrs to fix
        packages/optimise-ui/src/components/medicalData/utils.jsx on lines 377..382

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

        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 index.js has 388 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        const fs = require('fs');
        const path = require('path');
        const { Readable } = require('stream');
        const express = require('express');
        const { app, session, BrowserWindow, ipcMain, dialog, Menu } = require('electron');
        Severity: Minor
        Found in packages/optimise-electron/index.js - About 5 hrs to fix

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

                                  <select name='unit' value={this.state.unit} onChange={this._handleInputChange} autoComplete='off'>
                                      <option value='unselected'></option>
                                      <option value='cc'>cc</option>
                                      <option value='mg'>mg</option>
                                      <option value='µg'>µg</option>
          packages/optimise-ui/src/components/createMedicalElements/createTreatment.jsx on lines 176..182

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

          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

                                  <select name='times' value={this.state.times} onChange={this._handleInputChange} autoComplete='off'>
                                      <option value='unselected'></option>
                                      <option value='1'>once</option>
                                      <option value='2'>twice</option>
                                      <option value='3'>three times</option>
          packages/optimise-ui/src/components/createMedicalElements/createTreatment.jsx on lines 158..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 137.

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

              itemRenderer({ item, getItemProps, timelineContext }) {
          
                  let itemProps = getItemProps(item.itemProps);
                  const itemPropsStyle = {
                      ...itemProps.style,
          Severity: Major
          Found in packages/optimise-ui/src/components/patientProfile/fullTimeline.jsx - About 5 hrs to fix

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

                        return (
                            <a style={{ gridColumn: `${start + 3}/${end + 3}`, gridRow: '1' }} title={new Date(startDate).toDateString()} key={`${med.id}`} href={`#treatment-${med.id}`}>
                                <div className={style.timelineMed}>-</div>
                            </a>
                        );
            packages/optimise-ui/src/components/patientProfile/timeline.jsx on lines 106..110

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

            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

                        return (
                            <a style={{ gridColumn: `${start + 3}/${end + 3}`, gridRow: '5' }} title={new Date(startDate).toDateString()} key={`${test.id}`} href={`#test-${test.id}`}>
                                <div className={style.timelineTest}>-</div>
                            </a>
                        );
            packages/optimise-ui/src/components/patientProfile/timeline.jsx on lines 121..125

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

            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