wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 438 of 907 total issues

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

ve.ui.MWLanguageVariantNodeContextItem.prototype.renderBody = function () {
    const $body = this.$body,
        $table = $( '<table>' ),
        $header = $( '<tr>' ),
        variantInfo = this.model.getVariantInfo(),
Severity: Minor
Found in modules/ve-mw/ui/contextitems/ve.ui.MWLanguageVariantNodeContextItem.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

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

ve.ui.MWEducationPopupWidget = function VeUiMwEducationPopup( $target, config ) {
    config = config || {};

    // HACK: Do not display on platforms other than desktop
    if ( !( ve.init.mw.DesktopArticleTarget && ve.init.target instanceof ve.init.mw.DesktopArticleTarget ) ) {
Severity: Minor
Found in modules/ve-mw/ui/widgets/ve.ui.MWEducationPopupWidget.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

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

ve.dm.MWMagicLinkNode.static.matchFunction = function ( element ) {
    const children = element.childNodes,
        href = element.getAttribute( 'href' );
    // All children must be text nodes, or a <span> representing an entity.
    for ( let i = 0; i < children.length; i++ ) {
Severity: Minor
Found in modules/ve-mw/dm/nodes/ve.dm.MWMagicLinkNode.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

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

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

ve.dm.MWCategoryMetaItem.static.toDomElements = function ( dataElement, doc, converter ) {
    let domElement;
    const category = dataElement.attributes.category || '';
    if ( converter.isForPreview() ) {
        domElement = doc.createElement( 'a' );
Severity: Minor
Found in modules/ve-mw/dm/metaitems/ve.dm.MWCategoryMetaItem.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

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

ve.dm.MWWikitextSurfaceFragment.prototype.hasMatchingAncestor = function ( type, attributes ) {
    const nodes = this.getSelectedLeafNodes();

    let all = !!nodes.length;
    for ( let i = 0, len = nodes.length; i < len; i++ ) {
Severity: Minor
Found in modules/ve-mw/dm/ve.dm.MWWikitextSurfaceFragment.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

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

ve.ui.MWSaveDialog.prototype.positionDiffElement = function () {
    if ( this.panels.getCurrentItem() === this.reviewPanel ) {
        setTimeout( () => {
            this.withoutSizeTransitions( () => {
                // This is delayed, so check the visual diff is still visible
Severity: Minor
Found in modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.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

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

ve.dm.MWExtensionNode.static.toDomElements = function ( dataElement, doc, converter ) {
    const originalMw = dataElement.attributes.originalMw;

    let els;
    // If the transclusion is unchanged just send back the
Severity: Minor
Found in modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.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

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

ve.ui.MWCategoryWidget.prototype.queryCategoryStatus = function ( categoryNames ) {
    // Get rid of any we already know the hidden status of, or have an entry
    // if normalizedTitles (i.e. have been fetched before)
    const categoryNamesToQuery = categoryNames.filter( ( name ) => {
        if ( this.normalizedTitles[ name ] ) {
Severity: Minor
Found in modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.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

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

ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.setActiveParameter = function ( paramName ) {
    // Note: We know unnamed parameter placeholders never have an item here
    const newItem = paramName ? this.findItemFromData( paramName ) : null;
    // Unhighlight when called with no parameter name
    this.highlightItem( newItem );

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 getDefaultDir has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ve.dm.MWImageModel.prototype.getDefaultDir = function ( imageNodeType ) {
    imageNodeType = imageNodeType || this.getImageNodeType();

    if ( this.parentDoc.getDir() === 'rtl' ) {
        // Assume position is 'left'
Severity: Minor
Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.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

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

ve.dm.MWImageModel.prototype.updateScalableDetails = function ( originalDimensions ) {
    let newDimensions;

    // Resize the new image's current dimensions to default or based on the bounding box
    if ( this.isDefaultSize() ) {
Severity: Minor
Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.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

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

mw.libs.ve.SwitchPopupWidget = function MWLibsVESwitchPopupWidget( mode, config ) {
    const prefix = mode === 'visual' ? 'visualeditor-mweditmodewt' : 'visualeditor-mweditmodeve',
        option = mode === 'visual' ? 'visualeditor-hidevisualswitchpopup' : 'visualeditor-hidesourceswitchpopup';

    // Parent constructor
Severity: Minor
Found in modules/ve-mw/preinit/ve.init.MWVESwitchPopupWidget.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

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

    public function onGetPreferences( $user, &$preferences ) {
        $services = MediaWikiServices::getInstance();
        $userOptionsLookup = $services->getUserOptionsLookup();
        $veConfig = $services->getConfigFactory()->makeConfig( 'visualeditor' );
        $isBeta = $veConfig->get( 'VisualEditorEnableBetaFeature' );
Severity: Minor
Found in includes/Hooks.php - 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

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

    public function getMessages() {
        $messages = parent::getMessages();
        $services = MediaWikiServices::getInstance();

        $veConfig = $services->getConfigFactory()->makeConfig( 'visualeditor' );
Severity: Minor
Found in includes/VisualEditorDesktopArticleTargetInitModule.php - 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

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

    private static function isSupportedEditPage( Title $title, User $user, WebRequest $req ) {
        if (
            $req->getVal( 'action' ) !== 'edit' ||
            !MediaWikiServices::getInstance()->getPermissionManager()->quickUserCan( 'edit', $user, $title )
        ) {
Severity: Minor
Found in includes/Hooks.php - 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

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

ve.dm.MWImageNode.static.scaleToThumbnailSize = function ( dimensions, mediaType ) {
    const defaultThumbSize = mw.config.get( 'wgVisualEditorConfig' )
        .thumbLimits[ mw.user.options.get( 'thumbsize' ) ];

    mediaType = mediaType || 'BITMAP';
Severity: Minor
Found in modules/ve-mw/dm/nodes/ve.dm.MWImageNode.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

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

ve.ce.MWBlockImageNode.prototype.getCssClass = function ( type, alignment ) {
    // TODO use this.model.getAttribute( 'type' ) etc., see T54065
    // Default is different between RTL and LTR wikis:
    if ( type === 'default' && alignment === 'default' ) {
        if ( this.getModel().getDocument().getDir() === 'rtl' ) {
Severity: Minor
Found in modules/ve-mw/ce/nodes/ve.ce.MWBlockImageNode.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

Severity
Category
Status
Source
Language