myems-admin/js/plugins/clockpicker/clockpicker.js

Summary

Maintainability
F
4 days
Test Coverage

File clockpicker.js has 554 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * ClockPicker v0.0.7 (http://weareoutman.github.io/clockpicker/)
 * Copyright 2014 Wang Shenwei.
 * Licensed under MIT (https://github.com/weareoutman/clockpicker/blob/gh-pages/LICENSE)
 */
Severity: Major
Found in myems-admin/js/plugins/clockpicker/clockpicker.js - About 1 day to fix

    Function ClockPicker has 203 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function ClockPicker(element, options) {
            var popover = $(tpl),
                plate = popover.find('.clockpicker-plate'),
                hoursView = popover.find('.clockpicker-hours'),
                minutesView = popover.find('.clockpicker-minutes'),
    Severity: Major
    Found in myems-admin/js/plugins/clockpicker/clockpicker.js - About 1 day to fix

      Function setHand has 80 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          ClockPicker.prototype.setHand = function(x, y, roundBy5, dragging){
              var radian = Math.atan2(x, - y),
                  isHours = this.currentView === 'hours',
                  unit = Math.PI / (isHours || roundBy5 ? 6 : 30),
                  z = Math.sqrt(x * x + y * y),
      Severity: Major
      Found in myems-admin/js/plugins/clockpicker/clockpicker.js - About 3 hrs to fix

        Function mousedown has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                function mousedown(e, space) {
                    var offset = plate.offset(),
                        isTouch = /^touch/.test(e.type),
                        x0 = offset.left + dialRadius,
                        y0 = offset.top + dialRadius,
        Severity: Major
        Found in myems-admin/js/plugins/clockpicker/clockpicker.js - About 2 hrs to fix

          Function show has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              ClockPicker.prototype.show = function(e){
                  // Not show again
                  if (this.isShown) {
                      return;
                  }
          Severity: Minor
          Found in myems-admin/js/plugins/clockpicker/clockpicker.js - About 1 hr to fix

            Function locate has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                ClockPicker.prototype.locate = function(){
                    var element = this.element,
                        popover = this.popover,
                        offset = element.offset(),
                        width = element.outerWidth(),
            Severity: Minor
            Found in myems-admin/js/plugins/clockpicker/clockpicker.js - About 1 hr to fix

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

                              var isTouch = /^touch/.test(e.type),
                                  x = (isTouch ? e.originalEvent.changedTouches[0] : e).pageX - x0,
                                  y = (isTouch ? e.originalEvent.changedTouches[0] : e).pageY - y0;
              Severity: Major
              Found in myems-admin/js/plugins/clockpicker/clockpicker.js and 1 other location - About 2 hrs to fix
              myems-admin/js/plugins/clockpicker/clockpicker.js on lines 275..277

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

              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 isTouch = /^touch/.test(e.type),
                                  x = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
                                  y = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0;
              Severity: Major
              Found in myems-admin/js/plugins/clockpicker/clockpicker.js and 1 other location - About 2 hrs to fix
              myems-admin/js/plugins/clockpicker/clockpicker.js on lines 290..292

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

              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

                          $('<button type="button" class="btn btn-sm btn-default clockpicker-button am-button">' + "AM" + '</button>')
                              .on("click", function() {
                                  self.amOrPm = "AM";
                                  $('.clockpicker-span-am-pm').empty().append('AM');
                              }).appendTo(this.amPmBlock);
              Severity: Major
              Found in myems-admin/js/plugins/clockpicker/clockpicker.js and 1 other location - About 1 hr to fix
              myems-admin/js/plugins/clockpicker/clockpicker.js on lines 154..158

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

              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

                          $('<button type="button" class="btn btn-sm btn-default clockpicker-button pm-button">' + "PM" + '</button>')
                              .on("click", function() {
                                  self.amOrPm = 'PM';
                                  $('.clockpicker-span-am-pm').empty().append('PM');
                              }).appendTo(this.amPmBlock);
              Severity: Major
              Found in myems-admin/js/plugins/clockpicker/clockpicker.js and 1 other location - About 1 hr to fix
              myems-admin/js/plugins/clockpicker/clockpicker.js on lines 147..151

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

              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

                          tick.css({
                              left: dialRadius + Math.sin(radian) * outerRadius - tickRadius,
                              top: dialRadius - Math.cos(radian) * outerRadius - tickRadius
                          });
              Severity: Major
              Found in myems-admin/js/plugins/clockpicker/clockpicker.js and 2 other locations - About 1 hr to fix
              myems-admin/js/plugins/clockpicker/clockpicker.js on lines 194..197
              myems-admin/js/plugins/clockpicker/clockpicker.js on lines 208..211

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

              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

                              tick.css({
                                  left: dialRadius + Math.sin(radian) * radius - tickRadius,
                                  top: dialRadius - Math.cos(radian) * radius - tickRadius
                              });
              Severity: Major
              Found in myems-admin/js/plugins/clockpicker/clockpicker.js and 2 other locations - About 1 hr to fix
              myems-admin/js/plugins/clockpicker/clockpicker.js on lines 208..211
              myems-admin/js/plugins/clockpicker/clockpicker.js on lines 225..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 62.

              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

                              tick.css({
                                  left: dialRadius + Math.sin(radian) * radius - tickRadius,
                                  top: dialRadius - Math.cos(radian) * radius - tickRadius
                              });
              Severity: Major
              Found in myems-admin/js/plugins/clockpicker/clockpicker.js and 2 other locations - About 1 hr to fix
              myems-admin/js/plugins/clockpicker/clockpicker.js on lines 194..197
              myems-admin/js/plugins/clockpicker/clockpicker.js on lines 225..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 62.

              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 ((options.placement === 'top' || options.placement === 'bottom') && (options.align === 'top' || options.align === 'bottom')) options.align = 'left';
              Severity: Minor
              Found in myems-admin/js/plugins/clockpicker/clockpicker.js and 1 other location - About 35 mins to fix
              myems-admin/js/plugins/clockpicker/clockpicker.js on lines 171..171

              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 ((options.placement === 'left' || options.placement === 'right') && (options.align === 'left' || options.align === 'right')) options.align = 'top';
              Severity: Minor
              Found in myems-admin/js/plugins/clockpicker/clockpicker.js and 1 other location - About 35 mins to fix
              myems-admin/js/plugins/clockpicker/clockpicker.js on lines 170..170

              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

              There are no issues that match your filters.

              Category
              Status