wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

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

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

    private function addObjectToPropertyGroup( $object, $index = null ) {
        $propertyId = $object->getPropertyId();
        $validIndices = $this->getFlatArrayIndices( $propertyId );

        if ( empty( $validIndices ) ) {
Severity: Minor
Found in lib/packages/wikibase/data-model/src/ByPropertyIdArray.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 getChangedStatements has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function getChangedStatements( Diff $claimsDiff ) {
        $changedStatements = [];

        foreach ( $claimsDiff as $pid => $diffOp ) {
            /** @var Statement $statement */
Severity: Minor
Found in lib/packages/wikibase/changes/src/EntityDiffChangedAspectsFactory.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 patchStatementList has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function patchStatementList( StatementList $statements, Diff $patch ) {
        /**
         * @var Statement $statement
         * @var Statement $oldStatement
         * @var Statement $newStatement

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

Avoid too many return statements within this function.
Open

                    return -1;
Severity: Major
Found in view/resources/jquery/wikibase/jquery.wikibase.entityselector.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return new datamodel.Statement(
                    new datamodel.Claim( mainSnak, qualifiers, guid ),
                    references,
                    this._rankSelector.value()
                );
    Severity: Major
    Found in view/resources/jquery/wikibase/jquery.wikibase.statementview.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                              return 0;
      Severity: Major
      Found in view/resources/jquery/wikibase/jquery.wikibase.entityselector.js - About 30 mins to fix
        Severity
        Category
        Status
        Source
        Language