dsi-icl/optimise

View on GitHub

Showing 380 of 1,390 total issues

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

    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

      Function render has a Cognitive Complexity of 33 (exceeds 5 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: Minor
      Found in packages/optimise-ui/src/components/patientProfile/timeline.jsx - About 4 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 availableFields has 121 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function availableFields(state = initialState.availableFields, action) {
          let newState;
          let hash;
          switch (action.type) {
              case actionTypes.availableFields.GET_CE_TYPES_SUCCESS:
      Severity: Major
      Found in packages/optimise-ui/src/redux/reducers.js - About 4 hrs to fix

        File calculator.jsx has 366 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import React, { Component, Fragment } from 'react';
        import { Redirect } from 'react-router-dom';
        import { connect } from 'react-redux';
        import { BackButton } from '../medicalData/utils';
        import Helmet from '../scaffold/helmet';
        Severity: Minor
        Found in packages/optimise-ui/src/components/EDSScalculator/calculator.jsx - About 4 hrs to fix

          Function searchEntry has 119 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const searchEntry = function (queryfield, queryvalue) {
              switch (queryfield) {
                  case 'OPTIMISEID':
                      return new Promise((resolve, reject) => dbcon()('PATIENTS')
                          .select({ patientId: 'id' }, 'aliasId', 'uuid', 'optimiseConsent', 'participation')
          Severity: Major
          Found in packages/optimise-core/src/utils/controller-utils.js - About 4 hrs to fix

            File reducers.js has 358 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import initialState from './initialState';
            import { combineReducers } from 'redux';
            import actionTypes from './actions/listOfActions';
            import { dispatch as workerDispatch } from '../webWorker';
            
            
            Severity: Minor
            Found in packages/optimise-ui/src/redux/reducers.js - About 4 hrs to fix

              Function createCe has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
              Open

                  static createCe({ body, user }, res) {
                      if ((body.hasOwnProperty('visitId') || body.hasOwnProperty('patient')) && body.hasOwnProperty('dateStartDate') && body.hasOwnProperty('type') &&
                          typeof body.visitId === 'number' && typeof body.dateStartDate === 'string' && typeof body.type === 'number') {
                          const momentStart = moment(body.dateStartDate, moment.ISO_8601);
                          if (!momentStart.isValid()) {
              Severity: Minor
              Found in packages/optimise-core/src/controllers/ceController.js - About 4 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

              File utils.jsx has 357 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import React, { Component, Fragment } from 'react';
              import { Link } from 'react-router-dom';
              import merge from 'deepmerge';
              import moment from 'moment';
              import { PickDate } from '../createMedicalElements/datepicker';
              Severity: Minor
              Found in packages/optimise-ui/src/components/medicalData/utils.jsx - About 4 hrs to fix

                Function createTreatment has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                Open

                    static createTreatment({ body, user }, res) {
                        if (!(body.hasOwnProperty('visitId') && body.hasOwnProperty('drugId') && body.hasOwnProperty('startDate'))) {
                            res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
                            return;
                        }
                Severity: Minor
                Found in packages/optimise-core/src/controllers/treatmentController.js - About 4 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

                File createConmitantMeds.jsx has 350 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import React, { Component } from 'react';
                import { connect } from 'react-redux';
                import { BackButton } from '../medicalData/utils';
                import store from '../../redux/store';
                import { DeleteButton } from '../patientProfile/sharedComponents';

                  File treatmentInterruptions.jsx has 345 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import React, { Component } from 'react';
                  import { connect } from 'react-redux';
                  import moment from 'moment';
                  import { BackButton } from './utils';
                  import { PickDate } from '../createMedicalElements/datepicker';

                    File editPregnancy.jsx has 333 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import React, { Component } from 'react';
                    import { connect } from 'react-redux';
                    import moment from 'moment';
                    import { BackButton } from '../medicalData/utils';
                    import { PickDate } from '../createMedicalElements/datepicker';

                      Function editInterruption has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                      Open

                          static editInterruption({ body, user }, res) {
                              if (body.hasOwnProperty('treatmentInterId') && typeof body.treatmentInterId === 'number' &&
                                  body.hasOwnProperty('start_date') && typeof body.start_date === 'string') {
                                  const momentStart = body.hasOwnProperty('start_date') && body.start_date !== null ? moment(body.start_date, moment.ISO_8601) : null;
                                  const momentEnd = body.hasOwnProperty('end_date') && body.end_date !== null ? moment(body.end_date, moment.ISO_8601) : null;
                      Severity: Minor
                      Found in packages/optimise-core/src/controllers/treatmentController.js - About 3 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 render has 95 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          render() {
                      
                              if (!this.originalValues || !this.EDSSFields_Hash_reverse || !this.EDSSFields) return null;
                      
                              const { match: { params }, patientProfile: { visits } } = this.props;
                      Severity: Major
                      Found in packages/optimise-ui/src/components/EDSScalculator/calculator.jsx - About 3 hrs to fix

                        Function _RouterAddOrUpdate has 94 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            static _RouterAddOrUpdate(req, res) {
                                if (optionsContainer.hasOwnProperty(`${req.params.dataType}`)) {
                                    const options = optionsContainer[req.params.dataType];
                                    if (!(req.body.hasOwnProperty(`${options.entryIdString}`) &&
                                        (req.body.hasOwnProperty('add') || req.body.hasOwnProperty('update')))) {
                        Severity: Major
                        Found in packages/optimise-core/src/controllers/dataController.js - About 3 hrs to fix

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

                              render() {
                                  if (!this.state.dispatched) {
                                      const { genders, dominant_hands, ethnicities, countries } = this.props.demofields;
                                      let genders_sorted = [];
                                      genders.forEach((el) => {
                          Severity: Major
                          Found in packages/optimise-ui/src/components/createPatient/createPatient.jsx - About 3 hrs to fix

                            Function editConcomitantMed has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                            Open

                                static editConcomitantMed({ body, user }, res) {
                                    if (body.concomitantMedEntryId && typeof body.concomitantMedEntryId === 'number') {
                                        const entryObj = { id: body.concomitantMedEntryId };
                                        const { concomitantMedId, indication, startDate, endDate } = body;
                                        if (concomitantMedId) {
                            Severity: Minor
                            Found in packages/optimise-core/src/controllers/concomitantMedController.js - About 3 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 erasePatient has 88 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                static erasePatient({ user, body }, res) {
                                    let patientId = undefined;
                                    if (user.adminPriv !== 1) {
                                        res.status(401).json(ErrorHelper(message.userError.NORIGHTS));
                                        return false;
                            Severity: Major
                            Found in packages/optimise-core/src/controllers/patientController.js - About 3 hrs to fix

                              File sync.js has 313 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import os from 'os';
                              import request from 'request';
                              import { getEntry } from '../utils/controller-utils';
                              import dbcon from '../utils/db-connection';
                              import PatientCore from './patient';
                              Severity: Minor
                              Found in packages/optimise-core/src/core/sync.js - About 3 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language