wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

File DataAccess.php has 323 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Copyright (C) 2011-2022 Wikimedia Foundation and others.
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Minor
Found in includes/parser/Parsoid/Config/DataAccess.php - About 3 hrs to fix

    Function hook has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    mw.hook = function ( name ) {
        return hooks[ name ] || ( hooks[ name ] = ( function () {
            let memory;
            const fns = [];
            function rethrow( e ) {
    Severity: Minor
    Found in resources/src/mediawiki.base/mediawiki.base.js - About 3 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 write has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        #[\ReturnTypeWillChange]
        public function write( $id, $dataStr ) {
            if ( self::$instance !== $this ) {
                throw new \UnexpectedValueException( __METHOD__ . ': Wrong instance called!' );
            }
    Severity: Minor
    Found in includes/session/PHPSessionHandler.php - About 3 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 undeleteUnsafe has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public function undeleteUnsafe( string $comment ): StatusValue {
            $hookStatus = $this->runPreUndeleteHook( $comment );
            if ( !$hookStatus->isGood() ) {
                return $hookStatus;
            }
    Severity: Minor
    Found in includes/page/UndeletePage.php - About 3 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 imageLinks has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function imageLinks() {
            $limit = 100;
    
            $out = $this->getContext()->getOutput();
    
    
    Severity: Minor
    Found in includes/page/ImagePage.php - About 3 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 validate has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public function validate( $path ) {
            $contents = file_get_contents( $path );
            $jsonParser = new JsonParser();
            try {
                $data = $jsonParser->parse( $contents, JsonParser::DETECT_KEY_CONFLICTS );
    Severity: Minor
    Found in includes/registration/ExtensionJsonValidator.php - About 3 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 convertGrammar has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public function convertGrammar( $word, $case ) {
            $lord = strtolower( $word );
            $gender = 'm'; // Nuutnaarel // default
            if ( preg_match( '/wiki$/', $lord ) ) {
                $gender = 'n'; // Dat xyz-wiki
    Severity: Minor
    Found in includes/languages/LanguageKsh.php - About 3 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 runMultiHttp has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        private function runMultiHttp( array $reqs, array $opts = [] ) {
            $httpOptions = [
                'timeout' => $opts['reqTimeout'] ?? $this->reqTimeout,
                'connectTimeout' => $opts['connTimeout'] ?? $this->connTimeout,
                'logger' => $this->logger,
    Severity: Minor
    Found in includes/libs/http/MultiHttpClient.php - About 3 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 getMediaType has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getMediaType( string $path = null, string $mime = null ): string {
            if ( !$mime && !$path ) {
                return MEDIATYPE_UNKNOWN;
            }
    
    
    Severity: Minor
    Found in includes/libs/mime/MimeAnalyzer.php - About 3 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 getConnection has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getConnection( $server, LoggerInterface $logger = null ) {
            // The above @return also documents 'Redis' for convenience with IDEs.
            // RedisConnRef uses PHP magic methods, which wouldn't be recognised.
    
            $logger = $logger ?: $this->logger;
    Severity: Minor
    Found in includes/libs/redis/RedisConnectionPool.php - About 3 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 displaySection has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public function displaySection( $fields,
            $sectionName = '',
            $fieldsetIDPrefix = '',
            &$hasUserVisibleFields = false
        ) {
    Severity: Minor
    Found in includes/htmlform/HTMLForm.php - About 3 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 removeDotSegments has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function removeDotSegments( string $urlPath ): string {
            $output = '';
            $inputOffset = 0;
            $inputLength = strlen( $urlPath );
    
    
    Severity: Minor
    Found in includes/utils/UrlUtils.php - About 3 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 readExtension has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        private function readExtension( $fullJsonFile, $extDeps = [], $skinDeps = [] ) {
            $load = [
                $fullJsonFile => 1
            ];
            if ( $extDeps ) {
    Severity: Minor
    Found in includes/installer/Installer.php - About 3 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 execute has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public function execute() {
            $this->params = $this->extractRequestParams();
            if ( $this->params['prop'] !== null ) {
                $prop = array_fill_keys( $this->params['prop'], true );
                $this->fld_protection = isset( $prop['protection'] );
    Severity: Minor
    Found in includes/api/ApiQueryInfo.php - About 3 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 run has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        private function run( $resultPageSet = null ) {
            $params = $this->extractRequestParams();
    
            $prop = array_fill_keys( $params['prop'], true );
            $fld_ids = isset( $prop['ids'] );
    Severity: Minor
    Found in includes/api/ApiQueryPagesWithProp.php - About 3 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 extractAllSlotInfo has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        private function extractAllSlotInfo( RevisionRecord $revision, $revDel ): array {
            $vals = [];
    
            if ( $this->slotRoles === null ) {
                try {
    Severity: Minor
    Found in includes/api/ApiQueryRevisionsBase.php - About 3 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 execute has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public function execute() {
            $this->useTransactionalTimeLimit();
    
            $params = $this->extractRequestParams();
            $rotation = $params['rotation'];
    Severity: Minor
    Found in includes/api/ApiImageRotate.php - About 3 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 execute has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public function execute( $par ) {
            $this->setHeaders();
            $this->outputHeader();
            $out = $this->getOutput();
            $out->addModules( 'mediawiki.userSuggest' );
    Severity: Minor
    Found in includes/specials/SpecialLog.php - About 3 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 doExport has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function doExport( $page, $history, $list_authors, $exportall ) {
            // If we are grabbing everything, enable full history and ignore the rest
            if ( $exportall ) {
                $history = WikiExporter::FULL;
            } else {
    Severity: Minor
    Found in includes/specials/SpecialExport.php - About 3 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 showForm has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        private function showForm() {
            $action = $this->getPageTitle()->getLocalURL( [ 'action' => 'submit' ] );
            $authority = $this->getAuthority();
            $out = $this->getOutput();
            $this->addHelpLink( 'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Import', true );
    Severity: Minor
    Found in includes/specials/SpecialImport.php - About 3 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

    Severity
    Category
    Status
    Source
    Language