wikimedia/mediawiki-extensions-VisualEditor

View on GitHub
editcheck/modules/AddReferenceEditCheck.js

Summary

Maintainability
A
3 hrs
Test Coverage

Function act has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

mw.editcheck.AddReferenceEditCheck.prototype.act = function ( choice, action, contextItem ) {
    // The complex citoid workflow means that we can't just count on a single "windowAction" here...
    const windowAction = ve.ui.actionFactory.create( 'window', contextItem.context.getSurface(), 'check' );
    switch ( choice ) {
        case 'accept':
Severity: Minor
Found in editcheck/modules/AddReferenceEditCheck.js - About 1 hr to fix

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

    mw.editcheck.AddReferenceEditCheck.prototype.findAddedContent = function ( documentModel, includeReferencedContent ) {
        // Broken out so a helper for tagging can call it
        const ranges = this.getModifiedContentRanges( documentModel ).filter( ( range ) => {
            if ( !includeReferencedContent ) {
                // 4. Exclude any ranges that already contain references
    Severity: Minor
    Found in editcheck/modules/AddReferenceEditCheck.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

    There are no issues that match your filters.

    Category
    Status