wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

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

    public function doWikibaseHandleChange( Change $change ) {
        if ( $this->sendEchoNotification !== true ) {
            return false;
        }

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

    public function doHandle( Parser $parser, $shortDesc, $controlArg ) {
        $noReplace = $this->parseNoReplace( $parser, $controlArg );
        $out = $parser->getOutput();

        if ( $out->getPageProperty( 'wikibase-shortdesc' ) !== null && $noReplace ) {
Severity: Minor
Found in client/includes/Hooks/ShortDescHandler.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 getEntitySourceForConceptURI has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function getEntitySourceForConceptURI( $idSerialization ): ?ApiEntitySource {
        $baseUri = $this->baseUriExtractor->getBaseUriFromSerialization( $idSerialization );
        $conceptBaseURIsToSources = array_flip( $this->entitySourceDefinitions->getConceptBaseUris() );

        if ( array_key_exists( $baseUri, $conceptBaseURIsToSources ) ) {

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

    protected function getChangeOp( array $preparedParameters, EntityDocument $entity ): ChangeOp {
        $changeOps = [];
        $language = $preparedParameters['language'];

        // Set the list of aliases to a user given one OR add/ remove certain entries
Severity: Minor
Found in repo/includes/Api/SetAliases.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( $subPage ) {
        parent::execute( $subPage );

        $this->checkPermissions();
        $this->checkBlocked();
Severity: Minor
Found in repo/includes/Specials/SpecialRedirectEntity.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 processArguments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function processArguments( $subPage ) {
        $this->extractInput( $subPage );

        // Parse the 'id' parameter and throw an exception if the entity cannot be loaded
        parent::processArguments( $subPage );
Severity: Minor
Found in repo/includes/Specials/SpecialSetLabelDescriptionAliases.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 parseStringValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function parseStringValue( ValueParser $parser, string $value, ?ValueValidator $validator ): array {
        $result = [
            'raw' => $value,
        ];

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

    private function getOptionsObject( ?string $optionsParam ): ParserOptions {
        $parserOptions = new ParserOptions();
        $parserOptions->setOption( ValueParser::OPT_LANG, $this->getLanguage()->getCode() );

        if ( is_string( $optionsParam ) && $optionsParam !== '' ) {
Severity: Minor
Found in repo/includes/Api/ParseValue.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( $subPage ) {
        parent::execute( $subPage );
        [ $sites, $itemString ] = $this->getArguments( $subPage );

        if ( $itemString !== '' ) {
Severity: Minor
Found in repo/includes/Specials/SpecialGoToLinkedPage.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( $subPage ): void {
        $this->setHeaders();
        $this->outputHeader();

        $this->getOutput()->addWikiMsg( 'wikibase-mylanguagefallbackchain-text' );
Severity: Minor
Found in repo/includes/Specials/SpecialMyLanguageFallbackChain.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 processArguments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function processArguments( $subPage ) {
        parent::processArguments( $subPage );

        $request = $this->getRequest();
        // explode the subpage from the format Special:SetSitelink/q123/enwiki
Severity: Minor
Found in repo/includes/Specials/SpecialSetSiteLink.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 onOutputPageParserOutput has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function onOutputPageParserOutput( OutputPage $outputPage, ParserOutput $parserOutput ) {
        // Set in PlaceholderEmittingEntityTermsView.
        $placeholders = $parserOutput->getExtensionData( 'wikibase-view-chunks' );
        if ( $placeholders !== null ) {
            $outputPage->setProperty( 'wikibase-view-chunks', $placeholders );
Severity: Minor
Found in repo/includes/RepoHooks.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 attemptSaveEntity has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function attemptSaveEntity(
        EntityDocument $entity,
        $summary,
        array $requestParams,
        IContextSource $context,
Severity: Minor
Found in repo/includes/Api/EntitySavingHelper.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 statementMainSnakAlreadyExists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function statementMainSnakAlreadyExists(
        Statement $statement,
        StatementList $existingStatements
    ): bool {
        $propertyId = $statement->getPropertyId();
Severity: Minor
Found in repo/includes/Api/SetClaim.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/CombinedEntitySearchHelper.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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate( $value ): Result {
        if ( !is_string( $value ) ) {
            throw new InvalidArgumentException( 'Expected a string' );
        }

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

    public static function onSetupAfterCache() {
        global $wgContentHandlers,
            $wgNamespaceContentModels;

        if ( WikibaseRepo::getSettings()->getSetting( 'defaultEntityNamespaces' ) ) {
Severity: Minor
Found in repo/includes/RepoHooks.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 detectLabelDescriptionEqual has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function detectLabelDescriptionEqual(
        array $labels,
        array $descriptions
    ) {
        foreach ( $labels as $languageCode => $label ) {
Severity: Minor
Found in repo/includes/Validators/LabelDescriptionNotEqualValidator.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 formatValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function formatValue( array $params, DataValue $value, ?string $dataTypeId ): string {
        $snak = null;
        if ( isset( $params['property'] ) ) {
            $snak = new PropertyValueSnak( $this->parsePropertyId( $params['property'] ), $value );
        }
Severity: Minor
Found in repo/includes/Api/FormatSnakValue.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 inheritDefaultRateLimits has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function inheritDefaultRateLimits( array &$rateLimits ) {
        if ( isset( $rateLimits['wikibase-idgenerator']['&inherit-create-edit'] ) ) {
            unset( $rateLimits['wikibase-idgenerator']['&inherit-create-edit'] );
            $limits = $rateLimits['create'] ?? $rateLimits['edit'] ?? [];
            foreach ( $limits as $group => $limit ) {
Severity: Minor
Found in repo/includes/RepoHooks.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