wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

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

    protected function getChangeOp( array $preparedParameters, EntityDocument $entity ): ChangeOp {
        if ( $this->shouldRemove( $preparedParameters ) ) {
            $linksite = $this->stringNormalizer->trimToNFC( $preparedParameters['linksite'] );
            return $this->siteLinkChangeOpFactory->newRemoveSiteLinkOp( $linksite );
        } else {
Severity: Minor
Found in repo/includes/Api/SetSiteLink.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 mergeSearchResults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function mergeSearchResults( array $searchResults, array $newSearchResults, $limit ) {
        $searchResultEntityIdSerializations = array_keys( $searchResults );

        foreach ( $newSearchResults as $searchResultToAdd ) {
            $entityIdString = $searchResultToAdd->getEntityId()->getSerialization();
Severity: Minor
Found in repo/includes/Api/EntityTermSearchHelper.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 validateDataValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function validateDataValue( DataValue $dataValue, $dataTypeId ) {
        try {
            $dataValueType = $this->dataTypeFactory->getType( $dataTypeId )->getDataValueType();
        } catch ( OutOfBoundsException $ex ) {
            return Result::newError( [
Severity: Minor
Found in repo/includes/Validators/SnakValidator.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 getIterator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getIterator(): Traversable {
        $number = $this->startingNumber;

        if ( $this->inclusiveUpperBound === null ) {
            // @phan-suppress-next-line PhanInfiniteLoop
Severity: Minor
Found in repo/includes/RangeTraversable.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 getValidEntityId has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getValidEntityId( ?Title $title ): ?EntityId {
        if ( $title === null ) {
            return null;
        }

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

    protected function parseDateValue( $dateValue ) {
        [ $date, $time ] = explode( "T", $dateValue, 2 );
        if ( $date[0] == "-" ) {
            $minus = "-";
        } else {
Severity: Minor
Found in repo/includes/Rdf/DateTimeValueCleaner.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 julianDateValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function julianDateValue( $dateValue ) {
        [ $minus, $y, $m, $d, $time ] = $this->parseDateValue( $dateValue );

        $y = $minus ? -$y : $y + 0;
        // There are some weird overflows happening in the PHP functions before and after this year.
Severity: Minor
Found in repo/includes/Rdf/JulianDateTimeValueCleaner.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 httpContentNegotiation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function httpContentNegotiation( WebRequest $request, OutputPage $output, EntityId $id, $revision = 0 ) {
        $headers = $request->getAllHeaders();
        if ( isset( $headers['ACCEPT'] ) ) {
            $parser = new HttpAcceptParser();
            $accept = $parser->parseWeights( $headers['ACCEPT'] );
Severity: Minor
Found in repo/includes/LinkedData/EntityDataRequestHandler.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 validateTermSerialization has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function validateTermSerialization( $serialization, $languageCode ) {
        $this->assertArray(
            $serialization,
            'An array was expected, but not found in term serialization for the language code ' . $languageCode
        );

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

    public function apply( EntityDocument $entity, Summary $summary = null ) {
        if ( !( $entity instanceof StatementListProvider ) ) {
            throw new InvalidArgumentException( '$entity must be a StatementListProvider' );
        }

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

    private function getValueBuilder( $dataTypeId, $dataValueType ) {
        if ( $dataTypeId !== null ) {
            if ( isset( $this->valueBuilders["PT:$dataTypeId"] ) ) {
                return $this->valueBuilders["PT:$dataTypeId"];
            }
Severity: Minor
Found in repo/includes/Rdf/DispatchingValueSnakRdfBuilder.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 apply has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function apply( EntityDocument $entity, Summary $summary = null ) {
        $changeOpsResults = [];

        if ( count( $this->changeOps ) === 1 ) {
            $changeOpsResults[] = $this->changeOps[0]->apply( $entity, $summary );
Severity: Minor
Found in repo/includes/ChangeOp/ChangeOps.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 onRecentChange_save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function onRecentChange_save( RecentChange $recentChange ): void {
        $logType = $recentChange->getAttribute( 'rc_log_type' );
        $logAction = $recentChange->getAttribute( 'rc_log_action' );

        if (
Severity: Minor
Found in repo/includes/Hooks/RecentChangeSaveHookHandler.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 getIndexedAliases has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getIndexedAliases( array $aliasGroups ) {
        $indexedAliases = [];

        foreach ( $aliasGroups as $languageCode => $aliases ) {
            $this->assertIsArray( $aliases );
Severity: Minor
Found in repo/includes/ChangeOp/Deserialization/AliasesChangeOpDeserializer.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 getEntityIds has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getEntityIds( array $titles ): array {
        $entityIds = [];

        foreach ( $titles as $title ) {
            $pageId = $title->getArticleID();
Severity: Minor
Found in repo/includes/Content/ContentHandlerEntityIdLookup.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 applyEntityPageProperties has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function applyEntityPageProperties( EntityContent $content, ParserOutput $parserOutput ) {
        if ( $content->isRedirect() ) {
            return;
        }

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

    public function run( $new, IContextSource $context, $summary ) {
        $attemptSaveFilterStart = microtime( true );
        $hookStatus = $this->hookRunner->run( $new, $context, $summary );
        $attemptSaveFilterEnd = microtime( true );

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

    public function processUnit( $unit ) {
        $this->output( "Processing $unit...\n" );
        $query = <<<QUERY
SELECT * WHERE {
{
Severity: Minor
Found in repo/maintenance/addUnitConversions.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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        //TODO: more validation for options
        $shardingFactor = (int)$this->getOption( 'sharding-factor', 1 );
        $shard = (int)$this->getOption( 'shard', 0 );
        $batchSize = (int)$this->getOption( 'batch-size', 100 );
Severity: Minor
Found in repo/maintenance/DumpEntities.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 getUndoContent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getUndoContent(
        Content $latestContent,
        Content $newerContent,
        Content $olderContent,
        $undoIsLatest = false
Severity: Minor
Found in repo/includes/Content/EntityHandler.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