RLOpenCatalyst/core

View on GitHub
client/cat3/customlib/datetime.js

Summary

Maintainability
F
6 days
Test Coverage

File datetime.js has 776 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// https://github.com/Gillardo/bootstrap-ui-datetime-picker
// Version: 2.4.0
// Released: 2016-06-03
angular.module('ui.bootstrap.datetimepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.position'])
    .constant('uiDatetimePickerConfig', {
Severity: Major
Found in client/cat3/customlib/datetime.js - About 1 day to fix

    Function init has 148 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                this.init = function(_ngModel) {
                    ngModel = _ngModel;
                    ngModelOptions = ngModel.$options || uiDatetimePickerConfig.ngModelOptions;
    
                    $scope.buttonBar = angular.isDefined($attrs.buttonBar) ? $scope.$parent.$eval($attrs.buttonBar) : uiDatetimePickerConfig.buttonBar;
    Severity: Major
    Found in client/cat3/customlib/datetime.js - About 5 hrs to fix

      Consider simplifying this complex logical expression.
      Open

                  if (placement[2]) {
                      var viewportOffset = this.viewportOffset(hostElem);
      
                      var targetElemStyle = $window.getComputedStyle(targetElem);
                      var adjustedSize = {
      Severity: Critical
      Found in client/cat3/customlib/datetime.js - About 4 hrs to fix

        Function positionElements has 81 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                positionElements: function(hostElem, targetElem, placement, appendToBody) {
                    hostElem = this.getRawNode(hostElem);
                    targetElem = this.getRawNode(targetElem);
        
                    // need to read from prop to support tests.
        Severity: Major
        Found in client/cat3/customlib/datetime.js - About 3 hrs to fix

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

                  positionArrow: function(elem, placement) {
                      elem = this.getRawNode(elem);
          
                      var innerElem = elem.querySelector('.tooltip-inner, .popover-inner');
                      if (!innerElem) {
          Severity: Minor
          Found in client/cat3/customlib/datetime.js - About 1 hr to fix

            Function dateSelection has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                        $scope.dateSelection = function (dt, opt) {
            
                            // check if timePicker is being shown and merge dates, so that the date
                            // part is never changed, only the time
                            if ($scope.enableTime && $scope.showPicker === 'time') {
            Severity: Minor
            Found in client/cat3/customlib/datetime.js - About 1 hr to fix

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

                      viewportOffset: function(elem, useDocument, includePadding) {
                          elem = this.getRawNode(elem);
                          includePadding = includePadding !== false ? true : false;
              
                          var elemBCR = elem.getBoundingClientRect();
              Severity: Minor
              Found in client/cat3/customlib/datetime.js - About 1 hr to fix

                Avoid too many return statements within this function.
                Open

                                    return !isNaN(parseDateString(viewValue)) && validateMinMax(parseDateString(viewVialue));
                Severity: Major
                Found in client/cat3/customlib/datetime.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                          return uibDateParser.fromTimezone(value, ngModelOptions.timezone).toLocaleString();
                  Severity: Major
                  Found in client/cat3/customlib/datetime.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                            return uibDateParser.filter(uibDateParser.fromTimezone(value, ngModelOptions.timezone), dateFormat);
                    Severity: Major
                    Found in client/cat3/customlib/datetime.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                          return false;
                      Severity: Major
                      Found in client/cat3/customlib/datetime.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                            return undefined;
                        Severity: Major
                        Found in client/cat3/customlib/datetime.js - About 30 mins to fix

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

                                                  if (viewportOffset.left + xOverflow < 0 && adjustedSize.width - hostElemPos.width <= viewportOffset.right) {
                                                      placement[1] = 'left';
                                                  } else if (viewportOffset.right + xOverflow < 0 && adjustedSize.width - hostElemPos.width <= viewportOffset.left) {
                                                      placement[1] = 'right';
                                                  }
                          Severity: Major
                          Found in client/cat3/customlib/datetime.js and 1 other location - About 3 hrs to fix
                          client/cat3/customlib/datetime.js on lines 485..489

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

                          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 (viewportOffset.top + yOverflow < 0 && adjustedSize.height - hostElemPos.height <= viewportOffset.bottom) {
                                                      placement[1] = 'top';
                                                  } else if (viewportOffset.bottom + yOverflow < 0 && adjustedSize.height - hostElemPos.height <= viewportOffset.top) {
                                                      placement[1] = 'bottom';
                                                  }
                          Severity: Major
                          Found in client/cat3/customlib/datetime.js and 1 other location - About 3 hrs to fix
                          client/cat3/customlib/datetime.js on lines 478..482

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

                          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

                                                  placement[1] === 'left' && adjustedSize.width - hostElemPos.width > viewportOffset.right && adjustedSize.width - hostElemPos.width <= viewportOffset.left ? 'right' :
                                                      placement[1] === 'right' && adjustedSize.width - hostElemPos.width > viewportOffset.left && adjustedSize.width - hostElemPos.width <= viewportOffset.right ? 'left' :
                                                          placement[1];
                          Severity: Major
                          Found in client/cat3/customlib/datetime.js and 3 other locations - About 1 hr to fix
                          client/cat3/customlib/datetime.js on lines 469..473
                          client/cat3/customlib/datetime.js on lines 470..473
                          client/cat3/customlib/datetime.js on lines 472..473

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

                          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

                                              placement[1] === 'bottom' && adjustedSize.height - hostElemPos.height > viewportOffset.top && adjustedSize.height - hostElemPos.height <= viewportOffset.bottom ? 'top' :
                                                  placement[1] === 'left' && adjustedSize.width - hostElemPos.width > viewportOffset.right && adjustedSize.width - hostElemPos.width <= viewportOffset.left ? 'right' :
                                                      placement[1] === 'right' && adjustedSize.width - hostElemPos.width > viewportOffset.left && adjustedSize.width - hostElemPos.width <= viewportOffset.right ? 'left' :
                                                          placement[1];
                          Severity: Major
                          Found in client/cat3/customlib/datetime.js and 3 other locations - About 1 hr to fix
                          client/cat3/customlib/datetime.js on lines 469..473
                          client/cat3/customlib/datetime.js on lines 471..473
                          client/cat3/customlib/datetime.js on lines 472..473

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

                          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

                                          placement[1] = placement[1] === 'top' && adjustedSize.height - hostElemPos.height > viewportOffset.bottom && adjustedSize.height - hostElemPos.height <= viewportOffset.top ? 'bottom' :
                                              placement[1] === 'bottom' && adjustedSize.height - hostElemPos.height > viewportOffset.top && adjustedSize.height - hostElemPos.height <= viewportOffset.bottom ? 'top' :
                                                  placement[1] === 'left' && adjustedSize.width - hostElemPos.width > viewportOffset.right && adjustedSize.width - hostElemPos.width <= viewportOffset.left ? 'right' :
                                                      placement[1] === 'right' && adjustedSize.width - hostElemPos.width > viewportOffset.left && adjustedSize.width - hostElemPos.width <= viewportOffset.right ? 'left' :
                                                          placement[1];
                          Severity: Major
                          Found in client/cat3/customlib/datetime.js and 3 other locations - About 1 hr to fix
                          client/cat3/customlib/datetime.js on lines 470..473
                          client/cat3/customlib/datetime.js on lines 471..473
                          client/cat3/customlib/datetime.js on lines 472..473

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

                          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

                                                      placement[1] === 'right' && adjustedSize.width - hostElemPos.width > viewportOffset.left && adjustedSize.width - hostElemPos.width <= viewportOffset.right ? 'left' :
                                                          placement[1];
                          Severity: Major
                          Found in client/cat3/customlib/datetime.js and 3 other locations - About 1 hr to fix
                          client/cat3/customlib/datetime.js on lines 469..473
                          client/cat3/customlib/datetime.js on lines 470..473
                          client/cat3/customlib/datetime.js on lines 471..473

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

                          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

                                              height: targetHeight + Math.round(Math.abs(this.parseStyle(targetElemStyle.marginTop) + this.parseStyle(targetElemStyle.marginBottom)))
                          Severity: Minor
                          Found in client/cat3/customlib/datetime.js and 1 other location - About 55 mins to fix
                          client/cat3/customlib/datetime.js on lines 459..459

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

                          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

                                              width: targetWidth + Math.round(Math.abs(this.parseStyle(targetElemStyle.marginLeft) + this.parseStyle(targetElemStyle.marginRight))),
                          Severity: Minor
                          Found in client/cat3/customlib/datetime.js and 1 other location - About 55 mins to fix
                          client/cat3/customlib/datetime.js on lines 460..460

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

                          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