gopheracademy/gcon

View on GitHub
assets/admin/global/plugins/countdown/plugin/jquery.countdown.js

Summary

Maintainability
F
2 mos
Test Coverage

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

/* http://keith-wood.name/countdown.html
   Countdown for jQuery v1.6.3.
   Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
   Available under the MIT (https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt) license. 
   Please attribute the author if you use it. */
Severity: Major
Found in assets/admin/global/plugins/countdown/plugin/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/admin/global/plugins/countdown/plugin/jquery.countdown.js - About 3 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/admin/global/plugins/countdown/plugin/jquery.countdown.js - About 2 hrs to fix

        Function _buildLayout has 57 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/admin/global/plugins/countdown/plugin/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/admin/global/plugins/countdown/plugin/jquery.countdown.js - About 2 hrs to fix

            Function _determineTime has 41 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: Minor
            Found in assets/admin/global/plugins/countdown/plugin/jquery.countdown.js - About 1 hr 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/admin/global/plugins/countdown/plugin/jquery.countdown.js - About 1 hr to fix

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

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

                  Function offsetString has 29 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/admin/global/plugins/countdown/plugin/jquery.countdown.js - About 1 hr to fix

                    Function _optionPlugin has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        _optionPlugin: function(target, options, value) {
                            target = $(target);
                            var inst = target.data(this.propertyName);
                            if (!options || (typeof options == 'string' && value == null)) { // Get option
                                var name = options;
                    Severity: Minor
                    Found in assets/admin/global/plugins/countdown/plugin/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/admin/global/plugins/countdown/plugin/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
                            }
                            else {
                        Severity: Major
                        Found in assets/admin/global/plugins/countdown/plugin/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/admin/global/plugins/countdown/plugin/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/admin/global/plugins/countdown/plugin/jquery.countdown.js - About 45 mins to fix

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

                              (function($) { // Hide scope, no $ conflict
                              
                              /* Countdown manager. */
                              function Countdown() {
                                  this.regional = []; // Available regional settings, indexed by language code
                              assets/admin/global/plugins/countdown/jquery.countdown.js on lines 12..810

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

                              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