dsi-icl/optimise

View on GitHub

Showing 380 of 1,390 total issues

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

export async function migrate() {

    // Verify the OPT_KV configuration table exists
    const isIntitialized = await dbcon().schema.hasTable('OPT_KV');
    let stepVersion = 0;
Severity: Minor
Found in packages/optimise-core/src/utils/db-handler.js - About 1 hr to fix

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

        getTreatments(patientId, deleted) {
            const _this = this;
            const whereObj = { patient: patientId };
            const innerWhereObj = {};
            if (deleted !== true) {
    Severity: Minor
    Found in packages/optimise-core/src/utils/selector-utils.js - About 1 hr to fix

      Function createPregnancy has 45 lines of code (exceeds 25 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 1 hr to fix

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

            render() {
                const { formatter = (node) => node.name, hash } = this.props;
                const { currentTermName, filterTerm, filterText, opened, nodes } = this.state;
                const { nodes: filteredNodes } = filterTerm !== '' ? filterNodes(nameMatchesSearchTerm(filterTerm), nodes) : { nodes };
        
        Severity: Minor
        Found in packages/optimise-ui/src/components/treePicker/treePicker.jsx - About 1 hr to fix

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

              render() {
                  const { patientProfile, match, location, renderedInFrontPage } = this.props;
          
                  let _style = style;
                  if (this.props.override_style) {

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

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

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

                  static createMedicalCondition({ body, user }, res) {
                      if (body.hasOwnProperty('patient') && body.hasOwnProperty('startDate') && body.hasOwnProperty('outcome') && body.hasOwnProperty('relation') && body.hasOwnProperty('conditionName') &&
                          ((body.hasOwnProperty('resolvedYear') && typeof body.resolvedYear === 'number') || !body.hasOwnProperty('resolvedYear')) &&
                          typeof body.patient === 'number' && typeof body.startDate === 'string' && typeof body.outcome === 'string' && typeof body.relation === 'number' && typeof body.conditionName === 'number') {
                          const momentStart = moment(body.startDate, moment.ISO_8601);
              Severity: Minor
              Found in packages/optimise-core/src/controllers/demographicDataController.js - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

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

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

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

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

                  render() {
                      const { syncInfo } = this.props;
              
                      if (syncInfo.config === undefined || syncInfo.config.host === undefined || syncInfo.config.host === '')
                          return null;
              Severity: Minor
              Found in packages/optimise-ui/src/components/scaffold/syncIndicator.jsx - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function createCe has 43 lines of code (exceeds 25 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 1 hr to fix

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

                    render() {
                        return (
                            <>
                                <div className={style.ariane}>
                                    <Helmet title='Administration Panel' />
                Severity: Minor
                Found in packages/optimise-ui/src/components/admin/actions.jsx - About 1 hr to fix

                  Function _handleSubmit has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

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

                    Consider simplifying this complex logical expression.
                    Open

                                                                if (inputValue !== '' && !(inputValue === true || inputValue === false || inputValue === 1 || inputValue === 0 || inputValue === '1' || inputValue === '0' || inputValue.toUpperCase() === 'YES' || inputValue.toUpperCase() === 'NO')) {
                                                                    res.status(400).json(ErrorHelper(`${message.dataMessage.BOOLEANFIELD}${fieldDefinition}`));
                                                                    return false;
                                                                }
                    Severity: Critical
                    Found in packages/optimise-core/src/controllers/dataController.js - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                              if (!patientProfile.fetching && this.state.pregnancyEntry) {
                      
                                  let pregnancyEntry = this.state.pregnancyEntry;
                      
                                  if (!pregnancyEntry.id && !this.treatAsNewEntry) {
                      Severity: Critical
                      Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx - About 1 hr to fix

                        Function handleMeddraUploadByAdmin has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            static async handleMeddraUploadByAdmin({ user, files }, res) {
                                if (user.adminPriv !== 1) {
                                    res.status(401).json({ error: 'Not authorized.' });
                                    return;
                                }
                        Severity: Minor
                        Found in packages/optimise-core/src/controllers/meddraController.js - About 1 hr to fix

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

                              render() {
                                  const { editing, startDate, endDate, noEndDate, reason, meddra, startDate_original, endDate_original, reason_original, meddra_original } = this.state;
                                  const { data, interruptionReasons, meddra_Hash } = this.props;
                                  return (
                                      <div className={style.interruption} style={{

                            Function end has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    end: (chunk) => {
                                        try {
                                            if (chunk !== undefined)
                                                res._sent = Buffer.concat([res._sent, chunk]);
                                            if (Buffer.byteLength(res._sent) === 0)
                            Severity: Minor
                            Found in packages/optimise-electron/index.js - About 1 hr to fix

                              Function addInterruption has 40 lines of code (exceeds 25 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 1 hr to fix

                                Function getClinicalEvents has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    getClinicalEvents(patientId, deleted) {
                                        const _this = this;
                                        const whereObj = { patient: patientId };
                                        const innerWhereObj = {};
                                        if (deleted !== true) {
                                Severity: Minor
                                Found in packages/optimise-core/src/utils/selector-utils.js - About 1 hr to fix

                                  Function _handleSubmit has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

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