dsi-icl/optimise

View on GitHub
packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx

Summary

Maintainability
F
1 wk
Test Coverage

File pregnancyEntry.jsx has 708 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { Component, useState, useEffect } from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { createLevelObj, mappingFields, BackButton, checkIfObjIsEmpty } from '../medicalData/utils';
import Icon from '../icon';
Severity: Major
Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx - About 1 day to fix

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

        render() {
    
            const { patientProfile, match } = this.props;
            const { params } = match;
            const { pregnancyOutcomes } = this.props.fields;
    Severity: Major
    Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx - About 5 hrs to fix

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

          render() {
      
              const { patientProfile, match } = this.props;
              const { params } = match;
              const { pregnancyOutcomes } = this.props.fields;
      Severity: Minor
      Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx - About 5 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

      Consider simplifying this complex logical expression.
      Open

              if (entryType === 1) {
                  body.pregnancy.startDate = this.state.pregnancyStartDate ? this.state.pregnancyStartDate.toISOString() : null;
              }
              else {
                  body.pregnancy.outcome = (entryType === 3 && this.state.pregnancyOutcome)
      Severity: Critical
      Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx - About 2 hrs to fix

        Function _getNewStateFromProps has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static _getNewStateFromProps(props) {
        
                const { patientProfile, data, match } = props;
                const { params } = match;
        
        
        Severity: Major
        Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx - About 2 hrs to fix

          Function _getNewStateFromProps has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              static _getNewStateFromProps(props) {
          
                  const { patientProfile, data, match } = props;
                  const { params } = match;
          
          
          Severity: Minor
          Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.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

          Function _formatBody has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              _formatBody(update, add) {
                  const { params } = this.props.match;
                  const { outcomeApplicable, pregnancyEntry } = this.state;
          
                  const entryType = pregnancyEntry.type === 1 ? 1 : (outcomeApplicable === 'yes' ? 3 : 2);
          Severity: Minor
          Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.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

          PregnancyEntry has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          @withRouter
          @connect(mapStateToProps)
          class PregnancyEntry extends Component {
              constructor(props) {
                  super();
          Severity: Minor
          Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx - About 2 hrs to fix

            Function _composeSubmitBody has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _composeSubmitBody() {
                    if (this.state.lastSubmit && (new Date()).getTime() - this.state.lastSubmit < 500 ? true : false)
                        return;
            
                    const { references, originalValues } = this;
            Severity: Major
            Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx - About 2 hrs to fix

              Function _validateFields has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  _validateFields() {
              
                      const { visitId } = this.props.match.params;
                      const { outcomeApplicable, pregnancyEntry } = this.state;
                      const { data } = this.props;

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

                  _findDateRange(date, entryType) {
              
                      let pregnancies = Array.from(this.props.data.pregnancy);
              
                      let currentPregnancy;

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

                  static _checkEntryOrder(pregnancyEntry, data) {
                      let pregnancyId = pregnancyEntry.pregnancyId;
                      const currentVisit = data.visits.find(el => parseInt(el.id) === parseInt(pregnancyEntry.recordedDuringVisit));
              
                      const allPregnancyEntries = data.pregnancyEntries.filter((el) => parseInt(el.pregnancyId) === parseInt(pregnancyId));

              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

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

                    _formatBody(update, add) {
                        const { params } = this.props.match;
                        const { outcomeApplicable, pregnancyEntry } = this.state;
                
                        const entryType = pregnancyEntry.type === 1 ? 1 : (outcomeApplicable === 'yes' ? 3 : 2);

                  Function OffspringDataFields has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const OffspringDataFields = ({
                      originalValues,
                      atDeliveryOutcome,
                      onOffspringChange
                  }) => {

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

                      _findDateRange(date, entryType) {
                  
                          let pregnancies = Array.from(this.props.data.pregnancy);
                  
                          let currentPregnancy;

                    Function _validateFields has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        _validateFields() {
                    
                            const { visitId } = this.props.match.params;
                            const { outcomeApplicable, pregnancyEntry } = this.state;
                            const { data } = this.props;

                      Function _checkEntryOrder has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          static _checkEntryOrder(pregnancyEntry, data) {
                              let pregnancyId = pregnancyEntry.pregnancyId;
                              const currentVisit = data.visits.find(el => parseInt(el.id) === parseInt(pregnancyEntry.recordedDuringVisit));
                      
                              const allPregnancyEntries = data.pregnancyEntries.filter((el) => parseInt(el.pregnancyId) === parseInt(pregnancyId));

                        Function initializeComponent has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            initializeComponent() {
                                const { fields, patientProfile } = this.props;
                        
                                if (!patientProfile.fetching) {
                                    const newPregnancyState = PregnancyEntry._getNewStateFromProps(this.props);

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

                            static _getPregnancyStatus(date, pregnancies) {
                        
                                const sortedPregnancies = pregnancies.sort((a, b) => {
                                    // Sort pregnancies in descending order based on startDate
                                    return parseFloat(b.startDate) - parseFloat(a.startDate);

                          Function initializeComponent has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              initializeComponent() {
                                  const { fields, patientProfile } = this.props;
                          
                                  if (!patientProfile.fetching) {
                                      const newPregnancyState = PregnancyEntry._getNewStateFromProps(this.props);

                            Function _getPregnancyStatus has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                static _getPregnancyStatus(date, pregnancies) {
                            
                                    const sortedPregnancies = pregnancies.sort((a, b) => {
                                        // Sort pregnancies in descending order based on startDate
                                        return parseFloat(b.startDate) - parseFloat(a.startDate);
                            Severity: Minor
                            Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx - About 35 mins 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

                            Avoid too many return statements within this function.
                            Open

                                    return '';
                            Severity: Major
                            Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return 'Please enter both the outcome date and the outcome';
                              Severity: Major
                              Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx - About 30 mins to fix

                                Function _composeSubmitBody has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    _composeSubmitBody() {
                                        if (this.state.lastSubmit && (new Date()).getTime() - this.state.lastSubmit < 500 ? true : false)
                                            return;
                                
                                        const { references, originalValues } = this;
                                Severity: Minor
                                Found in packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx - About 25 mins 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

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

                                            if (type === 'D') {
                                                const value = reference.current.value;
                                                if (originalValues[fieldId] !== undefined) {
                                                    if (originalValues[fieldId] !== value)
                                                        update[fieldId] = value;
                                packages/optimise-ui/src/components/medicalData/ceDataPage.jsx on lines 103..111

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

                                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

                                                                        <label >Would you like to add an outcome for this pregnancy?:
                                                                            <select value={this.state.outcomeApplicable}
                                                                                onChange={this._handleOutcomeApplicableChange}>
                                                                                <option value='yes'>Yes</option>
                                                                                <option value='no'>No</option>
                                packages/optimise-ui/src/components/pregnancyForms/pregImage.jsx on lines 107..112

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

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

                                    const _handleAPGAR1Change = (index, event) => {
                                        if (!offsprings[index])
                                            offsprings[index] = {};
                                        offsprings[index].apgar1 = event.target.value;
                                        setOffsprings([...offsprings]);
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 51..56
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 58..63
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 72..77
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 79..84

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

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

                                    const _handleCongenitalAffectChange = (index, event) => {
                                        if (!offsprings[index])
                                            offsprings[index] = {};
                                        offsprings[index].congenitalAffect = event.target.value;
                                        setOffsprings([...offsprings]);
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 51..56
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 58..63
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 65..70
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 72..77

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

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

                                    const _handleWeigthChange = (index, event) => {
                                        if (!offsprings[index])
                                            offsprings[index] = {};
                                        offsprings[index].weight = event.target.value;
                                        setOffsprings([...offsprings]);
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 51..56
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 65..70
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 72..77
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 79..84

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

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

                                    const _handleGenderChange = (index, event) => {
                                        if (!offsprings[index])
                                            offsprings[index] = {};
                                        offsprings[index].gender = event.target.value;
                                        setOffsprings([...offsprings]);
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 58..63
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 65..70
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 72..77
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 79..84

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

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

                                    const _handleAPGAR5Change = (index, event) => {
                                        if (!offsprings[index])
                                            offsprings[index] = {};
                                        offsprings[index].apgar5 = event.target.value;
                                        setOffsprings([...offsprings]);
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 51..56
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 58..63
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 65..70
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 79..84

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

                                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 ((entryType === 1 && isValidDateRange(this.state.pregnancyStartDate.toDate()))) {
                                            return `Pregnancy start date conflicts with end date or existing pregnancies. Min viable date: 
                                            ${formatDate(dateLimit.minDate)} Max viable date: ${formatDate(dateLimit.maxDate)}`;
                                        }
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 620..623

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

                                        if ((entryType === 3 && isValidDateRange(this.state.pregnancyOutcomeDate.toDate()))) {
                                            return `Pregnancy end date conflicts with start date or existing pregnancies. Min viable date: 
                                            ${formatDate(dateLimit.minDate)} Max viable date: ${formatDate(dateLimit.maxDate)}`;
                                        }
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 615..618

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

                                                            {this.state.error ? <><div className={profile_style.error}>{this.state.error}</div><br /></> : null}
                                packages/optimise-ui/src/components/admin/sync.jsx on lines 89..89
                                packages/optimise-ui/src/components/createMedicalElements/createCE.jsx on lines 153..153
                                packages/optimise-ui/src/components/createMedicalElements/createTest.jsx on lines 124..124
                                packages/optimise-ui/src/components/createMedicalElements/createTreatment.jsx on lines 203..203
                                packages/optimise-ui/src/components/createPatient/createPatient.jsx on lines 252..252
                                packages/optimise-ui/src/components/editMedicalElements/createConmitantMeds.jsx on lines 245..245
                                packages/optimise-ui/src/components/editMedicalElements/createConmitantMeds.jsx on lines 376..376
                                packages/optimise-ui/src/components/editMedicalElements/editClinicalEvent.jsx on lines 217..217
                                packages/optimise-ui/src/components/editMedicalElements/editComorbidity.jsx on lines 108..108
                                packages/optimise-ui/src/components/editMedicalElements/editComorbidity.jsx on lines 214..214
                                packages/optimise-ui/src/components/editMedicalElements/editMedication.jsx on lines 274..274
                                packages/optimise-ui/src/components/editMedicalElements/editPregnancy.jsx on lines 167..167
                                packages/optimise-ui/src/components/editMedicalElements/editPregnancy.jsx on lines 339..339
                                packages/optimise-ui/src/components/editMedicalElements/editTest.jsx on lines 203..203
                                packages/optimise-ui/src/components/medicalData/treatmentInterruptions.jsx on lines 176..176
                                packages/optimise-ui/src/components/medicalData/treatmentInterruptions.jsx on lines 354..354
                                packages/optimise-ui/src/components/patientProfile/patientProfile.jsx on lines 281..281
                                packages/optimise-ui/src/components/pregnancyForms/pregImage.jsx on lines 269..269

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

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

                                                            {this.state.saved ? <><button disabled style={{ cursor: 'default', backgroundColor: 'green' }}>Successfully saved!</button><br /></> : null}
                                packages/optimise-ui/src/components/EDSScalculator/calculator.jsx on lines 274..274
                                packages/optimise-ui/src/components/medicalData/ceDataPage.jsx on lines 172..172
                                packages/optimise-ui/src/components/medicalData/testDataPage.jsx on lines 167..167
                                packages/optimise-ui/src/components/medicalData/visitDataPage.jsx on lines 172..172

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

                                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 inputTypeHash = this.props.fields.inputTypes.reduce((a, el) => { a[el.id] = el.value; return a; }, {});
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 672..672

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

                                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

                                        this.originalValues = this.state.pregnancyEntry.data.reduce((a, el) => { a[el.field] = el.value; return a; }, {});
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 670..670

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

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

                                            const inputTypeHash = fields.inputTypes.reduce((a, el) => { a[el.id] = el.value; return a; }, {});
                                packages/optimise-ui/src/components/medicalData/ceDataPage.jsx on lines 154..154
                                packages/optimise-ui/src/components/medicalData/testDataPage.jsx on lines 145..145
                                packages/optimise-ui/src/components/medicalData/visitDataPage.jsx on lines 155..155

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

                                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

                                            body.pregnancy.outcomeDate = this.state.pregnancyOutcome && ((entryType === 3 && this.state.pregnancyOutcomeDate)
                                                || (entryType === 2 && this.state.pregnancyOutcomeDate && this.state.entryOrder !== 'sole entry' && this.state.entryOrder !== 'latest'))
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 406..407

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

                                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

                                            body.pregnancy.outcome = (entryType === 3 && this.state.pregnancyOutcome)
                                                || (entryType === 2 && this.state.pregnancyOutcome && this.state.entryOrder !== 'sole entry' && this.state.entryOrder !== 'latest') // follow up entry added between term and baseline
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 409..410

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

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

                                        if (this.state.lastSubmit && (new Date()).getTime() - this.state.lastSubmit < 500 ? true : false)
                                            return;
                                packages/optimise-ui/src/components/EDSScalculator/calculator.jsx on lines 114..115
                                packages/optimise-ui/src/components/createMedicalElements/createCE.jsx on lines 88..89
                                packages/optimise-ui/src/components/createMedicalElements/createTest.jsx on lines 69..70
                                packages/optimise-ui/src/components/createMedicalElements/createTreatment.jsx on lines 92..93
                                packages/optimise-ui/src/components/createMedicalElements/createVisit.jsx on lines 69..70
                                packages/optimise-ui/src/components/createPatient/createPatient.jsx on lines 113..114
                                packages/optimise-ui/src/components/editMedicalElements/createConmitantMeds.jsx on lines 187..188
                                packages/optimise-ui/src/components/editMedicalElements/createConmitantMeds.jsx on lines 328..329
                                packages/optimise-ui/src/components/editMedicalElements/editClinicalEvent.jsx on lines 173..174
                                packages/optimise-ui/src/components/editMedicalElements/editCommunication.jsx on lines 221..222
                                packages/optimise-ui/src/components/editMedicalElements/editComorbidity.jsx on lines 39..40
                                packages/optimise-ui/src/components/editMedicalElements/editComorbidity.jsx on lines 161..162
                                packages/optimise-ui/src/components/editMedicalElements/editDemographic.jsx on lines 87..88
                                packages/optimise-ui/src/components/editMedicalElements/editEdss.jsx on lines 48..49
                                packages/optimise-ui/src/components/editMedicalElements/editMedication.jsx on lines 169..170
                                packages/optimise-ui/src/components/editMedicalElements/editPregnancy.jsx on lines 76..77
                                packages/optimise-ui/src/components/editMedicalElements/editPregnancy.jsx on lines 231..232
                                packages/optimise-ui/src/components/editMedicalElements/editPrimaryDiagnosis.jsx on lines 52..53
                                packages/optimise-ui/src/components/editMedicalElements/editPrimaryDiagnosis.jsx on lines 177..178
                                packages/optimise-ui/src/components/editMedicalElements/editTest.jsx on lines 152..153
                                packages/optimise-ui/src/components/editMedicalElements/editVisit.jsx on lines 99..100
                                packages/optimise-ui/src/components/medicalData/ceDataPage.jsx on lines 64..65
                                packages/optimise-ui/src/components/medicalData/testDataPage.jsx on lines 65..66
                                packages/optimise-ui/src/components/medicalData/treatmentInterruptions.jsx on lines 76..77
                                packages/optimise-ui/src/components/medicalData/treatmentInterruptions.jsx on lines 245..246
                                packages/optimise-ui/src/components/medicalData/visitDataPage.jsx on lines 67..68
                                packages/optimise-ui/src/components/patientProfile/patientProfile.jsx on lines 218..219
                                packages/optimise-ui/src/components/pregnancyForms/pregImage.jsx on lines 59..60
                                packages/optimise-ui/src/components/pregnancyForms/pregImage.jsx on lines 178..179

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

                                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

                                                                    this.treatAsNewEntry && (this.state.pregnancyEntry.type === 2 || this.state.pregnancyEntry.type === 3) ?
                                                                        <>
                                                                            <br /><br />
                                                                            <p>Ongoing pregnancy start date: {this.state.pregnancyStartDate && this.state.pregnancyStartDate.toString().slice(0, 10)}. Please enter details for a follow up pregnancy record.</p><br /><br />
                                                                        </>
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 804..814

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

                                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

                                                                {this.treatAsNewEntry && (this.state.pregnancyEntry.type === 2 || this.state.pregnancyEntry.type === 3) ?
                                                                    <div>
                                                                        <label >Would you like to add an outcome for this pregnancy?:
                                                                            <select value={this.state.outcomeApplicable}
                                                                                onChange={this._handleOutcomeApplicableChange}>
                                packages/optimise-ui/src/components/pregnancyForms/pregnancyEntry.jsx on lines 790..795

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

                                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

                                There are no issues that match your filters.

                                Category
                                Status