joseramonc/adminpanel

View on GitHub
app/assets/javascripts/adminpanel/dropzone.js

Summary

Maintainability
F
1 wk
Test Coverage

File dropzone.js has 1560 lines of code (exceeds 250 allowed). Consider refactoring.
Open


/*
 *
 * More info at [www.dropzonejs.com](http://www.dropzonejs.com)
 *
Severity: Major
Found in app/assets/javascripts/adminpanel/dropzone.js - About 4 days to fix

    Function init has 146 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        Dropzone.prototype.init = function() {
          var eventName, noPropagation, setupHiddenFileInput, _i, _len, _ref, _ref1;
          if (this.element.tagName === "form") {
            this.element.setAttribute("enctype", "multipart/form-data");
          }
    Severity: Major
    Found in app/assets/javascripts/adminpanel/dropzone.js - About 5 hrs to fix

      Function uploadFiles has 144 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          Dropzone.prototype.uploadFiles = function(files) {
            var file, formData, handleError, headerName, headerValue, headers, i, input, inputName, inputType, key, method, option, progressObj, response, updateProgress, url, value, xhr, _i, _j, _k, _l, _len, _len1, _len2, _len3, _m, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
            xhr = new XMLHttpRequest();
            for (_i = 0, _len = files.length; _i < _len; _i++) {
              file = files[_i];
      Severity: Major
      Found in app/assets/javascripts/adminpanel/dropzone.js - About 5 hrs to fix

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

            function Dropzone(element, options) {
              var elementOptions, fallback, _ref;
              this.element = element;
              this.version = Dropzone.version;
              this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, "");
        Severity: Major
        Found in app/assets/javascripts/adminpanel/dropzone.js - About 2 hrs to fix

          Function addedfile has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                addedfile: function(file) {
                  var node, removeFileEvent, removeLink, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _results;
                  if (this.element === this.previewsContainer) {
                    this.element.classList.add("dz-started");
                  }
          Severity: Minor
          Found in app/assets/javascripts/adminpanel/dropzone.js - About 1 hr to fix

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

                  resize: function(file) {
                    var info, srcRatio, trgRatio;
                    info = {
                      srcX: 0,
                      srcY: 0,
            Severity: Minor
            Found in app/assets/javascripts/adminpanel/dropzone.js - About 1 hr to fix

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

                Dropzone.discover = function() {
                  var checkElements, dropzone, dropzones, _i, _len, _results;
                  if (document.querySelectorAll) {
                    dropzones = document.querySelectorAll(".dropzone");
                  } else {
              Severity: Minor
              Found in app/assets/javascripts/adminpanel/dropzone.js - About 1 hr to fix

                Function createThumbnailFromUrl has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    Dropzone.prototype.createThumbnailFromUrl = function(file, imageUrl, callback) {
                      var img;
                      img = document.createElement("img");
                      img.onload = (function(_this) {
                        return function() {
                Severity: Minor
                Found in app/assets/javascripts/adminpanel/dropzone.js - About 1 hr to fix

                  Function getElements has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    Dropzone.getElements = function(els, name) {
                      var e, el, elements, _i, _j, _len, _len1, _ref;
                      if (els instanceof Array) {
                        elements = [];
                        try {
                  Severity: Minor
                  Found in app/assets/javascripts/adminpanel/dropzone.js - About 1 hr to fix

                    Avoid deeply nested control flow statements.
                    Open

                                  if (option.selected) {
                                    formData.append(inputName, option.value);
                                  }
                    Severity: Major
                    Found in app/assets/javascripts/adminpanel/dropzone.js - About 45 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                          if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
                            if (!("classList" in document.createElement("a"))) {
                              capableBrowser = false;
                            } else {
                              _ref = Dropzone.blacklistedBrowsers;
                      Severity: Major
                      Found in app/assets/javascripts/adminpanel/dropzone.js - About 40 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return false;
                        Severity: Major
                        Found in app/assets/javascripts/adminpanel/dropzone.js - About 30 mins to fix

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

                              Dropzone.prototype.removeEventListeners = function() {
                                var elementListeners, event, listener, _i, _len, _ref, _results;
                                _ref = this.listeners;
                                _results = [];
                                for (_i = 0, _len = _ref.length; _i < _len; _i++) {
                          Severity: Major
                          Found in app/assets/javascripts/adminpanel/dropzone.js and 1 other location - About 1 day to fix
                          app/assets/javascripts/adminpanel/dropzone.js on lines 753..771

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

                          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

                              Dropzone.prototype.setupEventListeners = function() {
                                var elementListeners, event, listener, _i, _len, _ref, _results;
                                _ref = this.listeners;
                                _results = [];
                                for (_i = 0, _len = _ref.length; _i < _len; _i++) {
                          Severity: Major
                          Found in app/assets/javascripts/adminpanel/dropzone.js and 1 other location - About 1 day to fix
                          app/assets/javascripts/adminpanel/dropzone.js on lines 773..791

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

                          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

                              Dropzone.prototype._errorProcessing = function(files, message, xhr) {
                                var file, _i, _len;
                                for (_i = 0, _len = files.length; _i < _len; _i++) {
                                  file = files[_i];
                                  file.status = Dropzone.ERROR;
                          Severity: Major
                          Found in app/assets/javascripts/adminpanel/dropzone.js and 1 other location - About 7 hrs to fix
                          app/assets/javascripts/adminpanel/dropzone.js on lines 1350..1365

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

                          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

                              Dropzone.prototype._finished = function(files, responseText, e) {
                                var file, _i, _len;
                                for (_i = 0, _len = files.length; _i < _len; _i++) {
                                  file = files[_i];
                                  file.status = Dropzone.SUCCESS;
                          Severity: Major
                          Found in app/assets/javascripts/adminpanel/dropzone.js and 1 other location - About 7 hrs to fix
                          app/assets/javascripts/adminpanel/dropzone.js on lines 1367..1382

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

                          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

                                for (_i = 0, _len = _ref.length; _i < _len; _i++) {
                                  file = _ref[_i];
                                  if (file.status === status) {
                                    _results.push(file);
                                  }
                          Severity: Major
                          Found in app/assets/javascripts/adminpanel/dropzone.js and 1 other location - About 1 hr to fix
                          app/assets/javascripts/adminpanel/dropzone.js on lines 1152..1157

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

                          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

                                  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
                                    file = _ref[_i];
                                    if (file.xhr === xhr) {
                                      _results.push(file);
                                    }
                          Severity: Major
                          Found in app/assets/javascripts/adminpanel/dropzone.js and 1 other location - About 1 hr to fix
                          app/assets/javascripts/adminpanel/dropzone.js on lines 494..499

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

                          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

                                for (_i = 0, _len = _ref.length; _i < _len; _i++) {
                                  file = _ref[_i];
                                  _results.push(this.cancelUpload(file));
                                }
                          Severity: Major
                          Found in app/assets/javascripts/adminpanel/dropzone.js and 1 other location - About 1 hr to fix
                          app/assets/javascripts/adminpanel/dropzone.js on lines 875..878

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

                          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

                                for (_i = 0, _len = files.length; _i < _len; _i++) {
                                  file = files[_i];
                                  _results.push(this.addFile(file));
                                }
                          Severity: Major
                          Found in app/assets/javascripts/adminpanel/dropzone.js and 1 other location - About 1 hr to fix
                          app/assets/javascripts/adminpanel/dropzone.js on lines 801..804

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

                          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

                                  for (_i = 0, _len = groupedFiles.length; _i < _len; _i++) {
                                    groupedFile = groupedFiles[_i];
                                    groupedFile.status = Dropzone.CANCELED;
                                  }
                          Severity: Major
                          Found in app/assets/javascripts/adminpanel/dropzone.js and 1 other location - About 1 hr to fix
                          app/assets/javascripts/adminpanel/dropzone.js on lines 256..259

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

                          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

                                    for (_i = 0, _len = _ref.length; _i < _len; _i++) {
                                      node = _ref[_i];
                                      node.textContent = file.name;
                                    }
                          Severity: Major
                          Found in app/assets/javascripts/adminpanel/dropzone.js and 1 other location - About 1 hr to fix
                          app/assets/javascripts/adminpanel/dropzone.js on lines 1166..1169

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

                          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

                                          for (_i = 0, _len = files.length; _i < _len; _i++) {
                                            file = files[_i];
                                            _this.addFile(file);
                                          }
                          Severity: Minor
                          Found in app/assets/javascripts/adminpanel/dropzone.js and 1 other location - About 55 mins to fix
                          app/assets/javascripts/adminpanel/dropzone.js on lines 1538..1541

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

                          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

                                for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
                                  el = _ref[_j];
                                  elements.push(el);
                                }
                          Severity: Minor
                          Found in app/assets/javascripts/adminpanel/dropzone.js and 1 other location - About 55 mins to fix
                          app/assets/javascripts/adminpanel/dropzone.js on lines 561..564

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

                          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