woothemes/woocommerce

View on GitHub
assets/js/photoswipe/photoswipe.js

Summary

Maintainability
F
1 mo
Test Coverage

Function PhotoSwipe has 2598 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    var PhotoSwipe = function(template, UiClass, items, options){

/*>>framework-bridge*/
/**
 *
Severity: Major
Found in assets/js/photoswipe/photoswipe.js - About 1 wk to fix

    File photoswipe.js has 2611 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*! PhotoSwipe - v4.1.3 - 2019-01-08
    * http://photoswipe.com
    * Copyright (c) 2019 Dmitry Semenov; */
    (function (root, factory) { 
        if (typeof define === 'function' && define.amd) {
    Severity: Major
    Found in assets/js/photoswipe/photoswipe.js - About 1 wk to fix

      Function _onDragRelease has 124 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _onDragRelease = function(e) {
      
              if(_features.isOldAndroid ) {
      
                  if(_oldAndroidTouchEndTimeout && e.type === 'mouseup') {
      Severity: Major
      Found in assets/js/photoswipe/photoswipe.js - About 4 hrs to fix

        Function _showOrHide has 121 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _showOrHide = function(item, img, out, completeFn) {
        
                if(_showOrHideTimeout) {
                    clearTimeout(_showOrHideTimeout);
                }
        Severity: Major
        Found in assets/js/photoswipe/photoswipe.js - About 4 hrs to fix

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

              init: function() {
          
                  if(_isOpen || _isDestroying) {
                      return;
                  }
          Severity: Major
          Found in assets/js/photoswipe/photoswipe.js - About 4 hrs to fix

            Function setContent has 107 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    setContent: function(holder, index) {
            
                        if(_options.loop) {
                            index = _getLoopedId(index);
                        }
            Severity: Major
            Found in assets/js/photoswipe/photoswipe.js - About 4 hrs to fix

              Function _renderMovement has 103 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  _renderMovement =  function() {
              
                      if(!_currentPoints) {
                          return;
                      }
              Severity: Major
              Found in assets/js/photoswipe/photoswipe.js - About 4 hrs to fix

                Function _initDragReleaseAnimationData has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _initDragReleaseAnimationData  = function() {
                        // temp local vars
                        var lastFlickDuration,
                            tempReleasePos;
                
                
                Severity: Major
                Found in assets/js/photoswipe/photoswipe.js - About 3 hrs to fix

                  Function _panOrMoveMainScroll has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      _panOrMoveMainScroll = function(axis, delta) {
                  
                          var panFriction,
                              overDiff = 0,
                              newOffset = _panOffset[axis] + delta[axis],
                  Severity: Major
                  Found in assets/js/photoswipe/photoswipe.js - About 3 hrs to fix

                    Function detectFeatures has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        detectFeatures: function() {
                            if(framework.features) {
                                return framework.features;
                            }
                            var helperEl = framework.createEl(),
                    Severity: Major
                    Found in assets/js/photoswipe/photoswipe.js - About 3 hrs to fix

                      Function startAnimation has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              var startAnimation = function() {
                                  var closeWithRaf = _closedByScroll,
                                      fadeEverything = !self.currItem.src || self.currItem.loadError || _options.showHideOpacity;
                                  
                                  // apply hw-acceleration to image
                      Severity: Major
                      Found in assets/js/photoswipe/photoswipe.js - About 2 hrs to fix

                        Function _onDragStart has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            _onDragStart = function(e) {
                        
                                // Allow dragging only via left mouse button.
                                // As this handler is not added in IE8 - we ignore e.which
                                // 
                        Severity: Major
                        Found in assets/js/photoswipe/photoswipe.js - About 2 hrs to fix

                          Function _finishSwipeMainScrollGesture has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              _finishSwipeMainScrollGesture = function(gestureType, _releaseAnimData) {
                                  var itemChanged;
                                  if(!_mainScrollAnimating) {
                                      _currZoomedItemIndex = _currentItemIndex;
                                  }
                          Severity: Major
                          Found in assets/js/photoswipe/photoswipe.js - About 2 hrs to fix

                            Function initHistory has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    initHistory: function() {
                            
                                        framework.extend(_options, _historyDefaultOptions, true);
                            
                                        if( !_options.history ) {
                            Severity: Major
                            Found in assets/js/photoswipe/photoswipe.js - About 2 hrs to fix

                              Function updateSize has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  updateSize: function(force) {
                                      
                                      if(!_isFixedPosition && _options.modal) {
                                          var windowScrollY = framework.getScrollY();
                                          if(_currentWindowScrollY !== windowScrollY) {
                              Severity: Major
                              Found in assets/js/photoswipe/photoswipe.js - About 2 hrs to fix

                                Function initController has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                        initController: function() {
                                            framework.extend(_options, _controllerDefaultOptions, true);
                                            self.items = _items = items;
                                            _getItemAt = self.getItemAt;
                                            _getNumItems = _options.getNumItemsFn; //self.getNumItems;
                                Severity: Minor
                                Found in assets/js/photoswipe/photoswipe.js - About 1 hr to fix

                                  Function initGestures has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                          initGestures: function() {
                                  
                                              // helper function that builds touch/pointer/mouse events
                                              var addEventNames = function(pref, down, move, up, cancel) {
                                                  _dragStartEvent = pref + down;
                                  Severity: Minor
                                  Found in assets/js/photoswipe/photoswipe.js - About 1 hr to fix

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

                                            handleMouseWheel: function(e) {
                                    
                                                if(_currZoomLevel <= self.currItem.fitRatio) {
                                                    if( _options.modal ) {
                                    
                                    
                                    Severity: Minor
                                    Found in assets/js/photoswipe/photoswipe.js - About 1 hr to fix

                                      Function _calculateItemSize has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          _calculateItemSize = function(item, viewportSize, zoomLevel) {
                                      
                                              if (item.src && !item.loadError) {
                                                  var isInitial = !zoomLevel;
                                                  
                                      Severity: Minor
                                      Found in assets/js/photoswipe/photoswipe.js - About 1 hr to fix

                                        Function updateCurrItem has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            updateCurrItem: function(beforeAnimation) {
                                        
                                                if(_indexDiff === 0) {
                                                    return;
                                                }
                                        Severity: Minor
                                        Found in assets/js/photoswipe/photoswipe.js - About 1 hr to fix

                                          Function setupDesktopZoom has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                                  setupDesktopZoom: function(onInit) {
                                          
                                                      _wheelDelta = {};
                                          
                                                      var events = 'wheel mousewheel DOMMouseScroll';
                                          Severity: Minor
                                          Found in assets/js/photoswipe/photoswipe.js - About 1 hr to fix

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

                                                _updateHash = function() {
                                            
                                                    if(_hashAnimCheckTimeout) {
                                                        clearTimeout(_hashAnimCheckTimeout);
                                                    }
                                            Severity: Minor
                                            Found in assets/js/photoswipe/photoswipe.js - About 1 hr to fix

                                              Function zoomTo has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                              Open

                                                  zoomTo: function(destZoomLevel, centerPoint, speed, easingFn, updateFn) {
                                                      /*
                                                          if(destZoomLevel === 'fit') {
                                                              destZoomLevel = self.currItem.fitRatio;
                                                          } else if(destZoomLevel === 'fill') {
                                              Severity: Minor
                                              Found in assets/js/photoswipe/photoswipe.js - About 1 hr to fix

                                                Function loadComplete has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                                Open

                                                                item.loadComplete = function(item) {
                                                
                                                                    // gallery closed before image finished loading
                                                                    if(!_isOpen) {
                                                                        return;
                                                Severity: Minor
                                                Found in assets/js/photoswipe/photoswipe.js - About 1 hr to fix

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

                                                      _setupTransforms = function() {
                                                  
                                                          if(_transformKey) {
                                                              // setup 3d transforms
                                                              var allow3dTransform = _features.perspective && !_likelyTouchDevice;
                                                  Severity: Minor
                                                  Found in assets/js/photoswipe/photoswipe.js - About 1 hr to fix

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

                                                        _parseItemIndexFromURL = function() {
                                                            var hash = _getHash(),
                                                                params = {};
                                                    
                                                            if(hash.length < 5) { // pid=1
                                                    Severity: Minor
                                                    Found in assets/js/photoswipe/photoswipe.js - About 1 hr to fix

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

                                                          _getTouchPoints = function(e) {
                                                              // clean up previous points, without recreating array
                                                              while(_tempPointsArr.length > 0) {
                                                                  _tempPointsArr.pop();
                                                              }
                                                      Severity: Minor
                                                      Found in assets/js/photoswipe/photoswipe.js - About 1 hr to fix

                                                        Function onTapRelease has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                                        Open

                                                                onTapRelease: function(e, releasePoint) {
                                                                    if(!releasePoint) {
                                                                        return;
                                                                    }
                                                        
                                                        
                                                        Severity: Minor
                                                        Found in assets/js/photoswipe/photoswipe.js - About 1 hr to fix

                                                          Function _animateProp has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                                          Open

                                                              _animateProp = function(name, b, endProp, d, easingFn, onUpdate, onComplete) {
                                                          Severity: Major
                                                          Found in assets/js/photoswipe/photoswipe.js - About 50 mins to fix

                                                            Avoid deeply nested control flow statements.
                                                            Open

                                                                                    if(mainScrollDiff < 0 && newMainScrollPosition > _startMainScrollPos.x) {
                                                                                        newMainScrollPos = _startMainScrollPos.x;
                                                                                    }
                                                            Severity: Major
                                                            Found in assets/js/photoswipe/photoswipe.js - About 45 mins to fix

                                                              Avoid deeply nested control flow statements.
                                                              Open

                                                                                      if(_currPanBounds.min.x !== _currPanBounds.max.x) {
                                                                                          newPanPos = newOffset;
                                                                                      }
                                                              Severity: Major
                                                              Found in assets/js/photoswipe/photoswipe.js - About 45 mins to fix

                                                                Function _appendImage has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                                                Open

                                                                    _appendImage = function(index, item, baseDiv, img, preventAnimation, keepPlaceholder) {
                                                                Severity: Minor
                                                                Found in assets/js/photoswipe/photoswipe.js - About 45 mins to fix

                                                                  Avoid deeply nested control flow statements.
                                                                  Open

                                                                                      if(!unbind) {
                                                                                          listener['oldIE' + evName] = _handleEv;
                                                                                      } else {
                                                                                          if(!listener['oldIE' + evName]) {
                                                                                              return false;
                                                                  Severity: Major
                                                                  Found in assets/js/photoswipe/photoswipe.js - About 45 mins to fix

                                                                    Avoid deeply nested control flow statements.
                                                                    Open

                                                                                            if(_currPanBounds.min.x !== _currPanBounds.max.x) {
                                                                                                newPanPos = newOffset;
                                                                                            }
                                                                    Severity: Major
                                                                    Found in assets/js/photoswipe/photoswipe.js - About 45 mins to fix

                                                                      Avoid deeply nested control flow statements.
                                                                      Open

                                                                                              if(mainScrollDiff > 0 && newMainScrollPosition < _startMainScrollPos.x) {
                                                                                                  newMainScrollPos = _startMainScrollPos.x;
                                                                                              }
                                                                      Severity: Major
                                                                      Found in assets/js/photoswipe/photoswipe.js - About 45 mins to fix

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

                                                                            _applyZoomTransform = function(styleObj,x,y,zoom,item) {
                                                                        Severity: Minor
                                                                        Found in assets/js/photoswipe/photoswipe.js - About 35 mins to fix

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

                                                                                      var addEventNames = function(pref, down, move, up, cancel) {
                                                                          Severity: Minor
                                                                          Found in assets/js/photoswipe/photoswipe.js - About 35 mins to fix

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

                                                                                zoomTo: function(destZoomLevel, centerPoint, speed, easingFn, updateFn) {
                                                                            Severity: Minor
                                                                            Found in assets/js/photoswipe/photoswipe.js - About 35 mins to fix

                                                                              Avoid too many return statements within this function.
                                                                              Open

                                                                                          return;
                                                                              Severity: Major
                                                                              Found in assets/js/photoswipe/photoswipe.js - About 30 mins to fix

                                                                                Avoid too many return statements within this function.
                                                                                Open

                                                                                                    return ;
                                                                                Severity: Major
                                                                                Found in assets/js/photoswipe/photoswipe.js - About 30 mins to fix

                                                                                  Avoid too many return statements within this function.
                                                                                  Open

                                                                                              return;
                                                                                  Severity: Major
                                                                                  Found in assets/js/photoswipe/photoswipe.js - About 30 mins to fix

                                                                                    Avoid too many return statements within this function.
                                                                                    Open

                                                                                                    return;
                                                                                    Severity: Major
                                                                                    Found in assets/js/photoswipe/photoswipe.js - About 30 mins to fix

                                                                                      Avoid too many return statements within this function.
                                                                                      Open

                                                                                                      return;
                                                                                      Severity: Major
                                                                                      Found in assets/js/photoswipe/photoswipe.js - About 30 mins to fix

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

                                                                                        (function (root, factory) { 
                                                                                            if (typeof define === 'function' && define.amd) {
                                                                                                define(factory);
                                                                                            } else if (typeof exports === 'object') {
                                                                                                module.exports = factory();
                                                                                        Severity: Major
                                                                                        Found in assets/js/photoswipe/photoswipe.js and 1 other location - About 2 hrs to fix
                                                                                        assets/js/photoswipe/photoswipe-ui-default.js on lines 10..861

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

                                                                                        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

                                                                                                    if(y > _currPanBounds.min.y) {
                                                                                                        y = _currPanBounds.min.y;
                                                                                                    } else if(y < _currPanBounds.max.y) {
                                                                                                        y = _currPanBounds.max.y;
                                                                                                    }
                                                                                        Severity: Major
                                                                                        Found in assets/js/photoswipe/photoswipe.js and 1 other location - About 1 hr to fix
                                                                                        assets/js/photoswipe/photoswipe.js on lines 1031..1035

                                                                                        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

                                                                                                    if(x > _currPanBounds.min.x) {
                                                                                                        x = _currPanBounds.min.x;
                                                                                                    } else if(x < _currPanBounds.max.x) {
                                                                                                        x = _currPanBounds.max.x;
                                                                                                    }
                                                                                        Severity: Major
                                                                                        Found in assets/js/photoswipe/photoswipe.js and 1 other location - About 1 hr to fix
                                                                                        assets/js/photoswipe/photoswipe.js on lines 1037..1041

                                                                                        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

                                                                                                            if( (startOverDiff <= 0 || mainScrollDiff < 0) && _getNumItems() > 1 ) {
                                                                                                                newMainScrollPos = newMainScrollPosition;
                                                                                                                if(mainScrollDiff < 0 && newMainScrollPosition > _startMainScrollPos.x) {
                                                                                                                    newMainScrollPos = _startMainScrollPos.x;
                                                                                                                }
                                                                                        Severity: Minor
                                                                                        Found in assets/js/photoswipe/photoswipe.js and 1 other location - About 30 mins to fix
                                                                                        assets/js/photoswipe/photoswipe.js on lines 1583..1594

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

                                                                                        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

                                                                                                            if( (startOverDiff <= 0 || mainScrollDiff > 0) && _getNumItems() > 1 ) {
                                                                                                                newMainScrollPos = newMainScrollPosition;
                                                                                        
                                                                                                                if(mainScrollDiff > 0 && newMainScrollPosition < _startMainScrollPos.x) {
                                                                                                                    newMainScrollPos = _startMainScrollPos.x;
                                                                                        Severity: Minor
                                                                                        Found in assets/js/photoswipe/photoswipe.js and 1 other location - About 30 mins to fix
                                                                                        assets/js/photoswipe/photoswipe.js on lines 1563..1573

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

                                                                                        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