wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    this.settingsFieldset = new OO.ui.FieldsetLayout( {
        label: ve.msg( 'visualeditor-dialog-meta-settings-label' ),
        icon: 'pageSettings'
    } );
Severity: Minor
Found in modules/ve-mw/ui/pages/ve.ui.MWSettingsPage.js and 1 other location - About 30 mins to fix
modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js on lines 28..31

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 45.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

ve.init.mw.ArticleTarget.prototype.setDefaultMode = function () {
    const oldDefaultMode = this.defaultMode;
    // Parent method
    ve.init.mw.ArticleTarget.super.prototype.setDefaultMode.apply( this, arguments );

Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWMediaDialog.prototype.initialize = function () {
    // Parent method
    ve.ui.MWMediaDialog.super.prototype.initialize.call( this );

    // Main layout
Severity: Minor
Found in modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.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 maybeShowMetaDialog has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.DesktopArticleTarget.prototype.maybeShowMetaDialog = function () {
    if ( this.welcomeDialogPromise ) {
        // Pop out the notices when the welcome dialog is closed
        this.welcomeDialogPromise
            .always( () => {
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.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 switchToWikitextEditor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.ArticleTarget.prototype.switchToWikitextEditor = function ( modified ) {
    // When switching with changes we always pass the full page as changes in visual section mode
    // can still affect the whole document (e.g. removing a reference)
    if ( modified ) {
        this.section = null;
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.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 onPositionCheckboxChange has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWMediaDialog.prototype.onPositionCheckboxChange = function ( isSelected ) {
    const currentModelAlignment = this.imageModel.getAlignment();

    this.positionSelect.setDisabled( !isSelected );
    this.checkChanged();
Severity: Minor
Found in modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.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 onSaveDialogReview has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.ArticleTarget.prototype.onSaveDialogReview = function () {
    if ( !this.saveDialog.hasDiff ) {
        this.emit( 'saveReview' );
        this.saveDialog.pushPending();
        // Acquire a temporary user username before diffing, so that signatures and
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.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 getSectionHashFromPage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.ArticleTarget.prototype.getSectionHashFromPage = function () {
    // Assume there are section edit links, as the user just did a section edit. This also means
    // that the section numbers line up correctly, as not every H_ tag is a numbered section.
    const $sections = this.$editableContent.find( '.mw-editsection' );

Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.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 refreshControls has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.refreshControls = function () {
    const partId = this.getSelectedTopLevelPartId(),
        canBeDeleted = !!partId;

    let canMoveUp, canMoveDown = false;
Severity: Minor
Found in modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.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 resetCaption has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWMediaDialog.prototype.resetCaption = function () {
    const doc = this.getFragment().getDocument();

    // Get existing caption. We only do this in setup, because the caption
    // should not reset to original if the image is replaced or edited.
Severity: Minor
Found in modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.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 afterActivate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.DesktopArticleTarget.prototype.afterActivate = function () {
    $( 'html' ).removeClass( 've-activating' ).addClass( 've-active' );

    // Disable TemplateStyles in the original content
    // (We do this here because toggling 've-active' class above hides it)
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.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 setupSkinTabs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.DesktopArticleTarget.prototype.setupSkinTabs = function () {
    if ( this.isViewPage ) {
        const namespaceNumber = mw.config.get( 'wgNamespaceNumber' );
        const namespaceName = mw.config.get( 'wgCanonicalNamespace' );
        const isTalkNamespace = mw.Title.isTalkNamespace( namespaceNumber );
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.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 getSetupProcess has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWAlienExtensionInspector.prototype.getSetupProcess = function ( data ) {
    return ve.ui.MWAlienExtensionInspector.super.prototype.getSetupProcess.call( this, data )
        .next( () => {
            const attributes = this.selectedNode.getAttribute( 'mw' ).attrs;

Severity: Minor
Found in modules/ve-mw/ui/inspectors/ve.ui.MWAlienExtensionInspector.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 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 updateSize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWExpandableContentElement.prototype.updateSize = function () {
    this.toggle( true );

    if ( Math.floor( this.calculateCurrentTextHeight() / this.getLineHeight() ) > 3 ) {
        if ( !this.$container ) {
Severity: Minor
Found in modules/ve-mw/ui/elements/ve.ui.MWExpandableContentElement.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 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 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

Severity
Category
Status
Source
Language