dsi-icl/optimise

View on GitHub

Showing 1,390 of 1,390 total issues

Function createSync has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    static async createSync({ body: { data, uuid, agent, key }, headers, connection }, res) {

        if (data === undefined || uuid === undefined) {
            res.status(401).json(ErrorHelper(message.userError.MISSINGARGUMENT));
            return;
Severity: Minor
Found in packages/optimise-sync/src/controllers/syncController.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 editPregnancyImage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    static editPregnancyImage({ body, user }, res) {
        //
        if (body.hasOwnProperty('id') && typeof body.id === 'number') {

            const entryObj = Object.assign({}, body);
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 render has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    render() {
        const { data, typedict, patientId, renderedInFrontPage } = this.props;
        const numberOfInterruptions = data.interruptions ? data.interruptions.length : 0;
        if (!typedict[data.drug])
            return null;
Severity: Minor
Found in packages/optimise-ui/src/components/patientProfile/patientChart.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 _handleSubmit has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

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

Severity: Minor
Found in packages/optimise-ui/src/components/createPatient/createPatient.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 login has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function login(state = initialState.login, action) {
    switch (action.type) {
        case actionTypes.login.LOGIN_REQUESTED:
            return { ...state, loggingIn: true, loginFailed: false, loggedIn: false, initialCheckingStatus: false, username: action.payload.username };
        case actionTypes.login.LOGIN_FAILURE:
Severity: Minor
Found in packages/optimise-ui/src/redux/reducers.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 _handleSubmitClick has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

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

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

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

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

          static getFields({ params, query }, res) {     //bound to GETclinicalEvents and GETtestTypes too
              const tableMap = {
                  visitFields: 'AVAILABLE_FIELDS_VISITS',
                  visitSections: 'AVAILABLE_VISIT_SECTIONS',
                  testFields: 'AVAILABLE_FIELDS_TESTS',
      Severity: Minor
      Found in packages/optimise-core/src/controllers/availableFieldController.js - About 1 hr to fix

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

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

              render() {
                  const { editing, date, result, mode } = this.state;
                  return (
                      <div className={style.interruption} style={{
                          overflow: editing ? 'visible' : 'hidden'
          Severity: Minor
          Found in packages/optimise-ui/src/components/pregnancyForms/pregImage.jsx - About 1 hr to fix

            Function _handleSubmit has 39 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()) {

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

                  static getDerivedStateFromProps(props, state) {
                      if (props.match.params.elementId === state.elementId)
                          return state;
                      return {
                          ...state,
              packages/optimise-ui/src/components/editMedicalElements/editMedication.jsx on lines 25..33
              packages/optimise-ui/src/components/editMedicalElements/editTest.jsx on lines 24..32

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

              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

                  static getDerivedStateFromProps(props, state) {
                      if (props.match.params.elementId === state.elementId)
                          return state;
                      return {
                          ...state,
              packages/optimise-ui/src/components/editMedicalElements/editClinicalEvent.jsx on lines 26..34
              packages/optimise-ui/src/components/editMedicalElements/editMedication.jsx on lines 25..33

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

              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

                  static getDerivedStateFromProps(props, state) {
                      if (props.match.params.elementId === state.elementId)
                          return state;
                      return {
                          ...state,
              packages/optimise-ui/src/components/editMedicalElements/editClinicalEvent.jsx on lines 26..34
              packages/optimise-ui/src/components/editMedicalElements/editTest.jsx on lines 24..32

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

              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

                  static getPregnancyAllFields(queryfield, queryvalue) {
                      return new Promise((resolve, reject) => searchEntry(queryfield, queryvalue).then((success) => resolve(success)).catch((error) => reject(ErrorHelper(message.errorMessages.SEARCHFAIL, error))));
                  }
              Severity: Major
              Found in packages/optimise-core/src/core/demographic.js and 1 other location - About 1 hr to fix
              packages/optimise-core/src/core/patient.js on lines 71..73

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

              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

                  static searchPatients(queryfield, queryvalue) {
                      return new Promise((resolve, reject) => searchEntry(queryfield, queryvalue).then((success) => resolve(success)).catch((error) => reject(ErrorHelper(message.errorMessages.SEARCHFAIL, error))));
                  }
              Severity: Major
              Found in packages/optimise-core/src/core/patient.js and 1 other location - About 1 hr to fix
              packages/optimise-core/src/core/demographic.js on lines 197..199

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

              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

                                  <div>
                                      <img src={edgeImg} alt="Edge" /><br /><br /><br />
                                      <em>Edge &gt; 30</em>
                                  </div>
              packages/optimise-ui/src/components/noSupport/noSupport.jsx on lines 15..18
              packages/optimise-ui/src/components/noSupport/noSupport.jsx on lines 25..28

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

              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

                                  <div>
                                      <img src={firefoxImg} alt="Firefox" /><br /><br /><br />
                                      <em>Firefox &gt; 40</em>
                                  </div>
              packages/optimise-ui/src/components/noSupport/noSupport.jsx on lines 15..18
              packages/optimise-ui/src/components/noSupport/noSupport.jsx on lines 20..23

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

              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

                                  <div>
                                      <img src={chromeImg} alt="Chrome" /><br /><br /><br />
                                      <em>Chrome &gt; 60</em>
                                  </div>
              packages/optimise-ui/src/components/noSupport/noSupport.jsx on lines 20..23
              packages/optimise-ui/src/components/noSupport/noSupport.jsx on lines 25..28

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

              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