wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

Function getDeserialized has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function getDeserialized( array $serialization ) {
        $snakList = new SnakList();

        foreach ( $serialization as $key => $snakArray ) {
            if ( is_string( $key ) ) {

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

    public function newFromEntityDiff( Diff $entityDiff ) {
        $labelChanges = [];
        $descriptionChanges = [];
        $statementChanges = [];
        $siteLinkChanges = [];

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

    private function validateDatabaseSourceConfigFields( $sourceData, $sourceName ) {
        if ( !is_string( $sourceData['repoDatabase'] ) && $sourceData['repoDatabase'] !== false ) {
            throw new InvalidArgumentException(
                'Symbolic database name of entity source "' . $sourceName . '" should be a string or false.'
            );
Severity: Minor
Found in data-access/src/EntitySourceDefinitionsConfigParser.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 setAliases has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        setAliases: function ( aliases, tempUserWatcher ) {
            var deferred = $.Deferred(),
                self = this,
                language = aliases.getLanguageCode(),
                initialAliases = this._getInitialAliases( language );
Severity: Minor
Found in view/resources/wikibase/entityChangers/AliasesChanger.js - About 1 hr to fix

    Function drawSnakTypeSelector has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            drawSnakTypeSelector: function () {
                if ( this.options.locked.snaktype && this.$snakTypeSelector.contents().length ) {
                    return;
                }
    
    
    Severity: Minor
    Found in view/resources/jquery/wikibase/snakview/snakview.js - About 1 hr to fix

      Function exports has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function (options, source) {
        var TARGET = options.target;
        var GLOBAL = options.global;
        var STATIC = options.stat;
        var FORCED, target, key, targetProperty, sourceProperty, descriptor;
      Severity: Minor
      Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr to fix

        Function get has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    get: (_target, prop) => {
                        if (this.target) {
                            return this.target[prop];
                        }
                        else if (prop === 'on') {
        Severity: Minor
        Found in view/lib/wikibase-tainted-ref/dist/tainted-ref.common.js - About 1 hr to fix

          Method getEntityId has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getEntityId( $pageTitle, $globalSiteId ) {
                  $globalSiteId = $globalSiteId ?: $this->siteId;
                  $entityId = null;
          
                  if ( $globalSiteId === $this->siteId ) {

            Method __construct has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function __construct(
                    EntityChangeLookup $changeLookup,
                    EntityChangeFactory $changeFactory,
                    RecentChangeFactory $rcFactory,
                    TitleFactory $titleFactory,
            Severity: Minor
            Found in client/includes/Changes/InjectRCRecordsJob.php - About 1 hr to fix

              Method onSkinAfterBottomScripts has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function onSkinAfterBottomScripts( Skin $skin, &$html ) {
                      $services = MediaWikiServices::getInstance();
                      $enabledNamespaces = WikibaseClient::getSettings( $services )
                          ->getSetting( 'pageSchemaNamespaces' );
              
              
              Severity: Minor
              Found in client/includes/ClientHooks.php - About 1 hr to fix

                Method getRedirectForEntityId has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getRedirectForEntityId( EntityId $entityId, $forUpdate = '' ) {
                        try {
                            $title = $this->entityTitleLookup->getTitleForId( $entityId );
                        } catch ( \Exception $ex ) {
                            // TODO: Catch more specific type of exception once EntityTitleStoreLookup contract is clarified
                Severity: Minor
                Found in repo/includes/Store/Sql/WikiPageEntityRedirectLookup.php - About 1 hr to fix

                  Method getTrackedExtensions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function getTrackedExtensions(): array {
                          $extensions = [
                              'WikibaseManifest' => 'WBM',
                              'EntitySchema' => 'ENS',
                              'PropertySuggester' => 'PS',
                  Severity: Minor
                  Found in repo/includes/WikibasePingback.php - About 1 hr to fix

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

                        public function getAllowedParams(): array {
                            return [
                                'datatype' => [
                                    ParamValidator::PARAM_TYPE => $this->dataTypeFactory->getTypeIds(),
                                    ParamValidator::PARAM_REQUIRED => false,
                    Severity: Minor
                    Found in repo/includes/Api/ParseValue.php - About 1 hr to fix

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

                          protected function getAllowedParams(): array {
                              return array_merge(
                                  [
                                      'claim' => [
                                          ParamValidator::PARAM_TYPE => 'string',
                      Severity: Minor
                      Found in repo/includes/Api/RemoveQualifiers.php - About 1 hr to fix

                        Method getExamplesMessages has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function getExamplesMessages(): array {
                                $query = 'action=' . $this->getModuleName();
                                $hello = new StringValue( 'hello' );
                                $acme = new StringValue( 'http://acme.org' );
                                $einsteinDob = new TimeValue(
                        Severity: Minor
                        Found in repo/includes/Api/FormatSnakValue.php - About 1 hr to fix

                          Method verifyValid has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function verifyValid( Item $item ): bool {
                                  $params = $this->getParams();
                                  $siteId = $params['siteId'];
                                  $page = $params['title'];
                          
                          
                          Severity: Minor
                          Found in repo/includes/UpdateRepo/UpdateRepoOnDeleteJob.php - About 1 hr to fix

                            Method execute has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function execute(): void {
                                    $this->getMain()->setCacheMode( 'public' );
                            
                                    $params = $this->extractRequestParams();
                                    $this->requireMaxOneParameter( $params, 'property', 'datatype' );
                            Severity: Minor
                            Found in repo/includes/Api/FormatSnakValue.php - About 1 hr to fix

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

                                  protected function getAllowedParams(): array {
                                      return array_merge(
                                          [
                                              'statement' => [
                                                  ParamValidator::PARAM_TYPE => 'string',
                              Severity: Minor
                              Found in repo/includes/Api/RemoveReferences.php - About 1 hr to fix

                                Method execute has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function execute() {
                                        if ( !ExtensionRegistry::getInstance()->isLoaded( 'WikibaseRepository' ) ) {
                                            $this->fatalError(
                                                "You need to have Wikibase enabled in order to use this "
                                                . "maintenance script!\n\n",
                                Severity: Minor
                                Found in repo/maintenance/rebuildPropertyTerms.php - About 1 hr to fix

                                  Method getDataTypeIdForProperty has 27 lines of code (exceeds 25 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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language