wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

Function getModifiedLanguageCodes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function getModifiedLanguageCodes( $original, $modified ): array {
        $original = iterator_to_array( $original );
        $modified = iterator_to_array( $modified );
        $modifiedLanguages = [];

Severity: Minor
Found in repo/rest-api/src/Infrastructure/ModifiedLanguageCodes.php - About 35 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 getPatchedCopy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getPatchedCopy( EntityContentDiff $patch ) {
        $handler = $this->getContentHandler();

        $redirAfterPatch = $this->getPatchedRedirect( $patch->getRedirectDiff() );

Severity: Minor
Found in repo/includes/Content/EntityContent.php - About 35 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 getBaseRevision has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getBaseRevision(): ?EntityRevision {
        if ( $this->baseRev === null ) {
            $baseRevId = $this->getBaseRevisionId();

            if ( $baseRevId === $this->getLatestRevisionId() ) {
Severity: Minor
Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 35 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 processStatements has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function processStatements( $values, $map ) {
        $shortValues = array_map( function ( $str ) {
            return 'wdv:' . $str;
        }, $values );
        $valuesStr = implode( ' ', $shortValues );
Severity: Minor
Found in repo/maintenance/addUnitConversions.php - About 35 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 convertObjectsToArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function convertObjectsToArray( $serialization ) {
        if ( !( is_object( $serialization ) || is_array( $serialization ) ) ) {
            return $serialization;
        }

Severity: Minor
Found in repo/rest-api/src/Infrastructure/JsonDiffJsonPatcher.php - About 35 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 processSnak has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function processSnak( Snak $snak ) {
        if ( $snak instanceof PropertyValueSnak ) {
            $id = $snak->getPropertyId();
            $value = $snak->getDataValue();

Severity: Minor
Found in repo/includes/ParserOutput/ImageLinksDataUpdater.php - About 35 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 processSnak has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function processSnak( Snak $snak ) {
        if ( $snak instanceof PropertyValueSnak ) {
            $id = $snak->getPropertyId();
            $value = $snak->getDataValue();

Severity: Minor
Found in repo/includes/ParserOutput/ExternalLinksDataUpdater.php - About 35 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 getStatementIdPath has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function getStatementIdPath( array $serialization, string $id ): string {
        foreach ( $serialization as $propertyId => $statementGroup ) {
            foreach ( $statementGroup as $groupIndex => $statement ) {
                if ( isset( $statement['id'] ) && $statement['id'] === $id ) {
                    return "/statements/$propertyId/$groupIndex";

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

    public function deserialize( array $serialization, string $basePath = '' ): Statement {
        if ( count( $serialization ) && array_is_list( $serialization ) ) {
            throw new InvalidFieldTypeException( $serialization, $basePath );
        }

Severity: Minor
Found in repo/rest-api/src/Application/Serialization/StatementDeserializer.php - About 35 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 getStatementIdPath has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function getStatementIdPath( array $serialization, string $id ): string {
        foreach ( $serialization as $propertyId => $statementGroup ) {
            foreach ( $statementGroup as $groupIndex => $statement ) {
                if ( isset( $statement['id'] ) && $statement['id'] === $id ) {
                    return "/statements/$propertyId/$groupIndex";

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

    private function getMultipleTermsByLanguageFromLookup( EntityId $entityId, string $termType, array $languages ) {
        if ( $termType === TermTypes::TYPE_LABEL ) {
            $freshTerms = $this->lookup->getLabels( $entityId, $languages );
        } else {
            $freshTerms = $this->lookup->getDescriptions( $entityId, $languages );
Severity: Minor
Found in lib/includes/Store/CachingPrefetchingTermLookup.php - About 35 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 storeTerms has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function storeTerms( NumericPropertyId $propertyId, Fingerprint $terms ) {
        $firstException = null;
        foreach ( $this->propertyTermStoreWriters as $propertyTermStoreWriter ) {
            try {
                $propertyTermStoreWriter->storeTerms( $propertyId, $terms );
Severity: Minor
Found in lib/includes/Store/MultiPropertyTermStoreWriter.php - About 35 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 splitIsoTimestamp has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function splitIsoTimestamp( $isoTimestamp, $precision ) {
        if ( !preg_match(
            '/(\d+)\D+(\d+)\D+(\d+)\D+(\d+)\D+(\d+)\D+(\d+)/',
            $isoTimestamp,
            $matches
Severity: Minor
Found in lib/includes/Formatters/MwTimeIsoFormatter.php - About 35 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 getLatestRevisionId has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getLatestRevisionId( EntityId $entityId, $mode = LookupConstants::LATEST_FROM_REPLICA ) {
        $rows = $this->entityMetaDataAccessor->loadRevisionInformation( [ $entityId ], $mode );
        $row = $rows[$entityId->getSerialization()];

        if ( $row && $row->page_latest ) {
Severity: Minor
Found in lib/includes/Store/Sql/WikiPageEntityRevisionLookup.php - About 35 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 extractPreferredValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function extractPreferredValue( array $data ): ?array {
        if ( !$data ) {
            return null;
        }

Severity: Minor
Found in lib/includes/TermLanguageFallbackChain.php - About 35 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 buildStore has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function buildStore( array $sites, $siteGroup = null, $wikiId = null ) {
        if ( $siteGroup === null && is_string( $wikiId ) ) {
            $siteGroup = $this->getInterwikiGroup( $sites, $wikiId );
        }

Severity: Minor
Found in lib/includes/Sites/SitesBuilder.php - About 35 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 deleteTerms has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function deleteTerms( NumericPropertyId $propertyId ) {
        $firstException = null;
        foreach ( $this->propertyTermStoreWriters as $propertyTermStoreWriter ) {
            try {
                $propertyTermStoreWriter->deleteTerms( $propertyId );
Severity: Minor
Found in lib/includes/Store/MultiPropertyTermStoreWriter.php - About 35 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 cleanTextInLangIds has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function cleanTextInLangIds( array $textInLangIds ): void {
        if ( $textInLangIds === [] ) {
            return;
        }

Severity: Minor
Found in lib/includes/Store/Sql/Terms/DatabaseInnerTermStoreCleaner.php - About 35 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 assertFormatterArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function assertFormatterArray( $format, array $formatters ) {
        foreach ( $formatters as $type => $formatter ) {
            if ( !is_string( $type ) ) {
                throw new InvalidArgumentException( 'formatter array must map type IDs to formatters.' );
            }
Severity: Minor
Found in lib/includes/Formatters/DispatchingSnakFormatter.php - About 35 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 setEntityTypeData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function setEntityTypeData( array $entityNamespaceIdsAndSlots ) {
        foreach ( $entityNamespaceIdsAndSlots as $entityType => $namespaceIdAndSlot ) {
            if ( !is_string( $entityType ) ) {
                throw new \InvalidArgumentException( 'Entity type name not a string: ' . $entityType );
            }
Severity: Minor
Found in data-access/src/DatabaseEntitySource.php - About 35 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