fossasia/loklak_webclient

View on GitHub
app/js/components/datetimepicker.js

Summary

Maintainability
F
6 days
Test Coverage

Function datetimepickerDirective has 297 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    .directive('datetimepicker', ['$log', 'dateTimePickerConfig', function datetimepickerDirective($log, defaultConfig) {

      function DateObject() {

        var tempDate = new Date();
Severity: Major
Found in app/js/components/datetimepicker.js - About 1 day to fix

    Function link has 209 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            link: function link(scope, element, attrs, ngModelController) {
    
              var directiveConfig = {};
    
              if (attrs.datetimepickerConfig) {
    Severity: Major
    Found in app/js/components/datetimepicker.js - About 1 day to fix

      File datetimepicker.js has 317 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*globals define, jQuery, module, require */
      /*jslint vars:true */
      
      /**
       * @license angular-bootstrap-datetimepicker  version: 0.3.12
      Severity: Minor
      Found in app/js/components/datetimepicker.js - About 3 hrs to fix

        Function day has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    day: function day(unixDate) {
        
                      var selectedDate = moment.utc(unixDate);
                      var startOfMonth = moment.utc(selectedDate).startOf('month');
                      var previousViewDate = moment.utc(selectedDate).startOf('year');
        Severity: Minor
        Found in app/js/components/datetimepicker.js - About 1 hr to fix

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

                var validateConfiguration = function validateConfiguration(configuration) {
                  var validOptions = ['startView', 'minView', 'minuteStep', 'dropdownSelector'];
          
                  for (var prop in configuration) {
                    //noinspection JSUnfilteredForInLoop
          Severity: Minor
          Found in app/js/components/datetimepicker.js - About 1 hr to fix

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

                        year: function year(unixDate) {
                          var selectedDate = moment.utc(unixDate).startOf('year');
                          // View starts one year before the decade starts and ends one year after the decade ends
                          // i.e. passing in a date of 1/1/2013 will give a range of 2009 to 2020
                          // Truncate the last digit from the current year and subtract 1 to get the start of the decade
            Severity: Minor
            Found in app/js/components/datetimepicker.js - About 1 hr to fix

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

                          minute: function minute(unixDate) {
                            var selectedDate = moment.utc(unixDate).startOf('hour');
                            var previousViewDate = moment.utc(selectedDate).startOf('day');
                            var activeFormat = ngModelController.$modelValue ? moment(ngModelController.$modelValue).format('YYYY-MM-DD H:mm') : '';
              
              
              Severity: Minor
              Found in app/js/components/datetimepicker.js - About 1 hr to fix

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

                              var result = {
                                'previousView': 'day',
                                'currentView': 'hour',
                                'nextView': configuration.minView === 'hour' ? 'setTime' : 'minute',
                                'previousViewDate': new DateObject({
                Severity: Major
                Found in app/js/components/datetimepicker.js and 1 other location - About 6 hrs to fix
                app/js/components/datetimepicker.js on lines 206..217

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

                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

                              var result = {
                                'previousView': 'year',
                                'currentView': 'month',
                                'nextView': configuration.minView === 'month' ? 'setTime' : 'day',
                                'previousViewDate': new DateObject({
                Severity: Major
                Found in app/js/components/datetimepicker.js and 1 other location - About 6 hrs to fix
                app/js/components/datetimepicker.js on lines 288..299

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

                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

                              for (var i = 0; i < 12; i += 1) {
                                var monthMoment = moment.utc(startDate).add(i, 'months');
                                var dateValue = {
                                  'utcDateValue': monthMoment.valueOf(),
                                  'display': monthMoment.format('MMM'),
                Severity: Major
                Found in app/js/components/datetimepicker.js and 1 other location - About 4 hrs to fix
                app/js/components/datetimepicker.js on lines 301..310

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

                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

                              for (var i = 0; i < 24; i += 1) {
                                var hourMoment = moment.utc(selectedDate).add(i, 'hours');
                                var dateValue = {
                                  'utcDateValue': hourMoment.valueOf(),
                                  'display': hourMoment.format('LT'),
                Severity: Major
                Found in app/js/components/datetimepicker.js and 1 other location - About 4 hrs to fix
                app/js/components/datetimepicker.js on lines 219..228

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

                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