wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

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 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 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 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 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 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 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 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 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

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 ): bool {
        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

Severity
Category
Status
Source
Language