hakimel/reveal.js

View on GitHub
js/controllers/autoanimate.js

Summary

Maintainability
F
3 days
Test Coverage

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

    autoAnimateElements( from, to, elementOptions, animationOptions, id ) {

        // 'from' elements are given a data-auto-animate-target with no value,
        // 'to' elements are are given a data-auto-animate-target with an ID
        from.dataset.autoAnimateTarget = '';
Severity: Minor
Found in js/controllers/autoanimate.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

File autoanimate.js has 329 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { queryAll, extend, createStyleSheet, matches, closest } from '../utils/util.js'
import { FRAGMENT_STYLE_REGEX } from '../utils/constants.js'

// Counter used to generate unique IDs for auto-animated elements
let autoAnimateCounter = 0;
Severity: Minor
Found in js/controllers/autoanimate.js - About 3 hrs to fix

    Function autoAnimateElements has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        autoAnimateElements( from, to, elementOptions, animationOptions, id ) {
    
            // 'from' elements are given a data-auto-animate-target with no value,
            // 'to' elements are are given a data-auto-animate-target with an ID
            from.dataset.autoAnimateTarget = '';
    Severity: Major
    Found in js/controllers/autoanimate.js - About 2 hrs to fix

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

          getAutoAnimatableProperties( direction, element, elementOptions ) {
      
              let config = this.Reveal.getConfig();
      
              let properties = { styles: [] };
      Severity: Minor
      Found in js/controllers/autoanimate.js - About 1 hr to fix

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

            run( fromSlide, toSlide ) {
        
                // Clean up after prior animations
                this.reset();
        
        
        Severity: Minor
        Found in js/controllers/autoanimate.js - About 1 hr to fix

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

              run( fromSlide, toSlide ) {
          
                  // Clean up after prior animations
                  this.reset();
          
          
          Severity: Minor
          Found in js/controllers/autoanimate.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 getAutoAnimatePairs has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              getAutoAnimatePairs( fromSlide, toSlide ) {
          
                  let pairs = [];
          
                  const codeNodes = 'pre';
          Severity: Minor
          Found in js/controllers/autoanimate.js - About 1 hr to fix

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

                findAutoAnimateMatches( pairs, fromScope, toScope, selector, serializer, animationOptions ) {
            
                    let fromMatches = {};
                    let toMatches = {};
            
            
            Severity: Minor
            Found in js/controllers/autoanimate.js - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                      if( fromSlide && toSlide && fromSlide.hasAttribute( 'data-auto-animate' ) && toSlide.hasAttribute( 'data-auto-animate' )
                              && fromSlide.getAttribute( 'data-auto-animate-id' ) === toSlide.getAttribute( 'data-auto-animate-id' ) 
                              && !( toSlideIndex > fromSlideIndex ? toSlide : fromSlide ).hasAttribute( 'data-auto-animate-restart' ) ) {
              
                          // Create a new auto-animate sheet
              Severity: Critical
              Found in js/controllers/autoanimate.js - About 1 hr to fix

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

                    getAutoAnimatableProperties( direction, element, elementOptions ) {
                
                        let config = this.Reveal.getConfig();
                
                        let properties = { styles: [] };
                Severity: Minor
                Found in js/controllers/autoanimate.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

                Consider simplifying this complex logical expression.
                Open

                        if( elementOptions.translate !== false || elementOptions.scale !== false ) {
                
                            let presentationScale = this.Reveal.getScale();
                
                            let delta = {
                Severity: Major
                Found in js/controllers/autoanimate.js - About 40 mins to fix

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

                      getAutoAnimateOptions( element, inheritedOptions ) {
                  
                          let options = {
                              easing: this.Reveal.getConfig().autoAnimateEasing,
                              duration: this.Reveal.getConfig().autoAnimateDuration,
                  Severity: Minor
                  Found in js/controllers/autoanimate.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

                              let toCSS = Object.keys( toProps.styles ).map( propertyName => {
                                  return propertyName + ': ' + toProps.styles[propertyName] + ' !important;';
                              } ).join( '' );
                  Severity: Major
                  Found in js/controllers/autoanimate.js and 1 other location - About 1 hr to fix
                  js/controllers/autoanimate.js on lines 284..286

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

                  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

                              let fromCSS = Object.keys( fromProps.styles ).map( propertyName => {
                                  return propertyName + ': ' + fromProps.styles[propertyName] + ' !important;';
                              } ).join( '' );
                  Severity: Major
                  Found in js/controllers/autoanimate.js and 1 other location - About 1 hr to fix
                  js/controllers/autoanimate.js on lines 288..290

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

                  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