redmine/redmine

View on GitHub
app/assets/javascripts/attachments.js

Summary

Maintainability
B
6 hrs
Test Coverage

Function ajaxUpload has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function ajaxUpload(file, attachmentId, fileSpan, inputEl) {

  function onLoadstart(e) {
    fileSpan.removeClass('ajax-waiting');
    fileSpan.addClass('ajax-loading');
Severity: Minor
Found in app/assets/javascripts/attachments.js - About 1 hr to fix

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

    function addInlineAttachmentMarkup(file) {
      // insert uploaded image inline if dropped area is currently focused textarea
      if($(handleFileDropEvent.target).hasClass('wiki-edit') && $.inArray(file.type, window.wikiImageMimeTypes) > -1) {
        var $textarea = $(handleFileDropEvent.target);
        var cursorPosition = $textarea.prop('selectionStart');
    Severity: Minor
    Found in app/assets/javascripts/attachments.js - About 1 hr to fix

      Function addInlineAttachmentMarkup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      function addInlineAttachmentMarkup(file) {
        // insert uploaded image inline if dropped area is currently focused textarea
        if($(handleFileDropEvent.target).hasClass('wiki-edit') && $.inArray(file.type, window.wikiImageMimeTypes) > -1) {
          var $textarea = $(handleFileDropEvent.target);
          var cursorPosition = $textarea.prop('selectionStart');
      Severity: Minor
      Found in app/assets/javascripts/attachments.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

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

      function uploadBlob(blob, uploadUrl, attachmentId, options) {
      
        var actualOptions = $.extend({
          loadstartEventHandler: $.noop,
          progressEventHandler: $.noop
      Severity: Minor
      Found in app/assets/javascripts/attachments.js - About 1 hr to fix

        Function addFile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function addFile(inputEl, file, eagerUpload) {
          var attachmentsFields = $(inputEl).closest('.attachments_form').find('.attachments_fields');
          var addAttachment = $(inputEl).closest('.attachments_form').find('.add_attachment');
          var maxFiles = ($(inputEl).attr('multiple') == 'multiple' ? 10 : 1);
        
        
        Severity: Minor
        Found in app/assets/javascripts/attachments.js - 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

        Function addInputFiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function addInputFiles(inputEl) {
          var attachmentsFields = $(inputEl).closest('.attachments_form').find('.attachments_fields');
          var addAttachment = $(inputEl).closest('.attachments_form').find('.add_attachment');
          var clearedFileInput = $(inputEl).clone().val('');
          var sizeExceeded = false;
        Severity: Minor
        Found in app/assets/javascripts/attachments.js - 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

        Function copyImageFromClipboard has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function copyImageFromClipboard(e) {
          if (!$(e.target).hasClass('wiki-edit')) { return; }
          var clipboardData = e.clipboardData || e.originalEvent.clipboardData
          if (!clipboardData) { return; }
          if (clipboardData.types.some(function(t){ return /^text\/plain$/.test(t); })) { return; }
        Severity: Minor
        Found in app/assets/javascripts/attachments.js - 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

        There are no issues that match your filters.

        Category
        Status