dsi-icl/optimise

View on GitHub

Showing 1,390 of 1,390 total issues

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

export async function migrate() {

    const db = await dbcon().then(client => client.db());

    // // Verify the OPT_KV configuration table exists
Severity: Minor
Found in packages/optimise-sync/src/utils/db-handler.js - About 1 hr to fix

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

    export async function migrate() {
    
        const db = await dbcon().then(client => client.db());
    
        // // Verify the OPT_KV configuration table exists
    Severity: Minor
    Found in packages/optimise-remote-control/src/utils/db-handler.js - About 1 hr to fix

      Function alterPregnancyItemsCall has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const alterPregnancyItemsCall = (body, callback) => async (dispatch) => {
          try {
              //if pregnancy entry needs to be created and entry type is 1 (baseline) then new pregnancy needs to be created
      
              const pregnancyMethod = body.pregnancyEntry?.type === 1 && !body.pregnancy.id ? 'POST' : 'PUT';
      Severity: Minor
      Found in packages/optimise-ui/src/redux/actions/demographicData.js - About 1 hr to fix

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

            render() {
                const { data } = this.props;
                const { userId } = this.props.match.params;
                if (!data.fetching) {
                    const usersFiltered = data.result.filter(el => el.id === parseInt(userId, 10));
        Severity: Minor
        Found in packages/optimise-ui/src/components/admin/userDetailPage.jsx - About 1 hr to fix

          Function filterEmptyRenders has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const filterEmptyRenders = (allFields, inputType, typedict) => allFields.map(data => {
          
              const toTitleCase = (str) => str.replace(/\w\S*/g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
          
              let value;
          Severity: Minor
          Found in packages/optimise-ui/src/components/patientProfile/patientChart.jsx - About 1 hr to fix

            Function migrate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            export async function migrate() {
            
                const db = await dbcon().then(client => client.db());
            
                // // Verify the OPT_KV configuration table exists
            Severity: Minor
            Found in packages/optimise-remote-control/src/utils/db-handler.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 migrate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            export async function migrate() {
            
                const db = await dbcon().then(client => client.db());
            
                // // Verify the OPT_KV configuration table exists
            Severity: Minor
            Found in packages/optimise-sync/src/utils/db-handler.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 11 (exceeds 5 allowed). Consider refactoring.
            Open

                render() {
            
                    if (this.props.data.demographicData) {
                        if (this.props.data.demographicData.gender === 1)
                            return null;

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

                _updateStatus() {
            
                    const now = (new Date()).getTime();
                    const { syncInfo: { config, status: { syncing, error, status } }, loggedIn } = this.props;
                    const { lastCall, triggered } = this.state;
            Severity: Minor
            Found in packages/optimise-ui/src/components/scaffold/syncIndicator.jsx - About 1 hr to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                render() {
                    const { editing } = this.state;
                    const { data, typedict } = this.props;
                    return (
                        <div className={style.interruption} style={{

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

            const oneSignOrSymptom = (data, VSFields_Hash) => {
                const fieldObj = VSFields_Hash[data.field];
                if (fieldObj) {
                    if (fieldObj.type === 5) {
                        return `- ${fieldObj.idname.replace(/:/g, ' > ')}: ${data.value === '1' ? 'Yes' : (data.value === '0' ? 'No' : 'Unknown')}`;

            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

            Similar blocks of code found in 4 locations. Consider refactoring.
            Open

                _handleFreeTextChange(ev) {
                    const newState = { error: false };
                    newState[ev.target.name] = ev.target.value;
                    this.setState(newState);
                }
            packages/optimise-ui/src/components/createPatient/createPatient.jsx on lines 93..97
            packages/optimise-ui/src/components/createPatient/createPatient.jsx on lines 99..103
            packages/optimise-ui/src/components/editMedicalElements/editDemographic.jsx on lines 79..83

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

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

                _handlePregnancyConsentChange(ev) {
                    const newState = { error: false };
                    newState[ev.target.name] = ev.target.value;
                    this.setState(newState);
                }
            packages/optimise-ui/src/components/createPatient/createPatient.jsx on lines 93..97
            packages/optimise-ui/src/components/createPatient/createPatient.jsx on lines 105..109
            packages/optimise-ui/src/components/editMedicalElements/editDemographic.jsx on lines 79..83

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

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

                _handleFreeTextChange(ev) {
                    const newState = { error: false };
                    newState[ev.target.name] = ev.target.value;
                    this.setState(newState);
                }
            packages/optimise-ui/src/components/createPatient/createPatient.jsx on lines 93..97
            packages/optimise-ui/src/components/createPatient/createPatient.jsx on lines 99..103
            packages/optimise-ui/src/components/createPatient/createPatient.jsx on lines 105..109

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

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

                _handleConsentChange(ev) {
                    const newState = { error: false };
                    newState[ev.target.name] = ev.target.value;
                    this.setState(newState);
                }
            packages/optimise-ui/src/components/createPatient/createPatient.jsx on lines 99..103
            packages/optimise-ui/src/components/createPatient/createPatient.jsx on lines 105..109
            packages/optimise-ui/src/components/editMedicalElements/editDemographic.jsx on lines 79..83

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

            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

                static createPregnancyEntry(entryObj) {
                    return new Promise((resolve, reject) => createEntry('PREGNANCY_ENTRY', entryObj).then((result) => resolve(result)).catch((error) => reject(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/demographic.js on lines 163..165

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

            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.setState({
                        lastImageSubmit: (new Date()).getTime(),
                        showAddNewImageData: false,
                        error: false
                    }, () => {
            packages/optimise-ui/src/components/editMedicalElements/createConmitantMeds.jsx on lines 209..216

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

            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

                constructor() {
                    super();
                    this._handleClickDelete = this._handleClickDelete.bind(this);
                    this._deleteFunction = this._deleteFunction.bind(this);
                }
            packages/optimise-ui/src/components/filterPatient/selectPanel.jsx on lines 5..9

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

            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

                static createPregnancyImage(entryObj) {
                    return new Promise((resolve, reject) => createEntry('PATIENT_PREGNANCY_IMAGING', entryObj).then((result) => resolve(result)).catch((error) => reject(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/demographic.js on lines 180..182

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

            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.setState({
                        lastSubmit: (new Date()).getTime(),
                        error: false,
                        editing: false
                    }, () => {
            packages/optimise-ui/src/components/pregnancyForms/pregImage.jsx on lines 72..79

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            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