zigomir/rubber_ring

View on GitHub

Showing 21 of 21 total issues

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

;(function(){


/**
 * hasOwnProperty.
Severity: Major
Found in app/assets/javascripts/libs/dropzone.js - About 2 days 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 = [];
    Severity: Major
    Found in app/assets/javascripts/libs/dropzone.js and 1 other location - About 1 day to fix
    app/assets/javascripts/libs/dropzone.js on lines 768..788

    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 = [];
    Severity: Major
    Found in app/assets/javascripts/libs/dropzone.js and 1 other location - About 1 day to fix
    app/assets/javascripts/libs/dropzone.js on lines 746..766

    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

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

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

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

              if (typeof this.options.previewsContainer === "string") {
                this.previewsContainer = document.querySelector(this.options.previewsContainer);
              } else if (this.options.previewsContainer.nodeType != null) {
                this.previewsContainer = this.options.previewsContainer;
              }
      Severity: Major
      Found in app/assets/javascripts/libs/dropzone.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/libs/dropzone.js on lines 595..599

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

      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

              } else if (typeof this.options.clickable === "string") {
                this.clickableElement = document.querySelector(this.options.clickable);
              } else if (this.options.clickable.nodeType != null) {
                this.clickableElement = this.options.clickable;
              }
      Severity: Major
      Found in app/assets/javascripts/libs/dropzone.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/libs/dropzone.js on lines 581..585

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

      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

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

          function Dropzone(element, options) {
            var elementOptions, extend, fallback, _ref;
      
            this.element = element;
            this.version = Dropzone.version;
      Severity: Major
      Found in app/assets/javascripts/libs/dropzone.js - About 2 hrs to fix

        Function uploadFile has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            Dropzone.prototype.uploadFile = function(file) {
              var formData, handleError, input, inputName, inputType, key, progressObj, value, xhr, _i, _len, _ref, _ref1, _ref2,
                _this = this;
        
              xhr = new XMLHttpRequest();
        Severity: Major
        Found in app/assets/javascripts/libs/dropzone.js - About 2 hrs to fix

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

              Dropzone.prototype.createThumbnail = function(file) {
                var fileReader,
                  _this = this;
          
                fileReader = new FileReader;
          Severity: Minor
          Found in app/assets/javascripts/libs/dropzone.js - About 1 hr to fix

            Function addEvent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            var addEvent = (function () {
              if (document.addEventListener) {
                return function (el, type, fn) {
                  if (el && el.nodeName || el === window) {
                    el.addEventListener(type, fn, false);
            Severity: Minor
            Found in app/assets/javascripts/libs/h5utils.js - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method load_attachments_page has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def Util.load_attachments_page(params)
                  images = []
                  attachments = []
                  dir_config = get_attachment_directories(params)
                  dirs_to_crawl = [dir_config.image_dir, dir_config.file_dir]
            Severity: Minor
            Found in app/concerns/rubber_ring/util.rb - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                  fileReader.onload = function() {
                    var img;
            
                    img = new Image;
                    img.onload = function() {
            Severity: Minor
            Found in app/assets/javascripts/libs/dropzone.js - About 1 hr to fix

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

                      img.onload = function() {
                        var canvas, ctx, srcHeight, srcRatio, srcWidth, srcX, srcY, thumbnail, trgHeight, trgRatio, trgWidth, trgX, trgY;
              
                        canvas = document.createElement("canvas");
                        ctx = canvas.getContext("2d");
              Severity: Minor
              Found in app/assets/javascripts/libs/dropzone.js - About 1 hr to fix

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

                  Dropzone.discover = function() {
                    var checkElements, dropzone, dropzones, _i, _len, _results;
                
                    if (!Dropzone.autoDiscover) {
                      return;
                Severity: Minor
                Found in app/assets/javascripts/libs/dropzone.js - About 1 hr to fix

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

                        if (el && el.nodeName || el === window) {
                          el.addEventListener(type, fn, false);
                        } else if (el && el.length) {
                          for (var i = 0; i < el.length; i++) {
                            addEvent(el[i], type, fn);
                  Severity: Major
                  Found in app/assets/javascripts/libs/h5utils.js and 1 other location - About 1 hr to fix
                  app/assets/javascripts/libs/h5utils.js on lines 17..23

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

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                        if (el && el.nodeName || el === window) {
                          el.attachEvent('on' + type, function () { return fn.call(el, window.event); });
                        } else if (el && el.length) {
                          for (var i = 0; i < el.length; i++) {
                            addEvent(el[i], type, fn);
                  Severity: Major
                  Found in app/assets/javascripts/libs/h5utils.js and 1 other location - About 1 hr to fix
                  app/assets/javascripts/libs/h5utils.js on lines 7..13

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

                  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

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

                  require.relative = function(parent) {
                    var p = require.normalize(parent, '..');
                  
                    /**
                     * lastIndexOf helper.
                  Severity: Minor
                  Found in app/assets/javascripts/libs/dropzone.js - About 1 hr to fix

                    Method editable_image has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def editable_image(options = {}, page)
                          key = options[:key]
                          image_source = nil
                          image_source = page.content[key] unless page.content.nil?
                    
                    
                    Severity: Minor
                    Found in app/helpers/rubber_ring/cms_helper.rb - About 55 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method compose_link has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def compose_link(block, options, page)
                          key = options[:key]
                          content_value = nil
                          content_value = page.content[key] unless page.content.nil?
                          href_attribute = nil
                    Severity: Minor
                    Found in app/helpers/rubber_ring/cms_helper.rb - About 45 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    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/libs/dropzone.js - About 40 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language