MakeYourLaws/MakeYourLaws

View on GitHub
app/assets/javascripts/jquery.form.js

Summary

Maintainability
F
1 wk
Test Coverage

Function ajaxSubmit has 544 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.fn.ajaxSubmit = function(options) {
    /*jshint scripturl:true */

    // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
    if (!this.length) {
Severity: Major
Found in app/assets/javascripts/jquery.form.js - About 2 days to fix
  • Create a ticket

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

    /*!
     * jQuery Form Plugin
     * version: 3.36.0-2013.06.16
     * @requires jQuery v1.5 or later
     * Copyright (c) 2013 M. Alsup
    Severity: Major
    Found in app/assets/javascripts/jquery.form.js - About 2 days to fix
    • Create a ticket

      Function fileUploadIframe has 360 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function fileUploadIframe(a) {
              var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle;
              var deferred = $.Deferred();
      
              if (a) {
      Severity: Major
      Found in app/assets/javascripts/jquery.form.js - About 1 day to fix
      • Create a ticket

        Function cb has 127 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                function cb(e) {
                    if (xhr.aborted || callbackProcessed) {
                        return;
                    }
                    
        Severity: Major
        Found in app/assets/javascripts/jquery.form.js - About 5 hrs to fix
        • Create a ticket

          Consider simplifying this complex logical expression.
          Open

              if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
                  (t == 'checkbox' || t == 'radio') && !el.checked ||
                  (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
                  tag == 'select' && el.selectedIndex == -1)) {
                      return null;
          Severity: Critical
          Found in app/assets/javascripts/jquery.form.js - About 3 hrs to fix
          • Create a ticket

            Function doSubmit has 73 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function doSubmit() {
                        // make sure form attrs are set
                        var t = $form.attr2('target'), a = $form.attr2('action');
            
                        // update form attrs in IE friendly way
            Severity: Major
            Found in app/assets/javascripts/jquery.form.js - About 2 hrs to fix
            • Create a ticket

              Function formToArray has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              $.fn.formToArray = function(semantic, elements) {
                  var a = [];
                  if (this.length === 0) {
                      return a;
                  }
              Severity: Major
              Found in app/assets/javascripts/jquery.form.js - About 2 hrs to fix
              • Create a ticket

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

                    function fileUploadXhr(a) {
                        var formdata = new FormData();
                
                        for (var i=0; i < a.length; i++) {
                            formdata.append(a[i].name, a[i].value);
                Severity: Minor
                Found in app/assets/javascripts/jquery.form.js - About 1 hr to fix
                • Create a ticket

                  Function fieldValue has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  $.fieldValue = function(el, successful) {
                      var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
                      if (successful === undefined) {
                          successful = true;
                      }
                  Severity: Minor
                  Found in app/assets/javascripts/jquery.form.js - About 1 hr to fix
                  • Create a ticket

                    Avoid deeply nested control flow statements.
                    Open

                                if (elements)
                                    elements.push(el);
                    Severity: Major
                    Found in app/assets/javascripts/jquery.form.js - About 45 mins to fix
                    • Create a ticket

                      Avoid deeply nested control flow statements.
                      Open

                                      for (j=0; j < files.length; j++) {
                                          a.push({name: n, value: files[j], type: el.type});
                                      }
                      Severity: Major
                      Found in app/assets/javascripts/jquery.form.js - About 45 mins to fix
                      • Create a ticket

                        Avoid too many return statements within this function.
                        Open

                                                return;
                        Severity: Major
                        Found in app/assets/javascripts/jquery.form.js - About 30 mins to fix
                        • Create a ticket

                          Avoid too many return statements within this function.
                          Open

                                  return this;
                          Severity: Major
                          Found in app/assets/javascripts/jquery.form.js - About 30 mins to fix
                          • Create a ticket

                            Avoid too many return statements within this function.
                            Open

                                return this;
                            Severity: Major
                            Found in app/assets/javascripts/jquery.form.js - About 30 mins to fix
                            • Create a ticket

                              Avoid too many return statements within this function.
                              Open

                                  return $(el).val();
                              Severity: Major
                              Found in app/assets/javascripts/jquery.form.js - About 30 mins to fix
                              • Create a ticket

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

                                            a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
                                Severity: Minor
                                Found in app/assets/javascripts/jquery.form.js and 1 other location - About 45 mins to fix
                                app/assets/javascripts/jquery.form.js on lines 901..901

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

                                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

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

                                                a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
                                Severity: Minor
                                Found in app/assets/javascripts/jquery.form.js and 1 other location - About 45 mins to fix
                                app/assets/javascripts/jquery.form.js on lines 941..941

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

                                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