saeedsq/django-fancy-cronfield

View on GitHub
fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js

Summary

Maintainability
F
3 days
Test Coverage

File jquery-cron.js has 458 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * jQuery gentleSelect plugin (version 0.1.4.1)
 * http://shawnchin.github.com/jquery-cron
 *
 * Copyright (c) 2010-2013 Shawn Chin.
Severity: Minor
Found in fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js - About 7 hrs to fix

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

            init: function(opts) {
    
                // init options
                var options = opts ? opts : {}; /* default to empty obj */
                var o = $.extend([], defaults, options);
    Severity: Major
    Found in fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js - About 4 hrs to fix

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

              value: function(cron_str) {
                  // when no args, act as getter
                  if (!cron_str) { return getCurrentValue(this); }
      
                  var o = this.data('options');
      Severity: Minor
      Found in fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js - About 1 hr to fix

        Function getCronType has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function getCronType(cron_str, opts) {
                // if customValues defined, check for matches there first
                if (defined(opts.customValues)) {
                    for (key in opts.customValues) {
                        if (cron_str === opts.customValues[key]) { return key; }
        Severity: Minor
        Found in fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js - About 1 hr to fix

          Function getCurrentValue has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function getCurrentValue(c) {
                  var b = c.data('block');
                  var min = '*', hour = '*', day = '*', month = '*', dow = '*';
                  var selectedPeriod = b['period'].find('select').val();
                  switch (selectedPeriod) {
          Severity: Minor
          Found in fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js - About 1 hr to fix

            Avoid too many return statements within this function.
            Open

                    return undefined;
            Severity: Major
            Found in fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js - About 30 mins to fix

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

                  $.fn.cron = function(method) {
                      if (methods[method]) {
                          return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
                      } else if (typeof method === 'object' || ! method) {
                          return methods.init.apply(this, arguments);
              Severity: Major
              Found in fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js and 1 other location - About 4 hrs to fix
              fancy_cronfield/static/fancy_cronfield/js/jquery-gentleSelect.js on lines 293..301

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

              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 'month':
                              min = b['time'].find('select.cron-time-min').val();
                              hour = b['time'].find('select.cron-time-hour').val();
                              day = b['dom'].find('select').val();
                              break;
              Severity: Major
              Found in fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js and 1 other location - About 2 hrs to fix
              fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js on lines 298..302

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

              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 'week':
                              min = b['time'].find('select.cron-time-min').val();
                              hour = b['time'].find('select.cron-time-hour').val();
                              dow = b['dow'].find('select').val();
                              break;
              Severity: Major
              Found in fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js and 1 other location - About 2 hrs to fix
              fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js on lines 304..308

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

              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 (i = 0; i < 24; i++) {
                      j = (i < 10) ? '0' : '';
                      str_opt_hid += "<option value='" + i + "'>" + j + i + '</option>\n';
                  }
              Severity: Minor
              Found in fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js and 1 other location - About 40 mins to fix
              fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js on lines 110..113

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

              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 < 60; i++) {
                      j = (i < 10) ? '0' : '';
                      str_opt_mih += "<option value='" + i + "'>" + j + i + '</option>\n';
                  }
              Severity: Minor
              Found in fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js and 1 other location - About 40 mins to fix
              fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js on lines 117..120

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

              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