AsgardCms/Media

View on GitHub
Assets/js/dropzone.js

Summary

Maintainability
F
1 wk
Test Coverage

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

;(function(){

    /**
     * Require the module at `name`.
     *
Severity: Major
Found in Assets/js/dropzone.js - About 4 days to fix

    Function init has 143 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 Assets/js/dropzone.js - About 5 hrs to fix

      Function uploadFiles has 142 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, option, progressObj, response, updateProgress, 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 Assets/js/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 Assets/js/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 Assets/js/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 Assets/js/dropzone.js - About 1 hr to fix

              Function createThumbnail has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                              Dropzone.prototype.createThumbnail = function(file, callback) {
                                  var fileReader;
                                  fileReader = new FileReader;
                                  fileReader.onload = (function(_this) {
                                      return function() {
              Severity: Minor
              Found in Assets/js/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 Assets/js/dropzone.js - About 1 hr to fix

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

                                      fileReader.onload = (function(_this) {
                                          return function() {
                                              var img;
                                              img = document.createElement("img");
                                              img.onload = function() {
                  Severity: Minor
                  Found in Assets/js/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 Assets/js/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 Assets/js/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 Assets/js/dropzone.js - About 40 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                          return false;
                          Severity: Major
                          Found in Assets/js/dropzone.js - About 30 mins to fix

                            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 Assets/js/dropzone.js and 1 other location - About 1 day to fix
                            Assets/js/dropzone.js on lines 930..948

                            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.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 Assets/js/dropzone.js and 1 other location - About 1 day to fix
                            Assets/js/dropzone.js on lines 910..928

                            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 Assets/js/dropzone.js and 1 other location - About 7 hrs to fix
                            Assets/js/dropzone.js on lines 1501..1516

                            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 Assets/js/dropzone.js and 1 other location - About 7 hrs to fix
                            Assets/js/dropzone.js on lines 1484..1499

                            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.xhr === xhr) {
                                                            _results.push(file);
                                                        }
                            Severity: Major
                            Found in Assets/js/dropzone.js and 1 other location - About 1 hr to fix
                            Assets/js/dropzone.js on lines 654..659

                            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.status === status) {
                                                        _results.push(file);
                                                    }
                            Severity: Major
                            Found in Assets/js/dropzone.js and 1 other location - About 1 hr to fix
                            Assets/js/dropzone.js on lines 1297..1302

                            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 = files.length; _i < _len; _i++) {
                                                    file = files[_i];
                                                    _results.push(this.addFile(file));
                                                }
                            Severity: Major
                            Found in Assets/js/dropzone.js and 1 other location - About 1 hr to fix
                            Assets/js/dropzone.js on lines 958..961

                            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 = _ref.length; _i < _len; _i++) {
                                                    file = _ref[_i];
                                                    _results.push(this.cancelUpload(file));
                                                }
                            Severity: Major
                            Found in Assets/js/dropzone.js and 1 other location - About 1 hr to fix
                            Assets/js/dropzone.js on lines 1036..1039

                            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 Assets/js/dropzone.js and 1 other location - About 1 hr to fix
                            Assets/js/dropzone.js on lines 426..429

                            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 Assets/js/dropzone.js and 1 other location - About 1 hr to fix
                            Assets/js/dropzone.js on lines 1311..1314

                            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 (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
                                                    el = _ref[_j];
                                                    elements.push(el);
                                                }
                            Severity: Minor
                            Found in Assets/js/dropzone.js and 1 other location - About 55 mins to fix
                            Assets/js/dropzone.js on lines 718..721

                            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 (_i = 0, _len = files.length; _i < _len; _i++) {
                                                                        file = files[_i];
                                                                        _this.addFile(file);
                                                                    }
                            Severity: Minor
                            Found in Assets/js/dropzone.js and 1 other location - About 55 mins to fix
                            Assets/js/dropzone.js on lines 1672..1675

                            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