spotweb/spotweb

View on GitHub
js/jquery/jquery.form.js

Summary

Maintainability
F
1 wk
Test Coverage

Function ajaxSubmit has 504 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 js/jquery/jquery.form.js - About 2 days to fix

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

    /*!
     * jQuery Form Plugin
     * version: 3.15 (09-SEP-2012)
     * @requires jQuery v1.3.2 or later
     *
    Severity: Major
    Found in js/jquery/jquery.form.js - About 1 day to fix

      Function fileUploadIframe has 337 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 useProp = !!$.fn.prop;
      
              if ($(':input[name=submit],:input[id=submit]', form).length) {
      Severity: Major
      Found in js/jquery/jquery.form.js - About 1 day to fix

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

                function cb(e) {
                    if (xhr.aborted || callbackProcessed) {
                        return;
                    }
                    try {
        Severity: Major
        Found in js/jquery/jquery.form.js - About 5 hrs to fix

          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 js/jquery/jquery.form.js - About 3 hrs to fix

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

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

              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 js/jquery/jquery.form.js - About 2 hrs to fix

                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 js/jquery/jquery.form.js - About 1 hr to fix

                  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 js/jquery/jquery.form.js - About 1 hr to fix

                    Avoid deeply nested control flow statements.
                    Open

                                if (elements) 
                                    elements.push(el);
                    Severity: Major
                    Found in js/jquery/jquery.form.js - About 45 mins to fix

                      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 js/jquery/jquery.form.js - About 45 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return this;
                        Severity: Major
                        Found in js/jquery/jquery.form.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return $(el).val();
                          Severity: Major
                          Found in js/jquery/jquery.form.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                                    return;
                            Severity: Major
                            Found in js/jquery/jquery.form.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  return this;
                              Severity: Major
                              Found in js/jquery/jquery.form.js - About 30 mins to fix

                                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 js/jquery/jquery.form.js and 1 other location - About 45 mins to fix
                                js/jquery/jquery.form.js on lines 821..821

                                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 js/jquery/jquery.form.js and 1 other location - About 45 mins to fix
                                js/jquery/jquery.form.js on lines 861..861

                                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