wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function revisionid has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public static function revisionid( $parser, $title = null ) {
        $t = self::makeTitle( $parser, $title );
        if ( $t === null || $t->isExternal() ) {
            return '';
        }
Severity: Minor
Found in includes/parser/CoreParserFunctions.php - About 2 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

Method __construct has 22 arguments (exceeds 4 allowed). Consider refactoring.
Open

        ServiceOptions $svcOptions,
        MagicWordFactory $magicWordFactory,
        Language $contLang,
        ParserFactory $factory,
        UrlUtils $urlUtils,
Severity: Major
Found in includes/parser/Parser.php - About 2 hrs to fix

    Function detectScript has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function detectScript( $file, $mime, $extension ) {
            # ugly hack: for text files, always look at the entire file.
            # For binary field, just check the first K.
    
            if ( str_starts_with( $mime ?? '', 'text/' ) ) {
    Severity: Minor
    Found in includes/upload/UploadBase.php - About 2 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 fileExistsBatch has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        public function fileExistsBatch( array $files ) {
            $results = [];
            foreach ( $files as $k => $f ) {
                if ( isset( $this->mFileExists[$f] ) ) {
                    $results[$k] = $this->mFileExists[$f];
    Severity: Minor
    Found in includes/filerepo/ForeignAPIRepo.php - About 2 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 publishBatch has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        public function publishBatch( array $ntuples, $flags = 0 ) {
            $this->assertWritableRepo(); // fail out if read-only
    
            $backend = $this->backend; // convenience
            // Try creating directories
    Severity: Minor
    Found in includes/filerepo/FileRepo.php - About 2 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 parseNamespacePrefixes has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function parseNamespacePrefixes(
            $query,
            $withAllKeyword = true,
            $withPrefixSearchExtractNamespaceHook = false
        ) {
    Severity: Minor
    Found in includes/search/SearchEngine.php - About 2 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 HTCPPurge has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function HTCPPurge( array $urls ) {
            $htcpRouting = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::HTCPRouting );
            $htcpMulticastTTL = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::HTCPMulticastTTL );
            // HTCP CLR operation
            $htcpOpCLR = 4;
    Severity: Minor
    Found in includes/deferred/CdnCacheUpdate.php - About 2 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 updateTo2 has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function updateTo2( &$json ) {
            if ( isset( $json['config'] ) ) {
                $config = $json['config'];
                $json['config'] = [];
                if ( isset( $config['_prefix'] ) ) {
    Severity: Minor
    Found in maintenance/updateExtensionJsonSchema.php - About 2 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 doPage has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        private function doPage( $pageId ) {
            $title = Title::newFromID( $pageId );
            if ( $title ) {
                $titleText = $title->getPrefixedText();
            } else {
    Severity: Minor
    Found in maintenance/storage/recompressTracked.php - About 2 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 checkFiles has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function checkFiles( LocalRepo $repo, array $paths, $verbose ) {
            if ( !count( $paths ) ) {
                return;
            }
    
    
    Severity: Minor
    Found in maintenance/findOrphanedFiles.php - About 2 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

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

    OO.ui.RadioOptionWidget.prototype.setDisabled = function ( disabled ) {
        OO.ui.RadioOptionWidget.super.prototype.setDisabled.call( this, disabled );
    
        this.radio.setDisabled( this.isDisabled() );
    
    
    Severity: Major
    Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 2 hrs to fix
    resources/lib/ooui/oojs-ui-core.js on lines 9551..9555

    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

        _activate: function(event) {
            var draggable = $.ui.ddmanager.current;
            if(this.options.activeClass) this.element.addClass(this.options.activeClass);
            (draggable && this._trigger('activate', event, this.ui(draggable)));
        },
    Severity: Major
    Found in resources/lib/jquery.ui/jquery.ui.droppable.js and 1 other location - About 2 hrs to fix
    resources/lib/jquery.ui/jquery.ui.droppable.js on lines 76..80

    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

    OO.ui.CheckboxMultioptionWidget.prototype.setDisabled = function ( disabled ) {
        OO.ui.CheckboxMultioptionWidget.super.prototype.setDisabled.call( this, disabled );
        this.checkbox.setDisabled( this.isDisabled() );
        return this;
    };
    Severity: Major
    Found in resources/lib/ooui/oojs-ui-core.js and 1 other location - About 2 hrs to fix
    resources/lib/ooui/oojs-ui-core.js on lines 9208..9214

    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

            if ( this.local ) {
                return (
                    date1.getHours() === date2.getHours() &&
                    date1.getMinutes() === date2.getMinutes() &&
                    date1.getSeconds() === date2.getSeconds() &&
    resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js on lines 554..561

    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

        _deactivate: function(event) {
            var draggable = $.ui.ddmanager.current;
            if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
            (draggable && this._trigger('deactivate', event, this.ui(draggable)));
        },
    Severity: Major
    Found in resources/lib/jquery.ui/jquery.ui.droppable.js and 1 other location - About 2 hrs to fix
    resources/lib/jquery.ui/jquery.ui.droppable.js on lines 70..74

    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

                atMost: function atMost(num) {
                    if (typeof num !== "number") {
                        throw new TypeError("'" + num + "' is not number");
                    }
    
    
    Severity: Major
    Found in resources/lib/sinonjs/sinon.js and 1 other location - About 2 hrs to fix
    resources/lib/sinonjs/sinon.js on lines 4017..4030

    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

                atLeast: function atLeast(num) {
                    if (typeof num !== "number") {
                        throw new TypeError("'" + num + "' is not number");
                    }
    
    
    Severity: Major
    Found in resources/lib/sinonjs/sinon.js and 1 other location - About 2 hrs to fix
    resources/lib/sinonjs/sinon.js on lines 4032..4045

    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

            } else {
                return (
                    date1.getUTCHours() === date2.getUTCHours() &&
                    date1.getUTCMinutes() === date2.getUTCMinutes() &&
                    date1.getUTCSeconds() === date2.getUTCSeconds() &&
    resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js on lines 547..554

    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

    File searchSuggest.js has 281 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*!
     * Add search suggestions to the search form.
     */
    ( function () {
        // eslint-disable-next-line no-jquery/no-map-util
    Severity: Minor
    Found in resources/src/mediawiki.searchSuggest/searchSuggest.js - About 2 hrs to fix

      File MessagesPl.php has 281 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /** Polish (polski)
       *
       * @file
       * @ingroup Languages
      Severity: Minor
      Found in languages/messages/MessagesPl.php - About 2 hrs to fix
        Severity
        Category
        Status
        Source
        Language