dsi-icl/optimise

View on GitHub

Showing 1,390 of 1,390 total issues

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

    constructor() {
        super();
        this._dragover_handler = this._dragover_handler.bind(this);
        this._drop_handler = this._drop_handler.bind(this);
    }
packages/optimise-ui/src/components/patientProfile/patientProfile.jsx on lines 641..645

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

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

function registerValidSW(swUrl, config) {
    navigator.serviceWorker
        .register(swUrl)
        .then(registration => {
            registration.onupdatefound = () => {
Severity: Minor
Found in packages/optimise-ui/src/serviceWorker.js - About 1 hr to fix

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

        constructor(props) {
            super(props);
            this.state = {
                dispatched: false,
                aliasId: props.match ? props.match.params.patientIdCreated : '',
    Severity: Minor
    Found in packages/optimise-ui/src/components/createPatient/createPatient.jsx - About 1 hr to fix

      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 _handleSubmit has 31 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;
        

          Function _handleSubmit has 31 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 { patientId } = this.props;

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

                render() {
                    const { editing, diagnosisDate, diagnosis, diagnosisDate_original, diagnosis_original } = this.state;
                    const { data, diagnoses } = this.props;
            
                    return (

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

                  static _formatEntries({ dataTableForeignKey, entryIdString }, { body, user }) {
                      const returned = {};
                      const numOfUpdates = (body.hasOwnProperty('update')) ? Object.keys(body.update).length : 0;
                      const numOfAdds = (body.hasOwnProperty('add')) ? Object.keys(body.add).length : 0;
                      const updates = [];
              Severity: Minor
              Found in packages/optimise-core/src/controllers/dataController.js - About 1 hr to fix

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

                const createWindow = () => {
                    // Create the browser window.
                    mainWindow = new BrowserWindow({
                        toolbar: false,
                        show: false,
                Severity: Minor
                Found in packages/optimise-electron/index.js - About 1 hr to fix

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

                      static editPregnancyImage({ body, user }, res) {
                          //
                          if (body.hasOwnProperty('id') && typeof body.id === 'number') {
                  
                              const entryObj = Object.assign({}, body);
                  Severity: Minor
                  Found in packages/optimise-core/src/controllers/demographicDataController.js - About 1 hr to fix

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

                        static getPatientProfile(whereObj, deleted, getOnly) {
                            return new Promise((resolve, reject) => Patient.getPatient(whereObj, { patientId: 'id', alias: 'aliasId', optimiseConsent: 'optimiseConsent', pregnancySubStudyConsent: 'pregnancySubStudyConsent', participation: 'participation' }, deleted)
                                .then((Patientresult) => {
                                    let patientId;
                                    if (Patientresult.length === 1) {
                    Severity: Minor
                    Found in packages/optimise-core/src/core/patient.js - About 1 hr to fix

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

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

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

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

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

                                  const mappingVisitFunction = visit => {
                          
                                      // const EDSSFieldID = this.props.visitFields.filter(field => field.idname === 'edss:expanded disability status scale - estimated total')[0].id;
                                      // const EDSSRecord = visit.data.filter(record => record.field === EDSSFieldID);
                          
                          Severity: Minor
                          Found in packages/optimise-ui/src/components/patientProfile/timeline.jsx - About 1 hr to fix

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

                                render() {
                                    const { syncInfo } = this.props;
                            
                                    if (syncInfo.config === undefined || syncInfo.config.host === undefined || syncInfo.config.host === '')
                                        return null;
                            Severity: Minor
                            Found in packages/optimise-ui/src/components/scaffold/syncIndicator.jsx - About 1 hr to fix

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

                                    render() {
                                        return (
                                            <>
                                                <div className={style.ariane}>
                                                    <Helmet title='Patient Search' />
                                Severity: Minor
                                Found in packages/optimise-ui/src/components/searchPatient/searchPatient.jsx - About 1 hr to fix

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

                                  export const formatEdss = (edssList, typeTable) => {
                                      if (edssList.length === 0) {
                                          return () => [
                                              blockgen(''),
                                              blockgen(edssTitle(), [{ offset: 0, length: 11, style: 'BOLD' }]),

                                    Function _handleSubmit has 30 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;
                                    

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

                                      visit.route('/')
                                          .get(VisitController.getVisitsOfPatient)
                                          .post(VisitController.createVisit)
                                          .put(VisitController.updateVisit)
                                          .delete(VisitController.deleteVisit);
                                      Severity: Major
                                      Found in packages/optimise-core/src/routes/visitRoute.js and 2 other locations - About 1 hr to fix
                                      packages/optimise-core/src/routes/treatmentRoute.js on lines 12..16
                                      packages/optimise-core/src/routes/visitRoute.js on lines 13..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 59.

                                      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