lujanfernaud/prevy

View on GitHub
public/assets/lazysizes-0622dd876a33cdbe06d2c1c01c3e3b9a8ca531f3c3c3ec27639622d535ceeec0.js

Summary

Maintainability
F
1 wk
Test Coverage

Function l has a Cognitive Complexity of 274 (exceeds 5 allowed). Consider refactoring.
Open

}(window, function l(window, document) {
    'use strict';
    /*jshint eqnull:true */
    if(!document.getElementsByClassName){return;}

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 l has 535 lines of code (exceeds 25 allowed). Consider refactoring.
Open

}(window, function l(window, document) {
    'use strict';
    /*jshint eqnull:true */
    if(!document.getElementsByClassName){return;}

    File lazysizes-0622dd876a33cdbe06d2c1c01c3e3b9a8ca531f3c3c3ec27639622d535ceeec0.js has 642 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    (function(window, factory) {
        var lazySizes = factory(window, window.document);
        window.lazySizes = lazySizes;
        if(typeof module == 'object' && module.exports){
            module.exports = lazySizes;

      Function loader has 250 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var loader = (function(){
              var preloadElems, isCompleted, resetPreloadingTimer, loadMode, started;
      
              var eLvW, elvH, eLtop, eLleft, eLright, eLbottom;
      
      

        Consider simplifying this complex logical expression.
        Open

                            } else if(!loadedSomething && isCompleted && !autoLoadElem &&
                                isLoading < 4 && lowRuns < 4 && loadMode > 2 &&
                                (preloadElems[0] || lazySizesConfig.preloadAfterLoad) &&
                                (preloadElems[0] || (!elemExpandVal && ((eLbottom || eLright || eLleft || eLtop) || lazyloadElems[i][_getAttribute](lazySizesConfig.sizesAttr) != 'auto')))){
                                autoLoadElem = preloadElems[0] || lazyloadElems[i];

          Consider simplifying this complex logical expression.
          Open

                              if ((eLbottom = rect.bottom) >= elemNegativeExpand &&
                                  (eLtop = rect.top) <= elvH &&
                                  (eLright = rect.right) >= elemNegativeExpand * hFac &&
                                  (eLleft = rect.left) <= eLvW &&
                                  (eLbottom || eLright || eLleft || eLtop) &&

            Function lazyUnveil has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    var lazyUnveil = rAFIt(function (elem, detail, isAuto, sizes, isImg){
                        var src, srcset, parent, isPicture, event, firesLoad;
            
                        if(!(event = triggerEvent(elem, 'lazybeforeunveil', detail)).defaultPrevented){
            
            

              Function checkElements has 54 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      var checkElements = function() {
                          var eLlen, i, rect, autoLoadElem, loadedSomething, elemExpand, elemNegativeExpand, elemExpandVal, beforeExpandVal;
              
                          var lazyloadElems = lazysizes.elements;
              
              

                Function autoSizer has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    var autoSizer = (function(){
                        var autosizesElems;
                
                        var sizeElement = rAFIt(function(elem, parent, event, width){
                            var sources, i, len;

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

                      var throttle = function(fn){
                          var running;
                          var lastTime = 0;
                          var gDelay = lazySizesConfig.throttleDelay;
                          var rICTimeout = lazySizesConfig.ricTimeout;

                    Consider simplifying this complex logical expression.
                    Open

                                if( (isAuto || !isCompleted) && isImg && (elem[_getAttribute]('src') || elem.srcset) && !elem.complete && !hasClass(elem, lazySizesConfig.errorClass) && hasClass(elem, lazySizesConfig.lazyClass)){return;}

                      Function _ has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                                  _: function(){
                                      started = Date.now();
                      
                                      lazysizes.elements = document.getElementsByClassName(lazySizesConfig.lazyClass);
                                      preloadElems = document.getElementsByClassName(lazySizesConfig.lazyClass + ' ' + lazySizesConfig.preloadClass);

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

                            var rAF = (function(){
                                var running, waiting;
                                var firstFns = [];
                                var secondFns = [];
                                var fns = firstFns;

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

                                  var lazyUnveil = rAFIt(function (elem, detail, isAuto, sizes, isImg){

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

                                var triggerEvent = function(elem, name, detail, noBubbles, noCancelable){

                              There are no issues that match your filters.

                              Category
                              Status