mangroveorg/datawinners

View on GitHub
datawinners/media/javascript/project/poll_options.js

Summary

Maintainability
F
1 wk
Test Coverage

Function PollOptionsViewModel has 173 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var PollOptionsViewModel = function() {
    var self = this;
    var start_date = new Date();
    var end_date;
    var END_TIME = "T23:59:00";
Severity: Major
Found in datawinners/media/javascript/project/poll_options.js - About 6 hrs to fix

    Function edit_poll has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        self.edit_poll = function() {
            data = {
                'end_date': self.endDate().getFullYear() + "-" + (self.endDate().getMonth()+1) + "-" + self.endDate().getDate() + END_TIME
            };
            $.blockUI({ message: '<h1><img src="/media/images/ajax-loader.gif"/><span class="loading">' + gettext("Just a moment") + '...</span></h1>', css: { width: '275px'}});
    Severity: Minor
    Found in datawinners/media/javascript/project/poll_options.js - About 1 hr to fix

      Function activate_poll has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          self.activate_poll = function() {
              data = {
                  'end_date': self.endDate().getFullYear() + "-" + (self.endDate().getMonth()+1) + "-" + self.endDate().getDate() + END_TIME
              };
              $.blockUI({ message: '<h1><img src="/media/images/ajax-loader.gif"/><span class="loading">' + gettext("Just a moment") + '...</span></h1>', css: { width: '275px'}});
      Severity: Minor
      Found in datawinners/media/javascript/project/poll_options.js - About 1 hr to fix

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

            self.activate_poll = function() {
                data = {
                    'end_date': self.endDate().getFullYear() + "-" + (self.endDate().getMonth()+1) + "-" + self.endDate().getDate() + END_TIME
                };
                $.blockUI({ message: '<h1><img src="/media/images/ajax-loader.gif"/><span class="loading">' + gettext("Just a moment") + '...</span></h1>', css: { width: '275px'}});
        Severity: Major
        Found in datawinners/media/javascript/project/poll_options.js and 1 other location - About 3 days to fix
        datawinners/media/javascript/project/poll_options.js on lines 166..196

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

        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

            self.edit_poll = function() {
                data = {
                    'end_date': self.endDate().getFullYear() + "-" + (self.endDate().getMonth()+1) + "-" + self.endDate().getDate() + END_TIME
                };
                $.blockUI({ message: '<h1><img src="/media/images/ajax-loader.gif"/><span class="loading">' + gettext("Just a moment") + '...</span></h1>', css: { width: '275px'}});
        Severity: Major
        Found in datawinners/media/javascript/project/poll_options.js and 1 other location - About 3 days to fix
        datawinners/media/javascript/project/poll_options.js on lines 135..165

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

        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

            window.smsViewModel.smsOptionList = ko.observableArray([
                                        {"label":gettext('Select Recipients'), disable: ko.observable(true)},
                                        {"label":gettext('My Poll Recipients'), "code": "poll_recipients"},
                                        {"label":gettext('Group'), "code": "group"},
                                        {"label":gettext('Contacts linked to a Questionnaire'), "code": "linked"}
        Severity: Major
        Found in datawinners/media/javascript/project/poll_options.js and 1 other location - About 2 hrs to fix
        datawinners/media/javascript/entity/send_sms.js on lines 147..150

        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

        There are no issues that match your filters.

        Category
        Status