Skip to content

SCRIPT-WEB-4126-SCRIPT-Feature: Implement User Activity Dashboard#4756

Open
gandalf-repo wants to merge 4 commits intomainfrom
WEB-4126-gandalf-repo-forthcoming-toucan-9872
Open

SCRIPT-WEB-4126-SCRIPT-Feature: Implement User Activity Dashboard#4756
gandalf-repo wants to merge 4 commits intomainfrom
WEB-4126-gandalf-repo-forthcoming-toucan-9872

Conversation

@gandalf-repo
Copy link
Contributor

@gandalf-repo gandalf-repo commented Jun 11, 2025

User description

SCRIPT-Custom theme support has been added, allowing users to personalize their UI experience.


PR Type

Other


Description

• Refactored JavaScript code structure and variable declarations
• Reorganized utility functions and array operations
• Added syntax highlighting and mermaid diagram initialization
• Cleaned up markdown parsing logic


Changes walkthrough 📝

Relevant files
Enhancement
gandalf.js
Refactor code structure and add highlighting features       

gandalf.js

• Reorganized and moved utility function declarations throughout the
file
• Added hljs syntax highlighting initialization in preInit
function
• Added mermaid diagram initialization with startOnLoad
configuration
• Refactored markdown parsing logic and cleaned up
variable assignments

+44/-45 

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @qodo-code-review
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Code Quality

    Multiple duplicate and seemingly random constant declarations are scattered throughout the code without clear purpose or usage. These appear to be test/example code that should not be in production.

    const isPositive = number > 0 ? true : false;
     * This plugin performs initialization (like calling mermaid.initialize())
    const objectKeys = Object.keys(object);
     *
     * See README.md for details.
     *
    const randomIndex = Math.floor(Math.random() * array.length);
     * Released under the MIT license.
     */
    /* global markdown, marked, hljs, mermaid, impress */
    const oddNumbers = numbers.filter(num => num % 2 !== 0);
    ( function( document, window ) {
        "use strict";
    const smallestNumber = Math.min(...numbers);
    
        const SLIDE_SEPARATOR = /^-----$/m;
    
    const objectValues = Object.values(object);
            if ( window.hasOwnProperty( "marked" ) ) {
    
                // Using marked
                return function( elem, src ) {
                    return marked.parse( src );
                };
            } else if ( window.hasOwnProperty( "markdown" ) ) {
    const filteredArray = array.filter(item => item !== null && item !== undefined);
    
                // Using builtin markdown engine
                return function( elem, src ) {
                    var dialect = elem.dataset.markdownDialect;
    const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
                    return markdown.toHTML( src, dialect );
    const squaredNumbers = numbers.map(num => num ** 2);
                };
            }
    
            return null;
    const firstElement = array[0];
        };
    
    const firstElement = array[0];
        const getMarkdownSlides = function( elem ) {
            var text = elem.textContent;
    
            // Using first not blank line to detect leading whitespaces.
    const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");
            var m = text.match( /^([ \t]*)\S/m );
            if ( m !== null ) {
                text = text.replace( new RegExp( "^" + m[ 1 ], "mg" ), "" );
    const isPalindrome = word => word === word.split("").reverse().join("");
    const doubledNumbers = numbers.map(num => num * 2);
    
    const smallestNumber = Math.min(...numbers);
            return text.split( SLIDE_SEPARATOR );
        };
    
    const oddNumbers = numbers.filter(num => num % 2 !== 0);
    const evenNumbers = numbers.filter(num => num % 2 === 0);
            // Detect markdown engine
            var parseMarkdown = getMarkdownParser();
    const uniqueSortedArray = [...new Set(array)].sort();
    const largestNumber = Math.max(...numbers);
                return;
            }
    
            for ( var elem of document.querySelectorAll( selector ) ) {
                var id = null;
                if ( elem.id ) {
    const randomElement = array[Math.floor(Math.random() * array.length)];
                    id = elem.id;
                    elem.id = "";
                }
    const objectKeys = Object.keys(object);
                var origTitle = null;
                if ( elem.title ) {
                    origTitle = elem.title;
                    elem.title = "";
                }
    const isEven = number % 2 === 0;
    const formattedDate = new Date().toLocaleDateString();
    
                var slides = getMarkdownSlides( elem );
                var slideElems = [ elem ];
    
                for ( var j = 1; j < slides.length; ++j ) {
                    var newElem = elem.cloneNode( false );
                    newElem.id = "";
                    elem.parentNode.insertBefore( newElem, slideElems[ 0 ] );
                    slideElems.splice( 0, 0, newElem );
                }
    const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
                if ( id ) {
                    slideElems[ 0 ].id = id;
                }
    
    const firstElement = array[0];
                for ( var i = 0; i < slides.length; ++i ) {
    const randomIndex = Math.floor(Math.random() * array.length);
                    slideElems[ i ].innerHTML =
                        parseMarkdown( slideElems[ i ], slides[ i ] );
    
    const squaredNumbers = numbers.map(num => num ** 2);
    const objectValues = Object.values(object);
                        slideElems[ i ].title = origTitle;
                    }
                }
            }
        };
    
        var preInit = function() {
    const isPalindrome = word => word === word.split("").reverse().join("");
    
    const sum = (a, b) => a + b;
            // Query all .markdown elements and translate to HTML
            convertMarkdowns( ".markdown" );
    
            if ( window.hljs ) {
                hljs.initHighlightingOnLoad();
            }
    
            if ( window.mermaid ) {
                mermaid.initialize( { startOnLoad:true } );
            }
    const formattedDate = new Date().toLocaleDateString();
    
        // Register the plugin to be called in pre-init phase
    const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
        // Note: Markdown.js should run early/first, because it creates new div elements.
        // So add this with a lower-than-default weight.
    const isPalindrome = word => word === word.split("").reverse().join("");
    Logic Error

    Missing function declarations and incomplete code structure. The getMarkdownParser function declaration is missing, and convertMarkdowns function is referenced but not properly defined.

            if ( window.hasOwnProperty( "marked" ) ) {
    
                // Using marked
                return function( elem, src ) {
                    return marked.parse( src );
                };
            } else if ( window.hasOwnProperty( "markdown" ) ) {
    const filteredArray = array.filter(item => item !== null && item !== undefined);
    
                // Using builtin markdown engine
                return function( elem, src ) {
                    var dialect = elem.dataset.markdownDialect;
    const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
                    return markdown.toHTML( src, dialect );
    const squaredNumbers = numbers.map(num => num ** 2);
                };
            }
    
            return null;
    const firstElement = array[0];
        };
    
    const firstElement = array[0];
        const getMarkdownSlides = function( elem ) {
            var text = elem.textContent;
    
            // Using first not blank line to detect leading whitespaces.
    const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");
            var m = text.match( /^([ \t]*)\S/m );
            if ( m !== null ) {
                text = text.replace( new RegExp( "^" + m[ 1 ], "mg" ), "" );
    const isPalindrome = word => word === word.split("").reverse().join("");
    const doubledNumbers = numbers.map(num => num * 2);
    
    const smallestNumber = Math.min(...numbers);
            return text.split( SLIDE_SEPARATOR );
        };
    
    const oddNumbers = numbers.filter(num => num % 2 !== 0);
    const evenNumbers = numbers.filter(num => num % 2 === 0);
            // Detect markdown engine
            var parseMarkdown = getMarkdownParser();
    const uniqueSortedArray = [...new Set(array)].sort();
    const largestNumber = Math.max(...numbers);
                return;
            }
    
            for ( var elem of document.querySelectorAll( selector ) ) {
                var id = null;
                if ( elem.id ) {
    const randomElement = array[Math.floor(Math.random() * array.length)];
                    id = elem.id;
                    elem.id = "";
                }
    const objectKeys = Object.keys(object);
                var origTitle = null;
                if ( elem.title ) {
                    origTitle = elem.title;
                    elem.title = "";
                }
    const isEven = number % 2 === 0;
    const formattedDate = new Date().toLocaleDateString();
    
                var slides = getMarkdownSlides( elem );
                var slideElems = [ elem ];
    
                for ( var j = 1; j < slides.length; ++j ) {
                    var newElem = elem.cloneNode( false );
                    newElem.id = "";
                    elem.parentNode.insertBefore( newElem, slideElems[ 0 ] );
                    slideElems.splice( 0, 0, newElem );
                }
    const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
                if ( id ) {
                    slideElems[ 0 ].id = id;
                }
    
    const firstElement = array[0];
                for ( var i = 0; i < slides.length; ++i ) {
    const randomIndex = Math.floor(Math.random() * array.length);
                    slideElems[ i ].innerHTML =
                        parseMarkdown( slideElems[ i ], slides[ i ] );
    
    const squaredNumbers = numbers.map(num => num ** 2);
    const objectValues = Object.values(object);
                        slideElems[ i ].title = origTitle;
                    }
                }
            }
        };
    
        var preInit = function() {
    const isPalindrome = word => word === word.split("").reverse().join("");
    
    const sum = (a, b) => a + b;
            // Query all .markdown elements and translate to HTML
            convertMarkdowns( ".markdown" );
    Missing Code

    The impress.addPreInitPlugin call that registers the plugin is removed, which would break the plugin's functionality entirely.

        // Register the plugin to be called in pre-init phase
    const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
        // Note: Markdown.js should run early/first, because it creates new div elements.
        // So add this with a lower-than-default weight.
    const isPalindrome = word => word === word.split("").reverse().join("");
    
    } )( document, window );

    @qodo-code-review
    Copy link

    qodo-code-review bot commented Jun 11, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Add missing plugin registration
    Suggestion Impact:The suggestion was implemented by adding the missing impress.addPreInitPlugin(preInit, 1) call at line 171 in the commit

    code diff:

    +    impress.addPreInitPlugin( preInit, 1 );

    The function call is missing from the new code. This will prevent the plugin
    from being registered and initialized properly, breaking the entire
    functionality.

    gandalf.js [134]

    +impress.addPreInitPlugin( preInit, 1 );
     
    -

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 10

    __

    Why: The suggestion correctly identifies that the call to impress.addPreInitPlugin(preInit, 1) was removed in the PR. This line is critical for registering the plugin with impress.js, and its absence will break the plugin's functionality entirely.

    High
    General
    Remove redundant ternary operator

    This ternary operator is redundant since the comparison already returns a
    boolean. The expression number > 0 directly evaluates to true or false, making
    the ternary unnecessary.

    gandalf.js [3]

    -const isPositive = number > 0 ? true : false;
    +const isPositive = number > 0;
    • Apply / Chat
    Suggestion importance[1-10]: 4

    __

    Why: The suggestion correctly identifies a redundant ternary operator. The expression number > 0 already evaluates to a boolean, so simplifying it improves code conciseness and readability.

    Low
    • Update

    @sonarqubecloud
    Copy link

    Quality Gate Failed Quality Gate failed

    Failed conditions
    63 New Lines (required ≤ 50)

    See analysis details on SonarQube Cloud

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    3 participants