wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

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

            return finishStash( {
                ignorewarnings: false,
                watchlist: ( upload.getWatchlist() ) ? 1 : undefined,
                comment: upload.getComment(),
                filename: upload.getFilename(),
Severity: Major
Found in resources/src/mediawiki.Upload.js and 1 other location - About 5 hrs to fix
resources/src/mediawiki.Upload.js on lines 314..330

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

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

    public function checkSettings( string $name, $settings, array $options ): array {
        $settings = $this->normalizeSettingsInternal( $settings );
        $issues = [];
        $allowedKeys = [
            self::PARAM_TYPE, self::PARAM_DEFAULT, self::PARAM_REQUIRED, self::PARAM_ISMULTI,
Severity: Minor
Found in includes/libs/ParamValidator/ParamValidator.php - About 5 hrs 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 showHistory has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    protected function showHistory() {
        $this->checkReadOnly();

        $out = $this->getOutput();
        if ( $this->mAllowed ) {
Severity: Minor
Found in includes/specials/SpecialUndelete.php - About 5 hrs 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 getCreditsForExtension has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    public function getCreditsForExtension( $type, array $extension ) {
        $out = $this->getOutput();

        // We must obtain the information for all the bits and pieces!
        // ... such as extension names and links
Severity: Minor
Found in includes/specials/SpecialVersion.php - About 5 hrs 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 getParserOutputInternal has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    private function getParserOutputInternal( ParserOptions $parserOptions ): Status {
        // NOTE: ParserOutputAccess::getParserOutput() should be used for revisions
        //       that come from the database. Either this revision is null to indicate
        //       the current revision or the revision must have an ID.
        // If we have a revision and the ID is 0 or null, then it's a fake revision
Severity: Minor
Found in includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php - About 5 hrs 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 wt2html has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    protected function wt2html(
        PageConfig $pageConfig, array $attribs, ?string $wikitext = null
    ) {
        $request = $this->getRequest();
        $opts = $attribs['opts'];
Severity: Minor
Found in includes/Rest/Handler/ParsoidHandler.php - About 5 hrs 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 loadWithArgv has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    public function loadWithArgv( array $argv, int $skip = 0 ) {
        $this->clear();

        $options = [];
        $args = [];
Severity: Minor
Found in maintenance/includes/MaintenanceParameters.php - About 5 hrs 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 handleCategorization has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    public function handleCategorization( IReadableDatabase $dbr, $output ) {
        $processedTitle = [];

        // Categorization change can add new parents and change counts
        // for the parent category.
Severity: Minor
Found in maintenance/categoryChangesAsRdf.php - About 5 hrs 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

File BitmapHandler.php has 399 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Generic handler for bitmap images.
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Minor
Found in includes/media/BitmapHandler.php - About 5 hrs to fix

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

    <?php
    /** Kashmiri (Devanagari script) (कॉशुर)
     *
     * @file
     * @ingroup Languages
    Severity: Major
    Found in languages/messages/MessagesKs_deva.php and 3 other locations - About 5 hrs to fix
    languages/messages/MessagesMni.php on lines 1..38
    languages/messages/MessagesPi.php on lines 1..42
    languages/messages/MessagesSat.php on lines 1..38

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

    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 4 locations. Consider refactoring.
    Open

    <?php
    /** Manipuri/Meitei (ꯃꯤꯇꯩ ꯂꯣꯟ)
     *
     * @file
     * @ingroup Languages
    Severity: Major
    Found in languages/messages/MessagesMni.php and 3 other locations - About 5 hrs to fix
    languages/messages/MessagesKs_deva.php on lines 1..41
    languages/messages/MessagesPi.php on lines 1..42
    languages/messages/MessagesSat.php on lines 1..38

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

    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 4 locations. Consider refactoring.
    Open

    <?php
    /** ᱥᱟᱱᱛᱟᱲᱤ (Santali)
     *
     * @file
     * @ingroup Languages
    Severity: Major
    Found in languages/messages/MessagesSat.php and 3 other locations - About 5 hrs to fix
    languages/messages/MessagesKs_deva.php on lines 1..41
    languages/messages/MessagesMni.php on lines 1..38
    languages/messages/MessagesPi.php on lines 1..42

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

    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 4 locations. Consider refactoring.
    Open

    <?php
    /** Pali (पालि)
     *
     * @file
     * @ingroup Languages
    Severity: Major
    Found in languages/messages/MessagesPi.php and 3 other locations - About 5 hrs to fix
    languages/messages/MessagesKs_deva.php on lines 1..41
    languages/messages/MessagesMni.php on lines 1..38
    languages/messages/MessagesSat.php on lines 1..38

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

    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 makeWidgetFieldLayouts has 139 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        ApiSandbox.PageLayout.prototype.makeWidgetFieldLayouts = function ( ppi, name ) {
            const widget = Util.createWidgetForParameter( ppi );
            if ( ppi.tokentype ) {
                this.tokenWidget = widget;
            }
    Severity: Major
    Found in resources/src/mediawiki.special.apisandbox/apisandbox.js - About 5 hrs to fix

      File importImages.php has 398 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * Import one or more images from the local file system into the wiki without
       * using the web-based interface.
       *
      Severity: Minor
      Found in maintenance/importImages.php - About 5 hrs to fix

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

                enable: function( index ) {
                    var options = this.options,
                        trigger;
        
                    if ( index && options.disabled === true ||
        Severity: Major
        Found in resources/lib/jquery.ui/jquery.ui.tabs.js and 1 other location - About 5 hrs to fix
        resources/lib/jquery.ui/jquery.ui.tabs.js on lines 994..1008

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

        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

                disable: function( index ) {
                    var options = this.options,
                        trigger;
        
                    if ( index && options.disabled === false ||
        Severity: Major
        Found in resources/lib/jquery.ui/jquery.ui.tabs.js and 1 other location - About 5 hrs to fix
        resources/lib/jquery.ui/jquery.ui.tabs.js on lines 978..992

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

        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

        File FileBackend.php has 397 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * @defgroup FileBackend File backend
         *
         * File backend is used to interact with file storage systems,
        Severity: Minor
        Found in includes/libs/filebackend/FileBackend.php - About 5 hrs to fix

          File rebuildrecentchanges.php has 397 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
           * Rebuild recent changes from scratch.  This takes several hours,
           * depending on the database size and server configuration.
           *
          Severity: Minor
          Found in maintenance/rebuildrecentchanges.php - About 5 hrs to fix

            Function exports has 138 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function ( grunt ) {
                grunt.loadNpmTasks( 'grunt-banana-checker' );
                grunt.loadNpmTasks( 'grunt-eslint' );
                grunt.loadNpmTasks( 'grunt-karma' );
                grunt.loadNpmTasks( 'grunt-stylelint' );
            Severity: Major
            Found in Gruntfile.js - About 5 hrs to fix
              Severity
              Category
              Status
              Source
              Language