zigomir/rubber_ring

View on GitHub

Showing 15 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

    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

      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

                  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

                      Method build_templates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def build_templates(page_templates, page, key)
                              templates_concatenated = ''
                      
                              page_templates.each_with_index do |t, index|
                                t.id = t.id.nil? ? index : t.id
                      Severity: Minor
                      Found in app/helpers/rubber_ring/cms_helper.rb - About 25 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

                      Severity
                      Category
                      Status
                      Source
                      Language