eHealthAfrica/LMIS-Chrome

View on GitHub
app/scripts/controllers/bundle.js

Summary

Maintainability
F
3 days
Test Coverage

File bundle.js has 496 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

angular.module('lmisChromeApp')
  .config(function($stateProvider) {
    $stateProvider
Severity: Minor
Found in app/scripts/controllers/bundle.js - About 7 hrs to fix

    Function finalSave has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        $scope.finalSave = function() {
          var bundle = angular.copy($scope.bundle);
          $scope.isSaving = true;
          var successMsg = '';
          if ($stateParams.type === logIncoming) {
    Severity: Minor
    Found in app/scripts/controllers/bundle.js - About 1 hr to fix

      Function validateBundle has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function validateBundle(bundleLine){
      
            var indicator = 0;
      
            $scope.bundle.bundleLines.filter(function(bundleLine){
      Severity: Minor
      Found in app/scripts/controllers/bundle.js - About 1 hr to fix

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

              if ($stateParams.type === logIncoming) {
                $scope.logBundleTitle = i18n('IncomingDelivery');
                $scope.facilityHeader = i18n('receivedFrom');
                $scope.previewFacilityLabel = i18n('receivedFrom');
                $scope.selectFacility = i18n('selectSender');
        Severity: Major
        Found in app/scripts/controllers/bundle.js and 1 other location - About 2 hrs to fix
        app/scripts/controllers/bundle.js on lines 69..78

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

        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 if ($stateParams.type === logOutgoing) {
                $scope.logBundleTitle = i18n('OutgoingDelivery');
                $scope.facilityHeader = i18n('sentTo');
                $scope.selectFacility = i18n('selectReceiver');
                $scope.previewFacilityLabel = i18n('sentTo');
        Severity: Major
        Found in app/scripts/controllers/bundle.js and 1 other location - About 2 hrs to fix
        app/scripts/controllers/bundle.js on lines 62..78

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

        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 ($stateParams.type === logIncoming) {
                $scope.logBundleTitle = [i18n('IncomingDelivery'), '-', today].join(' ');
                $scope.selectFacility = i18n('selectSender');
                $scope.previewFacilityLabel = i18n('receivedFrom');
                $scope.LGALabel = i18n('selectSendingLga');
        Severity: Major
        Found in app/scripts/controllers/bundle.js and 1 other location - About 2 hrs to fix
        app/scripts/controllers/bundle.js on lines 303..311

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

        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 if ($stateParams.type === logOutgoing) {
                $scope.logBundleTitle = [i18n('OutgoingDelivery'), '-', today].join(' ');
                $scope.selectFacility = i18n('selectReceiver');
                $scope.previewFacilityLabel = i18n('sendTo');
                $scope.LGALabel = i18n('selectReceivingLga');
        Severity: Major
        Found in app/scripts/controllers/bundle.js and 1 other location - About 2 hrs to fix
        app/scripts/controllers/bundle.js on lines 297..311

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

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

            $scope.removeLine = function(bundleLine) {
              $scope.bundle.bundleLines = $scope.bundle.bundleLines.filter(function(line) {
                return line.id !== bundleLine.id;
              });
            };
        Severity: Major
        Found in app/scripts/controllers/bundle.js and 2 other locations - About 1 hr to fix
        app/scripts/controllers/inventory.js on lines 164..168
        app/scripts/controllers/orders.js on lines 67..71

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

        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

              for (var i in bundle.bundleLines) {
                var ppUuid = bundle.bundleLines[i].productProfile;
                bundle.bundleLines[i].productProfile = productProfileFactory.get(ppUuid);
              }
        Severity: Major
        Found in app/scripts/controllers/bundle.js and 1 other location - About 1 hr to fix
        app/scripts/controllers/bundle.js on lines 386..389

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

        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

              for (var i in bundle.bundleLines) {
                var ppUuid = bundle.bundleLines[i].productProfile;
                bundle.bundleLines[i].productProfile = productProfileFactory.get(ppUuid);
              }
        Severity: Major
        Found in app/scripts/controllers/bundle.js and 1 other location - About 1 hr to fix
        app/scripts/controllers/bundle.js on lines 154..157

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

        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

            if ($stateParams.type !== logIncoming && $stateParams.type !== logOutgoing) {
              $state.go('home.index.home.mainActivity');
              growl.error(i18n('specifyBundleType'));
              return;
            }
        Severity: Minor
        Found in app/scripts/controllers/bundle.js and 1 other location - About 55 mins to fix
        app/scripts/controllers/bundle.js on lines 285..289

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

        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

            if ($stateParams.type !== logIncoming && $stateParams.type !== logOutgoing) {
              $state.go('home.index.home.mainActivity');
              growl.error(i18n('specifyBundleType'));
              return;
            }
        Severity: Minor
        Found in app/scripts/controllers/bundle.js and 1 other location - About 55 mins to fix
        app/scripts/controllers/bundle.js on lines 55..59

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

        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 if ($stateParams.type === logOutgoing) {
                $scope.bundle.receivingFacility = JSON.parse(selectedFacility);
                $scope.bundle.sendingFacility = appConfig.facility;
              } else {
                growl.error(i18n('unknownBundleType'));
        Severity: Minor
        Found in app/scripts/controllers/bundle.js and 1 other location - About 35 mins to fix
        app/scripts/controllers/bundle.js on lines 411..419

        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

              if ($stateParams.type === logIncoming) {
                $scope.bundle.sendingFacility = JSON.parse(selectedFacility);
                $scope.bundle.receivingFacility = appConfig.facility;
              } else if ($stateParams.type === logOutgoing) {
                $scope.bundle.receivingFacility = JSON.parse(selectedFacility);
        Severity: Minor
        Found in app/scripts/controllers/bundle.js and 1 other location - About 35 mins to fix
        app/scripts/controllers/bundle.js on lines 414..419

        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

                if(bundleLine.productProfile === ''){
                  indicator = 1;
                  $scope.err[bundleLine.id].pp = true;
                }
        Severity: Minor
        Found in app/scripts/controllers/bundle.js and 1 other location - About 30 mins to fix
        app/scripts/controllers/bundle.js on lines 510..513

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

        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(bundleLine.batchNo === ''){
                  indicator = 1;
                  $scope.err[bundleLine.id].batchNo = true;
                }
        Severity: Minor
        Found in app/scripts/controllers/bundle.js and 1 other location - About 30 mins to fix
        app/scripts/controllers/bundle.js on lines 506..509

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

        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