codn/adminpanel

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

Summary

Maintainability
F
1 wk
Test Coverage

File dropzone.js has 1596 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 148 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 146 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 createThumbnailFromUrl has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

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

                    Dropzone.prototype._addFilesFromDirectory = function(directory, path) {
                      var dirReader, errorHandler, readEntries;
                      dirReader = directory.createReader();
                      errorHandler = function(error) {
                        return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 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 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 772..790

                            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 792..810

                            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._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 1406..1421

                            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._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 1389..1404

                            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 1185..1190

                            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 500..505

                            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 (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
                                        node = _ref1[_j];
                                        node.innerHTML = this.filesize(file.size);
                                      }
                            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 261..264

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

                            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 = this._renameFilename(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 266..269

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

                            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 898..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 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 820..823

                            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];
                                              _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 1577..1580

                            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 571..574

                            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