Undev/redmine_lightbox

View on GitHub

Showing 37 of 74 total issues

Function destroy has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    Plugin.prototype.destroy = function(d) {

        var _this = this;

        if (!d) {
Severity: Minor
Found in assets/javascripts/lightgallery-all.js - About 1 hr to fix

    Function Plugin has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function Plugin(element, options) {
    
            // Current lightGallery element
            this.el = element;
    
    
    Severity: Minor
    Found in assets/javascripts/lightgallery-all.js - About 1 hr to fix

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

          Plugin.prototype.isVideo = function(src, index) {
      
              var html;
              if (this.s.dynamic) {
                  html = this.s.dynamicEl[index].html;
      Severity: Minor
      Found in assets/javascripts/lightgallery-all.js - About 1 hr to fix

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

            Plugin.prototype.enableSwipe = function() {
                var _this = this;
                var startCoords = 0;
                var endCoords = 0;
                var isMoved = false;
        Severity: Minor
        Found in assets/javascripts/lightgallery-all.js - About 1 hr to fix

          Function build has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              Plugin.prototype.build = function(index) {
          
                  var _this = this;
          
                  _this.structure();
          Severity: Minor
          Found in assets/javascripts/lightgallery-all.js - About 1 hr to fix

            Function getThumb has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function getThumb(src, thumb, index) {
                        var isVideo = _this.core.isVideo(src, index) || {};
                        var thumbImg;
                        var vimeoId = '';
            
            
            Severity: Minor
            Found in assets/javascripts/lightgallery-all.js - About 1 hr to fix

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

                      var actualSize = function(event, $image, index, fromIcon) {
                          var w = $image.width();
                          var nw;
                          if (_this.core.s.dynamic) {
                              nw = _this.core.s.dynamicEl[index].width || $image[0].naturalWidth || w;
              Severity: Minor
              Found in assets/javascripts/lightgallery-all.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                                    if (_this.core.s.loadDailymotionThumbnail) {
                                        thumbImg = '//www.dailymotion.com/thumbnail/video/' + isVideo.dailymotion[1];
                                    } else {
                                        thumbImg = thumb;
                                    }
                Severity: Major
                Found in assets/javascripts/lightgallery-all.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if ((index === _length - 1) && (_prevIndex === 0) && !fromThumb) {
                                          _prev = true;
                                          _next = false;
                                      }
                  Severity: Major
                  Found in assets/javascripts/lightgallery-all.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                            } else if (isVideo.vk) {
                    
                                a = '&autoplay=' + autoplay;
                                if (this.core.s.vkPlayerParams) {
                                    a = a + '&' + $.param(this.core.s.vkPlayerParams);
                    Severity: Major
                    Found in assets/javascripts/lightgallery-all.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  if (fL === '.' || fL === '#') {
                                      html = $(html).html();
                                  }
                      Severity: Major
                      Found in assets/javascripts/lightgallery-all.js - About 45 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                                        if (_this.s.dynamic) {
                                            _src = _this.s.dynamicEl[index].downloadUrl !== false && (_this.s.dynamicEl[index].downloadUrl || _this.s.dynamicEl[index].src);
                                        } else {
                                            _src = _this.$items.eq(index).attr('data-download-url') !== 'false' && (_this.$items.eq(index).attr('data-download-url') || _this.$items.eq(index).attr('href') || _this.$items.eq(index).attr('data-src'));
                        
                        
                        Severity: Major
                        Found in assets/javascripts/lightgallery-all.js - About 40 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                  if (_this.core.doCss() && _this.core.$items.length > 1 && ((_this.core.s.enableSwipe && _this.core.isTouch) || (_this.core.s.enableDrag && !_this.core.isTouch))) {
                                      _this.core.$el.on('onSlideClick.lg.tm', function() {
                                          var $el = _this.core.$slide.eq(_this.core.index);
                                          loadOnClick($el);
                                      });
                          Severity: Major
                          Found in assets/javascripts/lightgallery-all.js - About 40 mins to fix

                            Function loadVideo has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                Video.prototype.loadVideo = function(src, addClass, noposter, index, html) {
                            Severity: Minor
                            Found in assets/javascripts/lightgallery-all.js - About 35 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return {
                                              vk: vk
                                          };
                              Severity: Major
                              Found in assets/javascripts/lightgallery-all.js - About 30 mins to fix

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

                                      def lightbox_attachments
                                        case controller_name
                                          when 'issues'
                                            ( @issue && @issue.attachments ) || []
                                          when 'wiki'
                                Severity: Minor
                                Found in lib/redmine_lightbox/patches/application_controller_patch.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

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

                                    def generate_for(attachment, force = false)
                                      return nil unless can_generate_from?(attachment)
                                
                                      pdf_preview = attachment.pdf_preview
                                
                                
                                Severity: Minor
                                Found in app/models/pdf_preview.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