wikimedia/mediawiki-extensions-VisualEditor

View on GitHub

Showing 912 of 912 total issues

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

ve.ui.MWCategoryWidget.prototype.getCategories = function () {
    return Object.keys( this.categories );
};
Severity: Minor
Found in modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.js and 1 other location - About 35 mins to fix
modules/ve-mw/dm/models/ve.dm.MWTemplateSpecModel.js on lines 446..448

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

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

ve.ui.MWTemplateDialog.prototype.updateTitle = function () {
    let title = ve.msg( 'visualeditor-dialog-transclusion-loading' );

    if ( this.transclusionModel.isSingleTemplate() ) {
        const part = this.transclusionModel.getParts()[ 0 ];
Severity: Minor
Found in modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js - About 35 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 setUserConfig has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.Platform.prototype.setUserConfig = function ( keyOrValueMap, value ) {
    // T214963: Don't try to set user preferences for logged-out users, it doesn't work
    if ( !mw.user.isNamed() ) {
        return false;
    }
Severity: Minor
Found in modules/ve-mw/init/ve.init.mw.Platform.js - About 35 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 onSaveDialogPreview has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.ArticleTarget.prototype.onSaveDialogPreview = function () {
    const api = this.getContentApi();

    if ( !this.saveDialog.$previewViewer.children().length ) {
        this.emit( 'savePreview' );
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 35 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 toggleWrapSelection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWWikitextAction.prototype.toggleWrapSelection = function ( before, after, placeholder, expandOffsetsCallback, unwrapOffsetsCallback ) {
    const originalFragment = this.surface.getModel().getFragment( null, false, true /* excludeInsertions */ );

    let fragment = originalFragment;
    let textBefore, textAfter;
Severity: Minor
Found in modules/ve-mw/ui/actions/ve.ui.MWWikitextAction.js - About 35 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 VeInitMwArticleTarget has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.ArticleTarget = function VeInitMwArticleTarget( config ) {
    config = config || {};
    config.toolbarConfig = ve.extendObject( {
        shadow: true,
        actions: true,
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 35 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 prepareCacheKey has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.init.mw.ArticleTarget.prototype.prepareCacheKey = function ( doc ) {
    const start = ve.now();

    if ( this.getSurface().getMode() === 'source' ) {
        return;
Severity: Minor
Found in modules/ve-mw/init/targets/ve.init.mw.ArticleTarget.js - About 35 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 updateReviewMode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWSaveDialog.prototype.updateReviewMode = function () {
    if ( !this.hasDiff ) {
        return;
    }

Severity: Minor
Found in modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js - About 35 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 onToggle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWCategoryPopupWidget.prototype.onToggle = function ( show ) {
    if ( show ) {
        return;
    }
    const newSortkey = this.sortKeyInput.$input.val();
Severity: Minor
Found in modules/ve-mw/ui/widgets/ve.ui.MWCategoryPopupWidget.js - About 35 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 serialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.dm.MWTemplateModel.prototype.serialize = function () {
    const origData = this.originalData || {},
        origParams = origData.params || {},
        template = { target: this.target, params: {} },
        spec = this.spec,
Severity: Minor
Found in modules/ve-mw/dm/models/ve.dm.MWTemplateModel.js - About 35 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 onParameterAddedToTemplateModel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onParameterAddedToTemplateModel = function ( param ) {
    const paramName = param.getName();
    // The placeholder (currently) doesn't get a corresponding item in the sidebar
    if ( !paramName ) {
        return;
Severity: Minor
Found in modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineTemplateWidget.js - About 35 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 isDefaultAligned has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.dm.MWImageModel.prototype.isDefaultAligned = function ( imageType, align ) {
    const alignment = align || this.getAlignment(),
        defaultAlignment = ( this.parentDoc.getDir() === 'rtl' ) ? 'left' : 'right';

    imageType = imageType || this.getType();
Severity: Minor
Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.js - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
Open

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

    // States
Severity: Minor
Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js - About 35 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 toggleSearchPanel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWGalleryDialog.prototype.toggleSearchPanel = function ( visible ) {
    visible = visible !== undefined ? visible : !this.searchPanelVisible;

    // If currently visible panel is an edit panel, save the input values for the highlighted item
    if ( !this.searchPanelVisible ) {
Severity: Minor
Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js - About 35 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 isHighlightedItemModified has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWGalleryDialog.prototype.isHighlightedItemModified = function () {
    if ( this.highlightedItem ) {
        if ( this.highlightedAltTextInput.getValue() !== this.highlightedItem.altText ) {
            return true;
        }
Severity: Minor
Found in modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js - About 35 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 getValidationErrors has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWAddParameterPage.prototype.getValidationErrors = function ( name ) {
    if ( !name ) {
        return [];
    }

Severity: Minor
Found in modules/ve-mw/ui/pages/ve.ui.MWAddParameterPage.js - About 35 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 getUpdatedAttributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.dm.MWImageModel.prototype.getUpdatedAttributes = function () {
    const origAttrs = this.getOriginalImageAttributes();

    let currentDimensions;
    // Adjust default dimensions if size is set to default
Severity: Minor
Found in modules/ve-mw/dm/models/ve.dm.MWImageModel.js - About 35 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 setup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.ui.MWAdvancedSettingsPage.prototype.setup = function ( fragment, config ) {
    this.fragment = fragment;

    // Indexing items
    const indexingField = this.indexing.getField();
Severity: Minor
Found in modules/ve-mw/ui/pages/ve.ui.MWAdvancedSettingsPage.js - About 35 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 getTablesorterHeaderCells has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

ve.ce.MWTableNode.prototype.getTablesorterHeaderCells = function () {
    const matrix = this.model.getMatrix();

    let longestRow = [];
    let longestRowLength = 0;
Severity: Minor
Found in modules/ve-mw/ce/nodes/ve.ce.MWTableNode.js - About 35 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 canBeShown has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

mw.editcheck.BaseEditCheck.prototype.canBeShown = function () {
    // all checks are only in the main namespace for now
    if ( mw.config.get( 'wgNamespaceNumber' ) !== mw.config.get( 'wgNamespaceIds' )[ '' ] ) {
        return false;
    }
Severity: Minor
Found in editcheck/modules/BaseEditCheck.js - About 35 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