hakimel/reveal.js

View on GitHub
plugin/highlight/plugin.js

Summary

Maintainability
C
1 day
Test Coverage

Function highlightBlock has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    highlightBlock: function( block ) {

        hljs.highlightElement( block );

        // Don't generate line numbers for empty code blocks
Severity: Minor
Found in plugin/highlight/plugin.js - About 1 hr to fix

    Function highlightBlock has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        highlightBlock: function( block ) {
    
            hljs.highlightElement( block );
    
            // Don't generate line numbers for empty code blocks
    Severity: Minor
    Found in plugin/highlight/plugin.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 init has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        init: function( reveal ) {
    
            // Read the plugin config options and provide fallbacks
            let config = reveal.getConfig().highlight || {};
    
    
    Severity: Minor
    Found in plugin/highlight/plugin.js - About 1 hr to fix

      Function betterTrim has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function betterTrim(snippetEl) {
          // Helper functions
          function trimLeft(val) {
              // Adapted from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
              return val.replace(/^[\s\uFEFF\xA0]+/g, '');
      Severity: Minor
      Found in plugin/highlight/plugin.js - About 1 hr to fix

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

            scrollHighlightedLineIntoView: function( block, scrollState, skipAnimation ) {
        
                cancelAnimationFrame( scrollState.animationFrameID );
        
                // Match the scroll position of the currently visible
        Severity: Minor
        Found in plugin/highlight/plugin.js - About 1 hr to fix

          Function betterTrim has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function betterTrim(snippetEl) {
              // Helper functions
              function trimLeft(val) {
                  // Adapted from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
                  return val.replace(/^[\s\uFEFF\xA0]+/g, '');
          Severity: Minor
          Found in plugin/highlight/plugin.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 scrollHighlightedLineIntoView has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              scrollHighlightedLineIntoView: function( block, scrollState, skipAnimation ) {
          
                  cancelAnimationFrame( scrollState.animationFrameID );
          
                  // Match the scroll position of the currently visible
          Severity: Minor
          Found in plugin/highlight/plugin.js - About 55 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

          There are no issues that match your filters.

          Category
          Status