dsi-icl/optimise

View on GitHub

Showing 380 of 1,390 total issues

Function itemRenderer has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    itemRenderer({ item, getItemProps, timelineContext }) {

        let itemProps = getItemProps(item.itemProps);
        const itemPropsStyle = {
            ...itemProps.style,
Severity: Minor
Found in packages/optimise-ui/src/components/patientProfile/fullTimeline.jsx - 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 a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    render() {
        const { reference, choices, origVal } = this.props;
        if (choices.includes('LEFT'))
            return (
                <>
Severity: Minor
Found in packages/optimise-ui/src/components/medicalData/utils.jsx - 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 edssAlgorithm has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function edssAlgorithm(FSArrayWithoutAmbulation, ambulationScore) {

    if (FSArrayWithoutAmbulation.length === 0)
        return '';
Severity: Major
Found in packages/optimise-ui/src/components/EDSScalculator/calculator.jsx - About 3 hrs to fix

    Function createPregnancy has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        static createPregnancy({ body, user }, res) {
            if (body.hasOwnProperty('patient') && typeof body.patient === 'number') {
    
                if (body.hasOwnProperty('meddra') && body.meddra !== null && isNaN(parseInt(body.meddra))) {
                    res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
    Severity: Minor
    Found in packages/optimise-core/src/controllers/demographicDataController.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 alterPregnancyItemsCall has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    export const alterPregnancyItemsCall = (body, callback) => async (dispatch) => {
        try {
            //if pregnancy entry needs to be created and entry type is 1 (baseline) then new pregnancy needs to be created
    
            const pregnancyMethod = body.pregnancyEntry?.type === 1 && !body.pregnancy.id ? 'POST' : 'PUT';
    Severity: Minor
    Found in packages/optimise-ui/src/redux/actions/demographicData.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 addInterruption has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        static addInterruption({ body, user }, res) {    //need to search if treatment exists
            if (body.hasOwnProperty('treatmentId') && body.hasOwnProperty('start_date') &&
                typeof body.treatmentId === 'number' && typeof body.start_date === 'string') {
                const momentStart = moment(body.start_date, moment.ISO_8601);
                const momentEnd = moment(body.end_date, moment.ISO_8601);
    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 a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        render() {
    
            if (!this.props.data.visits)
                return null;
    
    
    Severity: Minor
    Found in packages/optimise-ui/src/components/patientProfile/patientChart.jsx - 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 _handleSubmit has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        _handleSubmit(ev) {
            ev.preventDefault();
            if (this.state.lastSubmit && (new Date()).getTime() - this.state.lastSubmit < 500 ? true : false)
                return;
            const criteria = [
    Severity: Minor
    Found in packages/optimise-ui/src/components/EDSScalculator/calculator.jsx - 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

    File treatmentController.js has 294 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import ErrorHelper from '../utils/error_helper';
    import message from '../utils/message-utils';
    import TreatmentCore from '../core/treatment';
    import formatToJSON from '../utils/format-response';
    import moment from 'moment';
    Severity: Minor
    Found in packages/optimise-core/src/controllers/treatmentController.js - About 3 hrs to fix

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

          render() {
              const { reference, choices, origVal } = this.props;
              if (choices.includes('LEFT'))
                  return (
                      <>
      Severity: Major
      Found in packages/optimise-ui/src/components/medicalData/utils.jsx - About 3 hrs to fix

        Function start has 75 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            start() {
                const _this = this;
                return new Promise((resolve, reject) => {
        
                    // Operate database migration if necessary
        Severity: Major
        Found in packages/optimise-core/src/optimiseServer.js - About 3 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                  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);
                      if (!momentStart.isValid() && body.startDate !== null) {
          Severity: Critical
          Found in packages/optimise-core/src/controllers/demographicDataController.js - About 3 hrs to fix

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

                render() {
                    if (this.props.visits) {
                        const params = this.props.match.params;
            
                        let _style = style;

              Function unwindEntries has 74 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      const unwindEntries = tree => {
                          const line = {
                              lineNum: globalLineCount++,
                              subjid: tree.subjid,
                              alias: tree.aliasId,
              Severity: Major
              Found in packages/optimise-core/src/controllers/exportDataController.js - About 2 hrs to fix

                Function transformData has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    transformData() {
                        const names = {};
                        const parents = {};
                        const leafs = [];
                
                Severity: Major
                Found in packages/optimise-core/src/core/MeddraHierarchyProcessor.js - About 2 hrs to fix

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

                      render() {
                          const { params: { currentPage, visitId, patientId } } = this.props.match;
                          const { onClickNext, formSaved } = this.props;
                          const { pregnancySubStudyConsent } = this.props.data;
                          const searchString = this.props.location.search;

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

                      render() {
                          let scaffold_style = _scaffold_style;
                          if (this.props.override_style) {
                              scaffold_style = { ..._scaffold_style, ...this.props.override_style };
                          }
                  Severity: Minor
                  Found in packages/optimise-ui/src/components/medicalData/visitDataPage.jsx - About 2 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

                  DemographicDataController has 25 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class DemographicDataController {
                  
                      static createDemographic({ body, user }, res) {
                          if ((!body.hasOwnProperty('patient') || !body.hasOwnProperty('DOB') || !body.hasOwnProperty('gender') || !body.hasOwnProperty('dominant_hand')
                              || !body.hasOwnProperty('ethnicity') || !body.hasOwnProperty('country_of_origin'))) {
                  Severity: Minor
                  Found in packages/optimise-core/src/controllers/demographicDataController.js - About 2 hrs to fix

                    OptimiseServer has 25 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class OptimiseServer {
                        constructor(config) {
                            this.config = new optimiseOptions(config);
                            this.app = express();
                    
                    
                    Severity: Minor
                    Found in packages/optimise-core/src/optimiseServer.js - About 2 hrs to fix

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

                          render() {
                              if (!this.props.data.demographicData) {
                                  return null;
                              }
                              const { visits } = this.props.data;
                      Severity: Major
                      Found in packages/optimise-ui/src/components/patientProfile/patientChart.jsx - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language