hakimel/reveal.js

View on GitHub
js/controllers/slidecontent.js

Summary

Maintainability
F
3 days
Test Coverage

Function load has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    load( slide, options = {} ) {

        // Show the slide element
        slide.style.display = this.Reveal.getConfig().display;

Severity: Minor
Found in js/controllers/slidecontent.js - About 5 hrs 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 load has 92 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    load( slide, options = {} ) {

        // Show the slide element
        slide.style.display = this.Reveal.getConfig().display;

Severity: Major
Found in js/controllers/slidecontent.js - About 3 hrs to fix

    File slidecontent.js has 273 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { extend, queryAll, closest, getMimeTypeFromFile, encodeRFC3986URI } from '../utils/util.js'
    import { isMobile } from '../utils/device.js'
    
    import fitty from 'fitty';
    
    
    Severity: Minor
    Found in js/controllers/slidecontent.js - About 2 hrs to fix

      Function startEmbeddedContent has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          startEmbeddedContent( element ) {
      
              if( element && !this.Reveal.isSpeakerNotes() ) {
      
                  // Restart GIFs
      Severity: Minor
      Found in js/controllers/slidecontent.js - About 2 hrs to fix

        Function startEmbeddedIframe has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            startEmbeddedIframe( event ) {
        
                let iframe = event.target;
        
                if( iframe && iframe.contentWindow ) {
        Severity: Minor
        Found in js/controllers/slidecontent.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 stopEmbeddedContent has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            stopEmbeddedContent( element, options = {} ) {
        
                options = extend( {
                    // Defaults
                    unloadIframes: true
        Severity: Minor
        Found in js/controllers/slidecontent.js - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                              if( isMobile ) {
                                  video.muted = true;
                                  video.setAttribute( 'playsinline', '' );
                              }
          Severity: Major
          Found in js/controllers/slidecontent.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if( type ) {
                                        sourceElement.setAttribute( 'type', type );
                                    }
            Severity: Major
            Found in js/controllers/slidecontent.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                              else if( backgroundIframe && options.excludeIframes !== true ) {
                                  let iframe = document.createElement( 'iframe' );
                                  iframe.setAttribute( 'allowfullscreen', '' );
                                  iframe.setAttribute( 'mozallowfullscreen', '' );
                                  iframe.setAttribute( 'webkitallowfullscreen', '' );
              Severity: Major
              Found in js/controllers/slidecontent.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if( backgroundVideoMuted ) {
                                        video.muted = true;
                                    }
                Severity: Major
                Found in js/controllers/slidecontent.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if( backgroundVideoLoop ) {
                                          video.setAttribute( 'loop', '' );
                                      }
                  Severity: Major
                  Found in js/controllers/slidecontent.js - About 45 mins to fix

                    Function formatEmbeddedContent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        formatEmbeddedContent() {
                    
                            let _appendParamToIframeSource = ( sourceAttribute, sourceURL, param ) => {
                                queryAll( this.Reveal.getSlidesElement(), 'iframe['+ sourceAttribute +'*="'+ sourceURL +'"]' ).forEach( el => {
                                    let src = el.getAttribute( sourceAttribute );
                    Severity: Minor
                    Found in js/controllers/slidecontent.js - About 35 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

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

                                queryAll( element, 'iframe[src*="player.vimeo.com/"]' ).forEach( el => {
                                    if( !el.hasAttribute( 'data-ignore' ) && el.contentWindow && typeof el.contentWindow.postMessage === 'function' ) {
                                        el.contentWindow.postMessage( '{"method":"pause"}', '*' );
                                    }
                                });
                    Severity: Major
                    Found in js/controllers/slidecontent.js and 1 other location - About 2 hrs to fix
                    js/controllers/slidecontent.js on lines 463..467

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

                    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

                                queryAll( element, 'iframe[src*="youtube.com/embed/"]' ).forEach( el => {
                                    if( !el.hasAttribute( 'data-ignore' ) && el.contentWindow && typeof el.contentWindow.postMessage === 'function' ) {
                                        el.contentWindow.postMessage( '{"event":"command","func":"pauseVideo","args":""}', '*' );
                                    }
                                });
                    Severity: Major
                    Found in js/controllers/slidecontent.js and 1 other location - About 2 hrs to fix
                    js/controllers/slidecontent.js on lines 470..474

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

                    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

                            queryAll( slide, 'video[data-lazy-loaded][src], audio[data-lazy-loaded][src], iframe[data-lazy-loaded][src]' ).forEach( element => {
                                element.setAttribute( 'data-src', element.getAttribute( 'src' ) );
                                element.removeAttribute( 'src' );
                            } );
                    Severity: Minor
                    Found in js/controllers/slidecontent.js and 1 other location - About 50 mins to fix
                    js/controllers/slidecontent.js on lines 244..247

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

                    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

                            queryAll( slide, 'video[data-lazy-loaded] source[src], audio source[src]' ).forEach( source => {
                                source.setAttribute( 'data-src', source.getAttribute( 'src' ) );
                                source.removeAttribute( 'src' );
                            } );
                    Severity: Minor
                    Found in js/controllers/slidecontent.js and 1 other location - About 50 mins to fix
                    js/controllers/slidecontent.js on lines 238..241

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

                    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