wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function showReturnToPage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function showReturnToPage(
        $type, $returnTo = '', $returnToQuery = '', $stickHTTPS = false, $returnToAnchor = ''
    ) {
        $config = $this->getConfig();
        if ( $type !== 'error' && $config->get( MainConfigNames::RedirectOnLogin ) !== null ) {
Severity: Minor
Found in includes/specials/helpers/LoginHelper.php - About 1 hr 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 formatPolicies has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function formatPolicies( $policies, $group ) {
        $groupPolicies = UserPasswordPolicy::getPoliciesForGroups(
            $policies['policies'],
            [ $group ],
            $policies['policies']['default']
Severity: Minor
Found in includes/specials/SpecialPasswordPolicies.php - About 1 hr 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 reallyDoQuery has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function reallyDoQuery( $limit, $offset = false ) {
        $fname = static::class . '::reallyDoQuery';
        $dbr = $this->getRecacheDB();
        $query = $this->getQueryInfo();
        $conds = isset( $query['conds'] ) ? (array)$query['conds'] : [];
Severity: Minor
Found in includes/specials/SpecialShortPages.php - About 1 hr 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 showEditUserGroupsForm has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function showEditUserGroupsForm( $user, $groups, $groupMemberships ) {
        $list = $membersList = $tempList = $tempMembersList = [];
        foreach ( $groupMemberships as $ugm ) {
            $linkG = UserGroupMembership::getLinkHTML( $ugm, $this->getContext() );
            $linkM = UserGroupMembership::getLinkHTML( $ugm, $this->getContext(), $user->getName() );
Severity: Minor
Found in includes/specials/SpecialUserRights.php - About 1 hr 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 formatRow has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function formatRow( $row ) {
        $title = Title::newFromRow( $row );

        // Revision deletion works on revisions,
        // so cast our recent change row to a revision row.
Severity: Minor
Found in includes/specials/pagers/NewPagesPager.php - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute( $par ) {
        $this->useTransactionalTimeLimit();
        $this->checkReadOnly();
        $this->setHeaders();
        $this->outputHeader();
Severity: Minor
Found in includes/specials/SpecialMovePage.php - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute( $par ) {
        $this->setHeaders();
        $this->outputHeader();

        $this->filename = $par ?? $this->getRequest()->getText( 'filename' );
Severity: Minor
Found in includes/specials/SpecialFileDuplicateSearch.php - About 1 hr 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 doBatchPush has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function doBatchPush( array $jobs, $flags ) {
        // Convert the jobs into field maps (de-duplicated against each other)
        $items = []; // (job ID => job fields map)
        foreach ( $jobs as $job ) {
            $item = $this->getNewJobFields( $job );
Severity: Minor
Found in includes/jobqueue/JobQueueRedis.php - About 1 hr 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 splitRawArg has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function splitRawArg( array $children ) {
        $bits = [];
        foreach ( $children as $i => $child ) {
            if ( !is_array( $child ) ) {
                continue;
Severity: Minor
Found in includes/parser/PPNode_Hash_Tree.php - About 1 hr 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 unstripType has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function unstripType( $type, $text ) {
        // Shortcut
        if ( !count( $this->data[$type] ) ) {
            return $text;
        }
Severity: Minor
Found in includes/parser/StripState.php - About 1 hr 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 resolveRevision has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function resolveRevision( PageIdentity $page, $revision, bool $lenientRevHandling = false ): array {
        $uncacheable = false;
        if ( !$page instanceof PageRecord ) {
            $name = "$page";
            $page = $this->pageLookup->getPageByReference( $page );
Severity: Minor
Found in includes/parser/Parsoid/ParsoidOutputAccess.php - About 1 hr 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 matches has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function matches( ParserOptions $other ) {
        // Compare most options
        $options = array_keys( $this->options );
        $options = array_diff( $options, [
            'enableLimitReport', // only affects HTML comments
Severity: Minor
Found in includes/parser/ParserOptions.php - About 1 hr 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 reallyFetchFile has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function reallyFetchFile( $httpOptions = [] ) {
        $copyUploadProxy = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::CopyUploadProxy );
        $copyUploadTimeout = MediaWikiServices::getInstance()->getMainConfig()
            ->get( MainConfigNames::CopyUploadTimeout );

Severity: Minor
Found in includes/upload/UploadFromUrl.php - About 1 hr 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 publishTo has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function publishTo( $src, $dstRel, $flags = 0, array $options = [] ) {
        $srcPath = ( $src instanceof FSFile ) ? $src->getPath() : $src;

        $repo = $this->getRepo();
        if ( $repo->getReadOnlyReason() !== false ) {
Severity: Minor
Found in includes/filerepo/file/LocalFile.php - About 1 hr 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 checkXMLEncodingMissmatch has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function checkXMLEncodingMissmatch( $file ) {
        // https://mimesniff.spec.whatwg.org/#resource-header says browsers
        // should read the first 1445 bytes. Do 4096 bytes for good measure.
        // XML Spec says XML declaration if present must be first thing in file
        // other than BOM
Severity: Minor
Found in includes/upload/UploadBase.php - About 1 hr 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 getFileInfo has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function getFileInfo( $file, Authority $performer, $transforms ) {
        $urlUtils = MediaWikiServices::getInstance()->getUrlUtils();
        // If there is a problem with the file, there is very little info we can reliably
        // return (T228286, T239213), but we do what we can (T201205).
        $responseFile = [
Severity: Minor
Found in includes/filerepo/file/MediaFileTrait.php - About 1 hr 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 modifyResponse has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function modifyResponse( RequestInterface $request, ResponseInterface $response ): ResponseInterface {
        if ( !$this->options->get( MainConfigNames::AllowCrossOrigin ) ) {
            return $response;
        }

Severity: Minor
Found in includes/Rest/CorsUtils.php - About 1 hr 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 formatMonologV0 has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function formatMonologV0( array $record ) {
        if ( empty( $record['datetime'] ) ) {
            $record['datetime'] = gmdate( 'c' );
        }
        $message = [
Severity: Minor
Found in includes/debug/logger/monolog/LogstashFormatter.php - About 1 hr 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 openSink has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function openSink() {
        if ( !$this->uri ) {
            throw new LogicException(
                'Missing stream uri, the stream can not be opened.' );
        }
Severity: Minor
Found in includes/debug/logger/monolog/LegacyHandler.php - About 1 hr 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 parseQuery has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function parseQuery( $term ) {
        wfDebug( "parseQuery received: $term" );

        // No backslashes allowed
        $term = preg_replace( '/\\\\/', '', $term );
Severity: Minor
Found in includes/search/SearchPostgres.php - About 1 hr 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