wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

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

    private function filterEntitySerializationUsingSiteIds(
        array $serialization,
        array $siteIds = null
    ) {
        if ( $siteIds && array_key_exists( 'sitelinks', $serialization ) ) {
Severity: Minor
Found in repo/includes/Api/ResultBuilder.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 addRevisionIdFromStatusToResult has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function addRevisionIdFromStatusToResult( Status $status, $path, $oldRevId = null ) {
        $value = $status->getValue();

        if ( isset( $value['revision'] ) ) {
            if ( $value['revision'] instanceof EntityRevision ) {
Severity: Minor
Found in repo/includes/Api/ResultBuilder.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 addTermsToResult has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function addTermsToResult( array $pagesToEntityIds, array $termGroups ): void {
        $result = $this->getResult();

        foreach ( $pagesToEntityIds as $currentPage => $entityId ) {
            if ( !isset( $termGroups[$currentPage] ) ) {
Severity: Minor
Found in repo/includes/Api/EntityTerms.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( $value ) {
        $result = Result::newSuccess();

        foreach ( $this->validators as $validator ) {
            $subResult = $validator->validate( $value );
Severity: Minor
Found in repo/includes/Validators/CompositeValidator.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 executeInternal has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function executeInternal(): void {
        $params = $this->extractRequestParams();
        $statement = $this->getStatementFromParams( $params );
        $guid = $statement->getGuid();

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

    protected function applyChangeOp( ChangeOp $changeOp, EntityDocument $entity, Summary $summary = null ): ChangeOpResult {
        try {
            // NOTE: Always validate modification against the current revision, if it exists!
            //       Otherwise, we may miss e.g. a combination of language/label/description
            //       that was already taken.
Severity: Minor
Found in repo/includes/Api/ModifyEntity.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 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

Severity
Category
Status
Source
Language