wikimedia/mediawiki-extensions-VisualEditor

View on GitHub
modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineWidget.js

Summary

Maintainability
A
3 hrs
Test Coverage

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

ve.ui.MWTransclusionOutlineWidget.prototype.addPartWidget = function ( part, newPosition, removed ) {
    const keys = Object.keys( this.partWidgets ),
        onlyPart = keys.length === 1 && this.partWidgets[ keys[ 0 ] ];
    if ( onlyPart instanceof ve.ui.MWTransclusionOutlineTemplateWidget ) {
        // To recalculate the height of the sticky header when we enter multi-part mode
Severity: Minor
Found in modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineWidget.js - About 1 hr to fix

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

    ve.ui.MWTransclusionOutlineWidget.prototype.setSelectionByPageName = function ( pageName ) {
        const selectedPartId = pageName ? pageName.split( '/', 1 )[ 0 ] : null,
            isParameter = pageName ? pageName.length > selectedPartId.length : false;
    
        for ( const partId in this.partWidgets ) {
    Severity: Minor
    Found in modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineWidget.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 addPartWidget has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    ve.ui.MWTransclusionOutlineWidget.prototype.addPartWidget = function ( part, newPosition, removed ) {
        const keys = Object.keys( this.partWidgets ),
            onlyPart = keys.length === 1 && this.partWidgets[ keys[ 0 ] ];
        if ( onlyPart instanceof ve.ui.MWTransclusionOutlineTemplateWidget ) {
            // To recalculate the height of the sticky header when we enter multi-part mode
    Severity: Minor
    Found in modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineWidget.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

    Function findPartIdContainingElement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    ve.ui.MWTransclusionOutlineWidget.prototype.findPartIdContainingElement = function ( element ) {
        if ( element ) {
            for ( const id in this.partWidgets ) {
                const part = this.partWidgets[ id ];
                if ( $.contains( part.$element[ 0 ], element ) ) {
    Severity: Minor
    Found in modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineWidget.js - About 25 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