eHealthAfrica/direct-delivery-dashboard

View on GitHub
src/app/planning/schedule/schedules.service.js

Summary

Maintainability
D
2 days
Test Coverage

File schedules.service.js has 308 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict'

angular.module('planning')
  .service('scheduleService', function (dbService, log, utility, pouchUtil, $filter) {
    var _this = this
Severity: Minor
Found in src/app/planning/schedule/schedules.service.js - About 3 hrs to fix

    Function applyChanges has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        _this.applyChanges = function (dailyDeliveries, schedulesInfo) {
          function applyUpdate (dailyDelivery) {
            var rowHash
            var scheduleInfo
            if (angular.isArray(dailyDelivery.facilityRounds)) {
    Severity: Minor
    Found in src/app/planning/schedule/schedules.service.js - About 1 hr to fix

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

            function applyUpdate (dailyDelivery) {
              var rowHash
              var scheduleInfo
              if (angular.isArray(dailyDelivery.facilityRounds)) {
                dailyDelivery.facilityRounds
      Severity: Minor
      Found in src/app/planning/schedule/schedules.service.js - About 1 hr to fix

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

            _this.getAlertReceiversForRound = function (deliveryRound) {
              var stateCode = deliveryRound.roundCode && deliveryRound.roundCode.split('-')[0] || deliveryRound.id.split('-')[0]
              var view = 'dashboard-delivery-rounds/alert-receivers'
              var options = {include_docs: true, keys: ['all', stateCode]}
        
        
        Severity: Minor
        Found in src/app/planning/schedule/schedules.service.js - About 1 hr to fix

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

              _this.headerIndex = {
                uuid: {
                  text: 'UUID',
                  index: 0
                },
          Severity: Major
          Found in src/app/planning/schedule/schedules.service.js and 1 other location - About 5 hrs to fix
          src/app/planning/schedule/schedule-service.mock.js on lines 4..41

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

          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

                      .forEach(function (facRnd) {
                        rowHash = _this.hashRow(dailyDelivery.deliveryRoundID, facRnd.facility.id, dailyDelivery._id)
                        scheduleInfo = schedulesInfo[rowHash]
                        if (scheduleInfo) {
                          facRnd.drop = scheduleInfo.drop
          Severity: Major
          Found in src/app/planning/schedule/schedules.service.js and 1 other location - About 3 hrs to fix
          src/app/planning/schedule/schedules.service.js on lines 240..249

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

          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

                  } else {
                    rowHash = _this.hashRow(dailyDelivery.deliveryRoundID, dailyDelivery.facility.id, dailyDelivery._id)
                    scheduleInfo = schedulesInfo[rowHash]
                    if (scheduleInfo) {
                      dailyDelivery.drop = scheduleInfo.drop
          Severity: Major
          Found in src/app/planning/schedule/schedules.service.js and 1 other location - About 3 hrs to fix
          src/app/planning/schedule/schedules.service.js on lines 230..239

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

          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.onSaveError = function (err) {
                if (err.status === 401) {
                  return log.error('unauthorizedAccess', err)
                }
                if (err.status === 409) {
          Severity: Major
          Found in src/app/planning/schedule/schedules.service.js and 1 other location - About 2 hrs to fix
          src/app/planning/allocation/delivery-allocation.service.js on lines 38..46

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

          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