XoopsModules25x/smallworld

View on GitHub
assets/js/jquery.countdown.js

Summary

Maintainability
F
4 days
Test Coverage

File jquery.countdown.js has 617 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* http://keith-wood.name/countdown.html
   Countdown for jQuery v1.5.10.
   Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
   Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and 
   MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses. 
Severity: Major
Found in assets/js/jquery.countdown.js - About 1 day to fix

    Function _calculatePeriods has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            _calculatePeriods: function (inst, show, significant, now) {
                // Find endpoints
                inst._now = now;
                inst._now.setMilliseconds(0);
                var until = new Date(inst._now.getTime());
    Severity: Major
    Found in assets/js/jquery.countdown.js - About 3 hrs to fix

      Function _buildLayout has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              _buildLayout: function (inst, show, layout, compact, significant, showSignificant) {
                  var labels = inst.options[compact ? 'compactLabels' : 'labels'];
                  var whichLabels = inst.options.whichLabels || this._normalLabels;
                  var labelFor = function (index) {
                      return (inst.options[(compact ? 'compactLabels' : 'labels') +
      Severity: Major
      Found in assets/js/jquery.countdown.js - About 2 hrs to fix

        Function _generateHTML has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                _generateHTML: function (inst) {
                    var self = this;
                    // Determine what to show
                    inst._periods = (inst._hold ? inst._periods :
                        this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()));
        Severity: Major
        Found in assets/js/jquery.countdown.js - About 2 hrs to fix

          Function Countdown has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function Countdown() {
                  this.regional = []; // Available regional settings, indexed by language code
                  this.regional[''] = { // Default regional settings
                      // The display texts for the counters
                      labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'],
          Severity: Major
          Found in assets/js/jquery.countdown.js - About 2 hrs to fix

            Function _determineTime has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    _determineTime: function (setting, defaultTime) {
                        var offsetNumeric = function (offset) { // e.g. +300, -2
                            var time = new Date();
                            time.setTime(time.getTime() + offset * 1000);
                            return time;
            Severity: Major
            Found in assets/js/jquery.countdown.js - About 2 hrs to fix

              Function _updateCountdown has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      _updateCountdown: function (target, inst) {
                          var $target = $(target);
                          inst = inst || $target.data(this.propertyName);
                          if (!inst) {
                              return;
              Severity: Minor
              Found in assets/js/jquery.countdown.js - About 1 hr to fix

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

                            var offsetString = function (offset) { // e.g. '+2d', '-4w', '+3h +30m'
                                offset = offset.toLowerCase();
                                var time = new Date();
                                var year = time.getFullYear();
                                var month = time.getMonth();
                Severity: Minor
                Found in assets/js/jquery.countdown.js - About 1 hr to fix

                  Function _adjustSettings has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          _adjustSettings: function (target, inst) {
                              var now;
                              var serverOffset = 0;
                              var serverEntry = null;
                              for (var i = 0; i < this._serverSyncs.length; i++) {
                  Severity: Minor
                  Found in assets/js/jquery.countdown.js - About 1 hr to fix

                    Function UTCDate has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            UTCDate: function (tz, year, month, day, hours, mins, secs, ms) {
                    Severity: Major
                    Found in assets/js/jquery.countdown.js - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                              if (!requestAnimationFrame || $.noRequestAnimationFrame) {
                                  $.noRequestAnimationFrame = null;
                                  setInterval(function () {
                                      plugin._updateTargets();
                                  }, 980); // Fall back to good old setInterval
                      Severity: Major
                      Found in assets/js/jquery.countdown.js - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                                    if (show[Y] || show[O]) {
                                        // Treat end of months as the same
                                        var lastNow = plugin._getDaysInMonth(now.getFullYear(), now.getMonth());
                                        var lastUntil = plugin._getDaysInMonth(until.getFullYear(), until.getMonth());
                                        var sameDay = (until.getDate() == now.getDate() ||
                        Severity: Major
                        Found in assets/js/jquery.countdown.js - About 1 hr to fix

                          Function _buildLayout has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  _buildLayout: function (inst, show, layout, compact, significant, showSignificant) {
                          Severity: Minor
                          Found in assets/js/jquery.countdown.js - About 45 mins to fix

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

                                                    case 'o':
                                                        month += parseInt(matches[1], 10);
                                                        day = Math.min(day, plugin._getDaysInMonth(year, month));
                                                        break;
                            Severity: Minor
                            Found in assets/js/jquery.countdown.js and 1 other location - About 35 mins to fix
                            assets/js/jquery.countdown.js on lines 473..476

                            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

                                                    case 'y':
                                                        year += parseInt(matches[1], 10);
                                                        day = Math.min(day, plugin._getDaysInMonth(year, month));
                                                        break;
                            Severity: Minor
                            Found in assets/js/jquery.countdown.js and 1 other location - About 35 mins to fix
                            assets/js/jquery.countdown.js on lines 469..472

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

                                        this._timerTargets = $.map(this._timerTargets,
                                            function (value) {
                                                return (value == target ? null : value);
                                            }); // delete entry
                            Severity: Major
                            Found in assets/js/jquery.countdown.js and 4 other locations - About 30 mins to fix
                            assets/js/jquery-ui-1.8.11.custom.js on lines 8573..8576
                            assets/js/jquery-ui-1.8.11.custom.js on lines 8598..8601
                            assets/js/jqueryui.min.js on lines 8399..8400
                            assets/js/jqueryui.min.js on lines 8427..8428

                            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