saeedsq/django-fancy-cronfield

View on GitHub

Showing 31 of 31 total issues

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

    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

        $.fn.gentleSelect = 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);
    fancy_cronfield/static/fancy_cronfield/js/jquery-cron.js on lines 592..600

    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

    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 init has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              init: function(options) {
                  var o = $.extend({}, defaults, options);
      
                  if (hasError(this, o)) { return this; } // check for errors
                  optionOverrides(this, o); //
      Severity: Major
      Found in fancy_cronfield/static/fancy_cronfield/js/jquery-gentleSelect.js - About 2 hrs to fix

        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

                if (!defined(o.openSpeed) || typeof o.openSpeed !== 'number' &&
                        (typeof o.openSpeed === 'string' && (o.openSpeed !== 'slow' && o.openSpeed !== 'fast'))) {
                    $.error('gentleSelect: openSpeed must be an integer or \"slow\" or \"fast\"');
                    return true;
                }
        fancy_cronfield/static/fancy_cronfield/js/jquery-gentleSelect.js on lines 62..66

        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

                if (!defined(o.closeSpeed) || typeof o.closeSpeed !== 'number' &&
                        (typeof o.closeSpeed === 'string' && (o.closeSpeed !== 'slow' && o.closeSpeed !== 'fast'))) {
                    $.error('gentleSelect: closeSpeed must be an integer or \"slow\" or \"fast\"');
                    return true;
                }
        fancy_cronfield/static/fancy_cronfield/js/jquery-gentleSelect.js on lines 57..61

        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

        Cyclomatic complexity is too high in method __init__. (6)
        Open

            def __init__(self, attrs=None, options=None):
                options = options or {}
                self.options = {
                    'use_gentle_select': True,
                    'allow_multiple_all': False,
        Severity: Minor
        Found in fancy_cronfield/widgets.py by radon

        Cyclomatic Complexity

        Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

        Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

        Construct Effect on CC Reasoning
        if +1 An if statement is a single decision.
        elif +1 The elif statement adds another decision.
        else +0 The else statement does not cause a new decision. The decision is at the if.
        for +1 There is a decision at the start of the loop.
        while +1 There is a decision at the while statement.
        except +1 Each except branch adds a new conditional path of execution.
        finally +0 The finally block is unconditionally executed.
        with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
        assert +1 The assert statement internally roughly equals a conditional statement.
        Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
        Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

        Source: http://radon.readthedocs.org/en/latest/intro.html

        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 hasError has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function hasError(c, o) {
                    if (defined(o.columns) && defined(o.rows)) {
                        $.error("gentleSelect: You cannot supply both 'rows' and 'columns'");
                        return true;
                    }
            Severity: Minor
            Found in fancy_cronfield/static/fancy_cronfield/js/jquery-gentleSelect.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

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

                    $.fn.cron_field = function(options) {
                        var cron_id = this.attr('id') + '-cron';
                        if ($('#' + cron_id).exists()) {
                            if (window.cron_objs[cron_id] !== undefined) {
                                return window.cron_objs[cron_id];
                Severity: Minor
                Found in fancy_cronfield/static/fancy_cronfield/js/cronfield.js - About 1 hr to fix

                  Function dialogClick has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          dialogClick: function(e) {
                              var clicked = $(e.target);
                              var $this = $(this);
                              var root = $this.data('root');
                              var opts = root.data('options');
                  Severity: Minor
                  Found in fancy_cronfield/static/fancy_cronfield/js/jquery-gentleSelect.js - About 1 hr to fix

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

                            if (!defined(o.openEffect) || (o.openEffect !== 'fade' && o.openEffect !== 'slide')) {
                                $.error("gentleSelect: openEffect must be either 'fade' or 'slide'!");
                                return true;
                            }
                    fancy_cronfield/static/fancy_cronfield/js/jquery-gentleSelect.js on lines 71..74

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

                    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 (!defined(o.closeEffect) || (o.closeEffect !== 'fade' && o.closeEffect !== 'slide')) {
                                $.error("gentleSelect: closeEffect must be either 'fade' or 'slide'!");
                                return true;
                            }
                    fancy_cronfield/static/fancy_cronfield/js/jquery-gentleSelect.js on lines 67..70

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

                    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

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

                        def check_html(self, widget, name, value, html='', attrs=None, **kwargs):
                    Severity: Minor
                    Found in fancy_cronfield/tests/test_widgets.py - About 45 mins to fix

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

                                  if (opts.openEffect === 'fade') {
                                      dialog.fadeIn(opts.openSpeed);
                                  } else {
                                      dialog.slideDown(opts.openSpeed);
                                  }
                      fancy_cronfield/static/fancy_cronfield/js/jquery-gentleSelect.js on lines 257..261

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language