wikimedia/mediawiki-core

View on GitHub

Showing 11,545 of 11,545 total issues

Function getUserForPreview has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getUserForPreview() {
        if ( $this->savedTempUser ) {
            return $this->savedTempUser;
        } elseif ( $this->unsavedTempUser ) {
            return $this->unsavedTempUser;
Severity: Minor
Found in includes/editpage/EditPage.php - 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 getCheckboxesDefinitionForWatchlist has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getCheckboxesDefinitionForWatchlist( $watch, $watchexpiry ): array {
        $fieldDefs = [
            'wpWatchthis' => [
                'id' => 'wpWatchthis',
                'label-message' => 'watchthis',
Severity: Minor
Found in includes/editpage/EditPage.php - 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 addPageLink has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function addPageLink( LinkTarget $target, $text, $wikiId, LinkTarget $contextTitle ) {
        if ( $wikiId !== null && $wikiId !== false && !$target->isExternal() ) {
            // Handle links from a foreign wiki ID
            return $this->linkRenderer->makeExternalLink(
                WikiMap::getForeignURL(
Severity: Minor
Found in includes/CommentFormatter/CommentParser.php - 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 dumpLogs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function dumpLogs( $cond ) {
        $where = [];
        # Hide private logs
        $hideLogs = LogEventsList::getExcludeClause( $this->db );
        if ( $hideLogs ) {
Severity: Minor
Found in includes/export/WikiExporter.php - 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 newFromInterwiki has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function newFromInterwiki( $interwiki, $page, $history = false,
        $templates = false, $pageLinkDepth = 0
    ) {
        if ( $page == '' ) {
            return Status::newFatal( 'import-noarticle' );
Severity: Minor
Found in includes/import/ImportStreamSource.php - 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 processTitle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function processTitle( $text, $ns = null ) {
        if ( $this->foreignNamespaces === null ) {
            $foreignTitleFactory = new NaiveForeignTitleFactory(
                $this->contentLanguage
            );
Severity: Minor
Found in includes/import/WikiImporter.php - 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 getSecondaryDataUpdates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getSecondaryDataUpdates( $recursive = false ) {
        if ( $this->isContentDeleted() ) {
            // This shouldn't happen, since the current content is always public,
            // and DataUpdates are only needed for current content.
            return [];
Severity: Minor
Found in includes/Storage/DerivedPageDataUpdater.php - 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 newFromUpload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function newFromUpload( $fieldname = "xmlimport" ) {
        // phpcs:ignore MediaWiki.Usage.SuperGlobalsUsage.SuperGlobals
        $upload =& $_FILES[$fieldname];

        if ( $upload === null || !$upload['name'] ) {
Severity: Minor
Found in includes/import/ImportStreamSource.php - 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 releaseAll has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function releaseAll() {
        $e = null;
        foreach ( self::$active as $poolCounter ) {
            try {
                if ( $poolCounter->slot !== null ) {
Severity: Minor
Found in includes/poolcounter/PoolCounterRedis.php - 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 openReader has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function openReader() {
        // Enable the entity loader, as it is needed for loading external URLs via
        // XMLReader::open (T86036)
        // phpcs:ignore Generic.PHP.NoSilencedErrors -- suppress deprecation per T268847
        $oldDisable = @libxml_disable_entity_loader( false );
Severity: Minor
Found in includes/import/WikiImporter.php - 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 getRevisionHeader has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getRevisionHeader( RevisionRecord $rev, $complete = '' ) {
        $lang = $this->getLanguage();
        $user = $this->getUser();
        $revtimestamp = $rev->getTimestamp();
        $timestamp = $lang->userTimeAndDate( $revtimestamp, $user );
Severity: Minor
Found in includes/diff/DifferenceEngine.php - 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 getRevisionIdsBetween has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getRevisionIdsBetween(
        int $pageId,
        RevisionRecord $old = null,
        RevisionRecord $new = null,
        ?int $max = null,
Severity: Minor
Found in includes/Revision/RevisionStore.php - 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 getField has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getField( $name ) {
        if ( !isset( $this->row->$name ) ) {
            // distinguish between unknown and uninitialized fields
            if ( property_exists( $this->row, $name ) ) {
                throw new IncompleteRevisionException(
Severity: Minor
Found in includes/Revision/SlotRecord.php - 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 register has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function register( array $configs, $readOnlyReason = null ) {
        foreach ( $configs as $config ) {
            if ( !isset( $config['name'] ) ) {
                throw new InvalidArgumentException( "Cannot register a backend with no name." );
            }
Severity: Minor
Found in includes/filebackend/FileBackendGroup.php - 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 hasSameContent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function hasSameContent( SlotRecord $other ) {
        if ( $other === $this ) {
            return true;
        }

Severity: Minor
Found in includes/Revision/SlotRecord.php - 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 getSize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getSize() {
        if ( $this->size === false ) {
            $this->size = null;

            if ( $this->fp ) {
Severity: Minor
Found in includes/libs/ParamValidator/Util/UploadedFileStream.php - 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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct( $linesBefore, $linesAfter ) {
        [ $wordsBefore, $wordsBeforeStripped ] = $this->split( $linesBefore );
        [ $wordsAfter, $wordsAfterStripped ] = $this->split( $linesAfter );

        try {
Severity: Minor
Found in includes/libs/Diff/WordLevelDiff.php - 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 encode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function encode( $value, $pretty = false, $escaping = 0 ) {
        // PHP escapes '/' to prevent breaking out of inline script blocks using '</script>',
        // which is hardly useful when '<' and '>' are escaped (and inadequate), and such
        // escaping negatively impacts the human readability of URLs and similar strings.
        $options = JSON_UNESCAPED_SLASHES;
Severity: Minor
Found in includes/json/FormatJson.php - 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 deserializeArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function deserializeArray( array $array ): array {
        $deserializedExtensionData = [];
        foreach ( $array as $key => $value ) {
            if ( $key === JsonConstants::COMPLEX_ANNOTATION ) {
                /* don't include this in the result */
Severity: Minor
Found in includes/json/JsonCodec.php - 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 getDiffersByFormat has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getDiffersByFormat() {
        if ( $this->differsByFormat === null ) {
            $differs = [];
            foreach ( $this->getDiffers() as $differ ) {
                foreach ( $differ->getFormats() as $format ) {
Severity: Minor
Found in includes/diff/TextDiffer/ManifoldTextDiffer.php - 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