hakimel/reveal.js

View on GitHub

Showing 210 of 210 total issues

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

Avoid deeply nested control flow statements.
Open

                else if( i === index && config.fragments ) {
                    if( loopedForwards ) {
                        hideFragmentsIn( element );
                    }
                    else if( loopedBackwards ) {
Severity: Major
Found in js/reveal.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if( config.navigationMode === 'linear' ) {
                            if( config.rtl ) {
                                this.Reveal.prev();
                            }
                            else {
    Severity: Major
    Found in js/controllers/touch.js - About 45 mins 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( slide.classList.contains( 'stack' ) ) {
                                    slide.style.top = 0;
                                }
                                else {
                                    slide.style.top = Math.max( ( size.height - slide.scrollHeight ) / 2, 0 ) + 'px';
        Severity: Major
        Found in js/reveal.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

                            if( event.shiftKey ) {
                                this.Reveal.slide( undefined, 0 );
                            }
                            else if( !this.Reveal.overview.isActive() && useLinearMode ) {
                                this.Reveal.prev({skipFragments: event.altKey});
            Severity: Major
            Found in js/controllers/keyboard.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if( config.fragments ) {
                                      // Hide all fragments in future slides
                                      hideFragmentsIn( element );
                                  }
              Severity: Major
              Found in js/reveal.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if ( typeof aPreviousChildElement.setAttribute === 'function' && aPreviousChildElement.tagName !== "BR" ) {
                                            previousParentElement = aPreviousChildElement;
                                            break;
                                        }
                Severity: Major
                Found in plugin/markdown/plugin.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              else if( keyCode === 74 || keyCode === 40 ) {
                                  if( event.shiftKey ) {
                                      this.Reveal.slide( undefined, Number.MAX_VALUE );
                                  }
                                  else if( !this.Reveal.overview.isActive() && useLinearMode ) {
                  Severity: Major
                  Found in js/controllers/keyboard.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if( distanceX + distanceY < viewDistance ) {
                                                slideContent.load( verticalSlide );
                                            }
                                            else {
                                                slideContent.unload( verticalSlide );
                    Severity: Major
                    Found in js/reveal.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if( config.rtl ) {
                                                  this.Reveal.next();
                                              }
                                              else {
                                                  this.Reveal.prev();
                      Severity: Major
                      Found in js/controllers/touch.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

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

                          export const MathJax2 = () => {
                          
                              // The reveal.js instance this plugin is attached to
                              let deck;
                          
                          
                          Severity: Minor
                          Found in plugin/math/mathjax2.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

                          Avoid deeply nested control flow statements.
                          Open

                                          else if( deltaY > SWIPE_THRESHOLD && availableRoutes.up ) {
                                              this.touchCaptured = true;
                                              if( config.navigationMode === 'linear' ) {
                                                  this.Reveal.prev();
                                              }
                          Severity: Major
                          Found in js/controllers/touch.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if( config.rtl ) {
                                                    this.Reveal.prev({skipFragments: event.altKey});
                                                }
                                                else {
                                                    this.Reveal.next({skipFragments: event.altKey});
                            Severity: Major
                            Found in js/controllers/keyboard.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( autoSlide && (el.duration * 1000 / el.playbackRate ) > autoSlide ) {
                                                                autoSlide = ( el.duration * 1000 / el.playbackRate ) + 1000;
                                                            }
                                Severity: Major
                                Found in js/reveal.js - About 45 mins to fix

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

                                                              section.outerHTML = slidify( xhr.responseText, {
                                                                  separator: section.getAttribute( 'data-separator' ),
                                                                  verticalSeparator: section.getAttribute( 'data-separator-vertical' ),
                                                                  notesSeparator: section.getAttribute( 'data-separator-notes' ),
                                                                  attributes: getForwardedAttributes( section )
                                  Severity: Minor
                                  Found in plugin/markdown/plugin.js and 1 other location - About 45 mins to fix
                                  plugin/markdown/plugin.js on lines 244..249

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

                                  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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language