dsi-icl/optimise

View on GitHub

Showing 1,390 of 1,390 total issues

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()) {

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

                  constructor(props) {
                      super(props);
              
                      this.timeBoudary = this.timeBoudary.bind(this);
                      this.groupRenderer = this.groupRenderer.bind(this);
              Severity: Minor
              Found in packages/optimise-ui/src/components/patientProfile/fullTimeline.jsx - About 1 hr to fix

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

                    render() {
                        const { editing, startDate, outcomeDate, noEndDate, outcome, meddra, startDate_original, outcomeDate_original, outcome_original, meddra_original } = this.state;
                        const { data, pregnancyOutcomes, meddra_Hash } = this.props;
                        return (
                            <div className={style.interruption} style={{

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

                              searchEntry(queryfield, queryvalue)
                                  .then(result => result && result.length !== undefined ? result : [])
                                  .then(result => result.length > 0 ? result.map(({ uuid, aliasId }) => ({ optimiseID: uuid, patientId: aliasId })) : ExportDataController.createNoDataFile())
                                  .then(result => result.length !== undefined ? [ExportDataController.createJsonDataFile(['patientMappings', result]), ExportDataController.createCsvDataFile(['patientMappings', result])] : [result])
                                  .then(filesArray => res.status(200).zip(filesArray, `${attachmentName}.zip`))
                  packages/optimise-core/src/controllers/exportDataController.js on lines 97..103

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

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

                              searchEntry(queryfield, queryvalue)
                                  .then(result => result && result.length !== undefined ? result : [])
                                  .then(result => result.length > 0 ? ExportDataController[extractor](result.map(({ patientId }) => patientId)) : ExportDataController.createNoDataFile())
                                  .then(matrixResults => matrixResults.length !== undefined ? matrixResults.reduce((a, dr) => dr[1][0] !== undefined ? [...a, ExportDataController.createJsonDataFile(dr), ExportDataController.createCsvDataFile(dr)] : a, []) : [ExportDataController.createNoDataFile()])
                                  .then(matrixResults => matrixResults.length !== 0 ? matrixResults : [ExportDataController.createNoDataFile()])
                  packages/optimise-core/src/controllers/exportDataController.js on lines 74..79

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

                  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

                              if (concomitantMedId) {
                                  if (typeof concomitantMedId === 'number') {
                                      entryObj.concomitantMedId = concomitantMedId;
                                  } else {
                                      res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
                  packages/optimise-core/src/controllers/concomitantMedController.js on lines 61..68
                  packages/optimise-core/src/controllers/concomitantMedController.js on lines 69..76

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

                  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

                              if (startDate) {
                                  if (typeof startDate === 'number') {
                                      entryObj.startDate = startDate;
                                  } else {
                                      res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
                  packages/optimise-core/src/controllers/concomitantMedController.js on lines 53..60
                  packages/optimise-core/src/controllers/concomitantMedController.js on lines 61..68

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

                  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

                              if (indication) {
                                  if (typeof indication === 'string') {
                                      entryObj.indication = indication;
                                  } else {
                                      res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
                  packages/optimise-core/src/controllers/concomitantMedController.js on lines 53..60
                  packages/optimise-core/src/controllers/concomitantMedController.js on lines 69..76

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

                  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

                  @withRouter
                  @connect(state => ({
                      typedict: state.availableFields.clinicalEventTypes_Hash[0],
                      patientId: state.patientProfile.data.patientId,
                      meddraHash: state.availableFields.meddra_Hash[0]
                  packages/optimise-ui/src/components/patientProfile/patientChart.jsx on lines 121..163

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

                  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 key = await dbcon()('OPT_KV').where({ key: 'SYNC_KEY' }).update({
                              value: options.key,
                              updated_at: dbcon().fn.now()
                          });
                  Severity: Major
                  Found in packages/optimise-core/src/core/sync.js and 1 other location - About 1 hr to fix
                  packages/optimise-core/src/core/sync.js on lines 47..50

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

                  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

                          if ((!body.hasOwnProperty('patient') || !body.hasOwnProperty('DOB') || !body.hasOwnProperty('gender') || !body.hasOwnProperty('dominant_hand')
                              || !body.hasOwnProperty('ethnicity') || !body.hasOwnProperty('country_of_origin'))) {
                  packages/optimise-core/src/controllers/userController.js on lines 72..72

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

                  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

                  @withRouter
                  @connect(state => ({
                      typedict: state.availableFields.drugs_Hash[0],
                      patientId: state.patientProfile.data.patientId,
                      reasondict: state.availableFields.interruptionReasons_Hash[0]
                  packages/optimise-ui/src/components/patientProfile/patientChart.jsx on lines 168..195

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

                  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 host = await dbcon()('OPT_KV').where({ key: 'SYNC_HOST' }).update({
                              value: hostURL.href,
                              updated_at: dbcon().fn.now()
                          });
                  Severity: Major
                  Found in packages/optimise-core/src/core/sync.js and 1 other location - About 1 hr to fix
                  packages/optimise-core/src/core/sync.js on lines 51..54

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

                  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

                          if (!body.hasOwnProperty('pw') || !body.hasOwnProperty('username') || !body.hasOwnProperty('isAdmin') || !body.hasOwnProperty('realname') || !body.hasOwnProperty('email')) {
                  Severity: Major
                  Found in packages/optimise-core/src/controllers/userController.js and 1 other location - About 1 hr to fix
                  packages/optimise-core/src/controllers/demographicDataController.js on lines 18..19

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

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

                      static createTest({ body, user }, res) {
                          if (!body.hasOwnProperty('visitId') || !body.hasOwnProperty('expectedOccurDate') || !body.hasOwnProperty('type')) {
                              res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
                              return;
                          }
                  Severity: Minor
                  Found in packages/optimise-core/src/controllers/testController.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

                  Severity
                  Category
                  Status
                  Source
                  Language