wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 2,096 of 2,096 total issues

Function validateFormData has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    protected function validateFormData( array $formData ) {
        $status = Status::newGood();

        if ( $formData[ self::FIELD_LABEL ] == ''
             && $formData[ self::FIELD_DESCRIPTION ] == ''
Severity: Minor
Found in repo/includes/Specials/SpecialNewProperty.php - About 1 hr 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 onSkinTemplateNavigationUniversal has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public static function onSkinTemplateNavigationUniversal( SkinTemplate $skinTemplate, array &$links ) {
        $entityContentFactory = WikibaseRepo::getEntityContentFactory();

        $title = $skinTemplate->getRelevantTitle();

Severity: Minor
Found in repo/includes/RepoHooks.php - About 1 hr 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 validateEntity has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function validateEntity( EntityDocument $entity ) {
        $entityId = $entity->getId()->getSerialization();
        $entityType = $entity->getType();

        if ( $entity instanceof LabelsProvider ) {
Severity: Minor
Found in repo/includes/Validators/LabelUniquenessValidator.php - About 1 hr 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 reduceUnits has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private function reduceUnits( $reconvert, &$convertUnits ) {
        while ( $reconvert ) {
            $converted = false;
            foreach ( $reconvert as $name => $unit ) {
                $convertedUnit = $this->convertDerivedUnit( $unit, $convertUnits );
Severity: Minor
Found in repo/maintenance/updateUnits.php - About 1 hr 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 buildClaimSummary has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function buildClaimSummary( ?Statement $oldStatement, Statement $newStatement ) {
        $summary = new Summary( $this->apiModuleName );
        // Only one statement touched, so we're always having singular here.
        $summary->addAutoCommentArgs( 1 );
        $summary->addAutoSummaryArgs( [
Severity: Minor
Found in repo/includes/ClaimSummaryBuilder.php - About 1 hr 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 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        if ( !WikibaseSettings::isRepoEnabled() ) {
            $this->fatalError( "You need to have Wikibase enabled in order to use this maintenance script!\n" );
        }

Severity: Minor
Found in repo/maintenance/removeTermsInLanguage.php - About 1 hr 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 loadLatestRevisionIds has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function loadLatestRevisionIds( array $entityIds, $mode ) {
        $this->doFetch( $mode );

        $revisionIds = [];

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

    public function getDataTypeIdForProperty( PropertyId $propertyId ) {
        $dataTypeId = null;
        $info = $this->infoLookup->getPropertyInfo( $propertyId );

        if ( $info !== null && isset( $info[PropertyInfoLookup::KEY_DATA_TYPE] ) ) {
Severity: Minor
Found in lib/includes/PropertyInfoDataTypeLookup.php - About 1 hr 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 mapToTextInLangIds has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private function mapToTextInLangIds(
        array $termsArray,
        ReplicaPrimaryAwareRecordIdsAcquirer $textInLangIdsAcquirer
    ) {
        $flattenedLangTextIds = [];
Severity: Minor
Found in lib/includes/Store/Sql/Terms/DatabaseTermInLangIdsAcquirer.php - About 1 hr 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 mergeComplexArrays has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private static function mergeComplexArrays(
        string $key,
        array $value,
        array $defaultValue,
        array $twoDArrayMerge,
Severity: Minor
Found in lib/includes/WikibaseSettings.php - About 1 hr 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 factory has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public static function factory( $language, $sourceLanguage = null ) {
        if ( is_string( $language ) ) {
            $languageCode = self::validateLanguageCode( $language );
        } else {
            $languageCode = $language->getCode();
Severity: Minor
Found in lib/includes/LanguageWithConversion.php - About 1 hr 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 assertNoDuplicateSourcesOrEntityTypes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private function assertNoDuplicateSourcesOrEntityTypes( array $sources ) {
        $entityTypesProvided = [];
        $sourceNamesProvided = [];

        foreach ( $sources as $source ) {
Severity: Minor
Found in data-access/src/EntitySourceDefinitions.php - About 1 hr 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 trackChanges has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public trackChanges( oldStatement: Statement|null, newStatement: Statement ): void {
        if ( oldStatement === null ) {
            // newly created statement
            return;
        }
Severity: Minor
Found in view/lib/wikibase-tainted-ref/src/StatementTracker.ts - About 1 hr 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 trimStatementMap has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private trimStatementMap( newStatementMap: StatementMap, baseStatementMap: StatementMap ): StatementMap {
        const trimmedStatementMap: StatementMap = {};
        const propertyIds = new Set( [ ...Object.keys( newStatementMap ), ...Object.keys( baseStatementMap ) ] );
        for ( const propertyId of propertyIds ) {
            if ( propertyId in baseStatementMap ) {
Severity: Minor
Found in client/data-bridge/src/data-access/TrimmingWritingRepository.ts - About 1 hr 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 movePropertyGroup has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private function movePropertyGroup( PropertyId $propertyId, $toIndex ) {
        if ( $this->getPropertyGroupIndex( $propertyId ) === $toIndex ) {
            return;
        }

Severity: Minor
Found in lib/packages/wikibase/data-model/src/ByPropertyIdArray.php - About 1 hr 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 createTag has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        createTag: function ( value, additionalClasses, forceTextInput ) {
            value = this._formatLabel( value );

            var $tag = this.getTag( value );

Severity: Minor
Found in view/resources/jquery/ui/jquery.ui.tagadata.js - About 1 hr to fix

    Function WbSites has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        wb.sites = new ( function WbSites() {
    
            /**
             * Will hold a list of all the sites after getSites() was called. This will cache the result.
             *
    Severity: Minor
    Found in repo/resources/wikibase.sites.js - About 1 hr to fix

      Function WbSites has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var wbSites = new ( function WbSites() {
      
              /**
               * Will hold a list of all the sites after getSites() was called. This will cache the result.
               *
      Severity: Minor
      Found in client/resources/wikibase.sites.js - About 1 hr to fix

        Method getAllowedParams has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getAllowedParams(): array {
                return [
                    'prop' => [
                        ParamValidator::PARAM_ISMULTI => true,
                        ParamValidator::PARAM_TYPE => [
        Severity: Minor
        Found in client/includes/Api/ApiPropsEntityUsage.php - About 1 hr to fix

          Method newLanguageIndependentLuaBindings has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function newLanguageIndependentLuaBindings(): WikibaseLanguageIndependentLuaBindings {
                  $mediaWikiServices = MediaWikiServices::getInstance();
                  $settings = WikibaseClient::getSettings( $mediaWikiServices );
                  $store = WikibaseClient::getStore( $mediaWikiServices );
                  $termsLanguages = WikibaseClient::getTermsLanguages( $mediaWikiServices );
          Severity: Minor
          Found in client/includes/DataAccess/Scribunto/WikibaseLibrary.php - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language