wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

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

    private function buildTermSearchMatchDisplayEntry( TermSearchResult $match, array $entry ): array {
        $entry['display'] = [];
        ApiResult::setArrayType( $entry['display'], 'assoc' );

        $displayLabel = $match->getDisplayLabel();
Severity: Minor
Found in repo/includes/Api/SearchEntities.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 execute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute(): void {
        $lookup = $this->revisionLookup;

        $params = $this->extractRequestParams();
        $this->validateParameters( $params );
Severity: Minor
Found in repo/includes/Api/LinkTitles.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 getOptionsObject has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function getOptionsObject( ?string $optionsParam ): FormatterOptions {
        $formatterOptions = new FormatterOptions();
        $formatterOptions->setOption( ValueFormatter::OPT_LANG, $this->getLanguage()->getCode() );

        if ( is_string( $optionsParam ) && $optionsParam !== '' ) {
Severity: Minor
Found in repo/includes/Api/FormatSnakValue.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 execute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute(): void {
        $params = $this->extractRequestParams();
        $result = $this->getResult();

        $context = $params['context'];
Severity: Minor
Found in repo/includes/Api/MetaContentLanguages.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 markStubEntityDataForPrefetching has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function markStubEntityDataForPrefetching( array $entityIds ): void {
        foreach ( $entityIds as $id ) {
            if ( !( $id instanceof EntityId ) ) {
                continue;
            }
Severity: Minor
Found in repo/includes/Rdf/RdfBuilder.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 addStatements has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function addStatements( EntityId $entityId, StatementList $statementList ) {
        $bestList = [];

        // FIXME: This is expensive, share the result with TruthyStatementRdfBuilder!
        foreach ( $statementList->getPropertyIds() as $propertyId ) {
Severity: Minor
Found in repo/includes/Rdf/FullStatementRdfBuilder.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 getResultHtml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getResultHtml( TermSearchResult $searchResult ): string {
        $idHtml = $this->getIdHtml( $searchResult->getEntityId() );

        $displayLabel = $searchResult->getDisplayLabel();
        $displayDescription = $searchResult->getDisplayDescription();
Severity: Minor
Found in repo/includes/ItemDisambiguation.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 validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate( EntityDocument $entity ) {
        if ( !( $entity instanceof DescriptionsProvider ) ) {
            throw new InvalidArgumentException( '$entity must be a DescriptionsProvider' );
        }

Severity: Minor
Found in repo/includes/ChangeOp/ChangeOpDescription.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 addAliases has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function addAliases( $entityNamespace, $entityLName, AliasGroupList $aliases ) {
        /** @var AliasGroup $aliasGroup */
        foreach ( $aliases as $aliasGroup ) {
            $languageCode = $aliasGroup->getLanguageCode();
            if ( $this->languages !== null && !isset( $this->languages[$languageCode] ) ) {
Severity: Minor
Found in repo/includes/Rdf/TermsRdfBuilder.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 rdfSerialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function rdfSerialize(
        EntityRevision $entityRevision,
        ?RedirectRevision $followedRedirect,
        array $incomingRedirects,
        RdfBuilder $rdfBuilder,
Severity: Minor
Found in repo/includes/LinkedData/EntityDataSerializationService.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 getTermsLanguages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function getTermsLanguages(
        array $userPreferredTermsLanguages,
        EntityDocument $entity,
        array $entityTermsListHtml
    ): array {
Severity: Minor
Found in repo/includes/Hooks/OutputPageBeforeHTMLHookHandler.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 showData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function showData( WebRequest $request, OutputPage $output, $format, EntityId $id, $revision ) {
        $flavor = $request->getRawVal( 'flavor' );

        /** @var EntityRevision $entityRevision */
        /** @var RedirectRevision $followedRedirectRevision */
Severity: Minor
Found in repo/includes/LinkedData/EntityDataRequestHandler.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 validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate( EntityDocument $entity ) {
        if ( !( $entity instanceof LabelsProvider ) ) {
            throw new InvalidArgumentException( '$entity must be a LabelsProvider' );
        }

Severity: Minor
Found in repo/includes/ChangeOp/ChangeOpLabel.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 updateAliases has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function updateAliases( AliasGroupList $aliases ) {
        if ( $aliases->hasGroupForLanguage( $this->languageCode ) ) {
            $oldAliases = $aliases->getByLanguage( $this->languageCode )->getAliases();
        } else {
            $oldAliases = [];
Severity: Minor
Found in repo/includes/ChangeOp/ChangeOpAliases.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 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

Severity
Category
Status
Source
Language