qomoteam/qomo

View on GitHub
app/assets/javascripts/rails.validations.js

Summary

Maintainability
F
4 days
Test Coverage

File rails.validations.js has 634 lines of code (exceeds 250 allowed). Consider refactoring.
Open


/*!
 * Client Side Validations - v5.0.0 (https://github.com/DavyJonesLocker/client_side_validations)
 * Copyright (c) 2016 Geremia Taglialatela, Brian Cardarella
 * Licensed under MIT (http://opensource.org/licenses/mit-license.php)
Severity: Major
Found in app/assets/javascripts/rails.validations.js - About 1 day to fix

    Function input has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        input: function(input) {
          var $form, $input, binding, event, form, ref;
          $input = $(input);
          form = input.form;
          $form = $(form);
    Severity: Major
    Found in app/assets/javascripts/rails.validations.js - About 2 hrs to fix

      Function uniqueness has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            uniqueness: function(element, options) {
              var data, key, message, name, ref, scope_value, scoped_element, scoped_name;
              message = ClientSideValidations.validators.local.presence(element, options);
              if (message) {
                if (options.allow_blank === true) {
      Severity: Major
      Found in app/assets/javascripts/rails.validations.js - About 2 hrs to fix

        Function numericality has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              numericality: function(element, options) {
                var CHECKS, check, check_value, fn, form, operator, val;
                val = $.trim(element.val());
                if (!ClientSideValidations.patterns.numericality.test(val)) {
                  if (options.allow_blank === true && this.presence(element, {
        Severity: Minor
        Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

          Function form has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              form: function(form) {
                var $form, binding, event, ref;
                $form = $(form);
                form.ClientSideValidations = {
                  settings: window.ClientSideValidations.forms[$form.attr('id')],
          Severity: Minor
          Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

            Function inclusion has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  inclusion: function(element, options) {
                    var lower, message, option, ref, upper;
                    message = this.presence(element, options);
                    if (message) {
                      if (options.allow_blank === true) {
            Severity: Minor
            Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

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

                    exclusion: function(element, options) {
                      var lower, message, option, ref, upper;
                      message = this.presence(element, options);
                      if (message) {
                        if (options.allow_blank === true) {
              Severity: Minor
              Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

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

                      length: function(element, options) {
                        var CHECKS, blankOptions, check, fn, message, operator, tokenized_length, tokenizer;
                        tokenizer = options.js_tokenizer || "split('')";
                        tokenized_length = new Function('element', "return (element.val()." + tokenizer + " || '').length")(element);
                        CHECKS = {
                Severity: Minor
                Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

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

                        uniqueness: function(element, options) {
                          var form, matches, name, name_prefix, name_suffix, valid, value;
                          name = element.attr('name');
                          if (/_attributes\]\[\d/.test(name)) {
                            matches = name.match(/^(.+_attributes\])\[\d+\](.+)$/);
                  Severity: Minor
                  Found in app/assets/javascripts/rails.validations.js - About 1 hr to fix

                    Avoid deeply nested control flow statements.
                    Open

                                      if ($(this).data('notLocallyUnique')) {
                                        return $(this).removeData('notLocallyUnique').data('changed', true);
                                      }
                    Severity: Major
                    Found in app/assets/javascripts/rails.validations.js - About 45 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                return options.message;
                      Severity: Major
                      Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                  return options.messages.odd;
                        Severity: Major
                        Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                    return options.messages.even;
                          Severity: Major
                          Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return;
                            Severity: Major
                            Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return options.messages[check];
                              Severity: Major
                              Found in app/assets/javascripts/rails.validations.js - About 30 mins to fix

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

                                          if (ref = element.val(), indexOf.call((function() {
                                            var i, len, ref1, results;
                                            ref1 = options["in"];
                                            results = [];
                                            for (i = 0, len = ref1.length; i < len; i++) {
                                Severity: Major
                                Found in app/assets/javascripts/rails.validations.js and 1 other location - About 4 hrs to fix
                                app/assets/javascripts/rails.validations.js on lines 420..431

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

                                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 (ref = element.val(), indexOf.call((function() {
                                            var i, len, ref1, results;
                                            ref1 = options["in"];
                                            results = [];
                                            for (i = 0, len = ref1.length; i < len; i++) {
                                Severity: Major
                                Found in app/assets/javascripts/rails.validations.js and 1 other location - About 4 hrs to fix
                                app/assets/javascripts/rails.validations.js on lines 451..462

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

                                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

                                    this.filter(ClientSideValidations.selectors.inputs).each(function() {
                                      return ClientSideValidations.enablers.input(this);
                                    });
                                Severity: Minor
                                Found in app/assets/javascripts/rails.validations.js and 1 other location - About 35 mins to fix
                                app/assets/javascripts/rails.validations.js on lines 20..22

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

                                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

                                    this.filter(ClientSideValidations.selectors.forms).each(function() {
                                      return ClientSideValidations.enablers.form(this);
                                    });
                                Severity: Minor
                                Found in app/assets/javascripts/rails.validations.js and 1 other location - About 35 mins to fix
                                app/assets/javascripts/rails.validations.js on lines 23..25

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

                                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