dsi-icl/optimise

View on GitHub

Showing 1,390 of 1,390 total issues

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

    static getEthnicityFields() {
        return new Promise((resolve, reject) => getEntry('ETHNICITIES', {}, '*').then((result) => {
            const returnObj = { ethnicities: result };
            return resolve(returnObj);
        }).catch((error) => reject(error)));
Severity: Major
Found in packages/optimise-core/src/core/demographic.js and 5 other locations - About 2 hrs to fix
packages/optimise-core/src/core/demographic.js on lines 32..37
packages/optimise-core/src/core/demographic.js on lines 46..51
packages/optimise-core/src/core/demographic.js on lines 53..58
packages/optimise-core/src/core/demographic.js on lines 88..93
packages/optimise-core/src/core/demographic.js on lines 95..100

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

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

    static getConditions() {
        return new Promise((resolve, reject) => getEntry('CONDITIONS', {}, '*').then((result) => {
            const returnObj = { conditions: result };
            return resolve(returnObj);
        }).catch((error) => reject(error)));
Severity: Major
Found in packages/optimise-core/src/core/demographic.js and 5 other locations - About 2 hrs to fix
packages/optimise-core/src/core/demographic.js on lines 32..37
packages/optimise-core/src/core/demographic.js on lines 39..44
packages/optimise-core/src/core/demographic.js on lines 46..51
packages/optimise-core/src/core/demographic.js on lines 53..58
packages/optimise-core/src/core/demographic.js on lines 88..93

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

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

export function erase() {
    return new Promise((resolve, reject) => {
        if (process.env.NODE_ENV !== 'test') {
            // if (process.env.NODE_ENV === 'development') console.log('Removing database file ...');
            // let filename = dbcon().client.config.connection.filename;
Severity: Major
Found in packages/optimise-sync/src/utils/db-handler.js and 1 other location - About 2 hrs to fix
packages/optimise-remote-control/src/utils/db-handler.js on lines 60..74

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

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

export function erase() {
    return new Promise((resolve, reject) => {
        if (process.env.NODE_ENV !== 'test') {
            // if (process.env.NODE_ENV === 'development') console.log('Removing database file ...');
            // let filename = dbcon().client.config.connection.filename;
Severity: Major
Found in packages/optimise-remote-control/src/utils/db-handler.js and 1 other location - About 2 hrs to fix
packages/optimise-sync/src/utils/db-handler.js on lines 60..74

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

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

    static getDominantHandsFields() {
        return new Promise((resolve, reject) => getEntry('DOMINANT_HANDS', {}, '*').then((result) => {
            const returnObj = { dominant_hands: result };
            return resolve(returnObj);
        }).catch((error) => reject(error)));
Severity: Major
Found in packages/optimise-core/src/core/demographic.js and 5 other locations - About 2 hrs to fix
packages/optimise-core/src/core/demographic.js on lines 32..37
packages/optimise-core/src/core/demographic.js on lines 39..44
packages/optimise-core/src/core/demographic.js on lines 53..58
packages/optimise-core/src/core/demographic.js on lines 88..93
packages/optimise-core/src/core/demographic.js on lines 95..100

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

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

    static getGenderFields() {
        return new Promise((resolve, reject) => getEntry('GENDERS', {}, '*').then((result) => {
            const returnObj = { genders: result };
            return resolve(returnObj);
        }).catch((error) => reject(error)));
Severity: Major
Found in packages/optimise-core/src/core/demographic.js and 5 other locations - About 2 hrs to fix
packages/optimise-core/src/core/demographic.js on lines 32..37
packages/optimise-core/src/core/demographic.js on lines 39..44
packages/optimise-core/src/core/demographic.js on lines 46..51
packages/optimise-core/src/core/demographic.js on lines 88..93
packages/optimise-core/src/core/demographic.js on lines 95..100

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

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

    static getRelations() {
        return new Promise((resolve, reject) => getEntry('RELATIONS', {}, '*').then((result) => {
            const returnObj = { relations: result };
            return resolve(returnObj);
        }).catch((error) => reject(error)));
Severity: Major
Found in packages/optimise-core/src/core/demographic.js and 5 other locations - About 2 hrs to fix
packages/optimise-core/src/core/demographic.js on lines 32..37
packages/optimise-core/src/core/demographic.js on lines 39..44
packages/optimise-core/src/core/demographic.js on lines 46..51
packages/optimise-core/src/core/demographic.js on lines 53..58
packages/optimise-core/src/core/demographic.js on lines 95..100

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

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

        if (!body.hasOwnProperty('visitId') || !body.hasOwnProperty('type') || !body.hasOwnProperty('pregnancyId')) {
            res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
            return;
        }
packages/optimise-core/src/controllers/testController.js on lines 10..13

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

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 (typeof body.visitId !== 'number' || typeof body.expectedOccurDate !== 'string' || typeof body.type !== 'number') {
            res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
            return;
        }
Severity: Major
Found in packages/optimise-core/src/controllers/testController.js and 1 other location - About 2 hrs to fix
packages/optimise-core/src/controllers/demographicDataController.js on lines 601..604

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

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 (typeof body.visitId !== 'number' || typeof body.type !== 'number' || typeof body.pregnancyId !== 'number') {
            res.status(400).json(ErrorHelper(message.userError.WRONGARGUMENTS));
            return;
        }
packages/optimise-core/src/controllers/testController.js on lines 14..17

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

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

        if (!body.hasOwnProperty('visitId') || !body.hasOwnProperty('expectedOccurDate') || !body.hasOwnProperty('type')) {
            res.status(400).json(ErrorHelper(message.userError.MISSINGARGUMENT));
            return;
        }
Severity: Major
Found in packages/optimise-core/src/controllers/testController.js and 1 other location - About 2 hrs to fix
packages/optimise-core/src/controllers/demographicDataController.js on lines 597..600

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

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function getICD11Field has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    static async getICD11Field({ query }, res) {
        const result = [];
        const maxOccurency = 20;
        await ICD11Controller.loadICD11Collection();
        if (query.hasOwnProperty('search')) {
Severity: Minor
Found in packages/optimise-core/src/controllers/icd11Controller.js - 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 render has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    render() {
        const { patientProfile, fields } = this.props;
        const { pregnancyOutcomes, meddra_Hash } = fields;
        if (!patientProfile.fetching) {
            return (

Cognitive Complexity

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

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

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

Further reading

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

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

Cognitive Complexity

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

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

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

Further reading

Function start has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    start() {
        const _this = this;
        return new Promise((resolve, reject) => {

            // Operate database migration if necessary
Severity: Major
Found in packages/optimise-remote-control/src/optimiseAssistServer.js - About 2 hrs to fix

    Function start has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        start() {
            const _this = this;
            return new Promise((resolve, reject) => {
    
                // Operate database migration if necessary
    Severity: Major
    Found in packages/optimise-sync/src/optimiseSyncServer.js - About 2 hrs to fix

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

          render() {
              const { patientProfile, match } = this.props;
              const { params } = match;
      
              let _style = scaffold_style;
      Severity: Major
      Found in packages/optimise-ui/src/components/medicalData/testDataPage.jsx - About 2 hrs to fix

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

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

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

              render() {
                  const { patientProfile, fields } = this.props;
                  const { icd11_Hash } = fields;
          
                  let _style = style;

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

                _handleSubmit(ev) {
                    ev.preventDefault();
                    if (this.state.lastSubmit && (new Date()).getTime() - this.state.lastSubmit < 500 ? true : false)
                        return;
                    const criteria = [
            Severity: Major
            Found in packages/optimise-ui/src/components/EDSScalculator/calculator.jsx - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language