wikimedia/mediawiki-core

View on GitHub

Showing 11,498 of 11,498 total issues

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

    public function __set( $name, $value ) {
        if ( property_exists( get_called_class(), $name ) ) {
            // Direct access to a public property, deprecated.
            wfDeprecatedMsg( "CacheTime::$name public write access deprecated", '1.38' );
            $this->$name = $value;
Severity: Minor
Found in includes/parser/CacheTime.php and 1 other location - About 30 mins to fix
includes/parser/ParserOutput.php on lines 3020..3030

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

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

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

    public function __set( $name, $value ) {
        if ( property_exists( get_called_class(), $name ) ) {
            // Direct access to a public property, deprecated.
            wfDeprecatedMsg( "ParserOutput::$name public write access deprecated", '1.38' );
            $this->$name = $value;
Severity: Minor
Found in includes/parser/ParserOutput.php and 1 other location - About 30 mins to fix
includes/parser/CacheTime.php on lines 317..327

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

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

function HtmlEmitter( language, magic ) {
    var jmsg = this;
    this.language = language;
    Object.keys( magic || {} ).forEach( ( key ) => {
        var val = magic[ key ];
Severity: Minor
Found in resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.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 set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    set: function ( key, value, options ) {
        var prefix, date;

        // The 'options' parameter may be a shortcut for the expiry.
        if ( arguments.length > 2 && ( !options || options instanceof Date || typeof options === 'number' ) ) {
Severity: Minor
Found in resources/src/mediawiki.cookie/index.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 setExpires has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

SafeStorage.prototype.setExpires = function ( key, expiry ) {
    if ( expiry ) {
        try {
            this.store.setItem(
                EXPIRY_PREFIX + key,
Severity: Minor
Found in resources/src/mediawiki.storage/SafeStorage.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 OptionalParamWidget has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function OptionalParamWidget( widget, config ) {
    var k;

    config = config || {};

Severity: Minor
Found in resources/src/mediawiki.special.apisandbox/OptionalParamWidget.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 sanitize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    sanitize = function ( s, filter ) {
        const rules = sanitationRules;

        for ( let i = 0, ruleLength = rules.length; i < ruleLength; ++i ) {
            const rule = rules[ i ];
Severity: Minor
Found in resources/src/mediawiki.Title/Title.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 loadSearchModule has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function loadSearchModule( moduleName ) {
    // T251544: Collect search performance metrics to compare Vue search with
    // mediawiki.searchSuggest performance. Marks and Measures will only be
    // recorded on the Vector skin.
    //
Severity: Minor
Found in resources/src/mediawiki.page.ready/ready.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 MwRcfiltersUiMenuSelectWidget has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

MenuSelectWidget = function MwRcfiltersUiMenuSelectWidget( controller, model, config ) {
    var header;

    config = config || {};

Severity: Minor
Found in resources/src/mediawiki.rcfilters/ui/MenuSelectWidget.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 MwRcfiltersUiItemMenuOptionWidget has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ItemMenuOptionWidget = function MwRcfiltersUiItemMenuOptionWidget(
    controller, filtersViewModel, invertModel, itemModel, highlightPopup, config
) {
    var layout,
        $widgetRow,
Severity: Minor
Found in resources/src/mediawiki.rcfilters/ui/ItemMenuOptionWidget.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 upgradeDatabase has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function upgradeDatabase( versionChangeEvent ) {
    const keyPathParts = [ 'pageName', 'section' ];
    var objectStore;

    db = versionChangeEvent.target.result;
Severity: Minor
Found in resources/src/mediawiki.editRecovery/storage.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 toggleDefault has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

SavedLinksListItemWidget.prototype.toggleDefault = function ( isDefault ) {
    isDefault = isDefault === undefined ? !this.default : isDefault;

    if ( this.default !== isDefault ) {
        this.default = isDefault;
Severity: Minor
Found in resources/src/mediawiki.rcfilters/ui/SavedLinksListItemWidget.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 getLabelMessageKey has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

ItemModel.prototype.getLabelMessageKey = function ( inverted ) {
    if ( this.labelPrefixKey ) {
        if ( typeof this.labelPrefixKey === 'string' ) {
            return this.labelPrefixKey;
        }
Severity: Minor
Found in resources/src/mediawiki.rcfilters/dm/ItemModel.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 MwWidgetsTableWidgetModel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

mw.widgets.TableWidgetModel = function MwWidgetsTableWidgetModel( config ) {
    config = config || {};

    // Mixin constructors
    OO.EventEmitter.call( this, config );
Severity: Minor
Found in resources/src/mediawiki.widgets/Table/mw.widgets.TableWidgetModel.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 MwWidgetsRowWidgetModel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

mw.widgets.RowWidgetModel = function MwWidgetsRowWidgetModel( config ) {
    config = config || {};

    // Mixin constructors
    OO.EventEmitter.call( this, config );
Severity: Minor
Found in resources/src/mediawiki.widgets/Table/mw.widgets.RowWidgetModel.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 getActionProcess has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

FeedbackDialog.prototype.getActionProcess = function ( action ) {
    if ( action === 'cancel' ) {
        return new OO.ui.Process( function () {
            this.close( { action: action } );
        }, this );
Severity: Minor
Found in resources/src/mediawiki.feedback/FeedbackDialog.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 refreshTableMarginals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

mw.widgets.TableWidget.prototype.refreshTableMarginals = function () {
    const tableProps = this.model.getTableProperties(),
        columnProps = this.model.getAllColumnProperties();

    if ( tableProps.showHeaders ) {
Severity: Minor
Found in resources/src/mediawiki.widgets/Table/mw.widgets.TableWidget.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 setValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

mw.widgets.TableWidgetModel.prototype.setValue = function ( row, col, value ) {
    let rowIndex, colIndex;

    if ( typeof row === 'number' ) {
        rowIndex = row;
Severity: Minor
Found in resources/src/mediawiki.widgets/Table/mw.widgets.TableWidgetModel.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 insertColumn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

mw.widgets.TableWidgetModel.prototype.insertColumn = function ( data, index, key, label ) {
    const insertIndex = ( typeof index === 'number' ) ? index : this.cols.length;

    // Add the new column metadata
    this.cols.splice( insertIndex, 0, {
Severity: Minor
Found in resources/src/mediawiki.widgets/Table/mw.widgets.TableWidgetModel.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 initializeProps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

mw.widgets.TableWidgetModel.prototype.initializeProps = function ( rowProps, colProps ) {
    // FIXME: Account for extra data with missing row/col metadata

    let i, len;

Severity: Minor
Found in resources/src/mediawiki.widgets/Table/mw.widgets.TableWidgetModel.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