wikimedia/mediawiki-extensions-Wikibase

View on GitHub

Showing 1,432 of 2,096 total issues

Method updateQuantityUnit has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function updateQuantityUnit( EntityDocument $entity ) {
        $updateCounter = 0;

        if ( !$entity instanceof StatementListProvider ) {
            $this->errorReporter->reportMessage(
Severity: Minor
Found in repo/maintenance/EntityQuantityUnitRebuilder.php - About 1 hr to fix

    Method validateAndDeserialize has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function validateAndDeserialize( PropertyLabelEditRequest $request ): Term {
            $property = $this->propertyRetriever->getPropertyWriteModel( new NumericPropertyId( $request->getPropertyId() ) );
            $label = $request->getLabel();
            $language = $request->getLanguageCode();
    
    

      Method getLinks has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getLinks(
              ?array $numericIds = null,
              ?array $siteIds = null,
              ?array $pageNames = null
          ): array {
      Severity: Minor
      Found in lib/includes/Store/Sql/SiteLinkTable.php - About 1 hr to fix

        Method formatReference has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function formatReference( Reference $reference ): string {
                $referenceSnaks = new ByCertainPropertyIdGrouper( $reference->getSnaks(), [
                    $this->properties->referenceUrlPropertyId,
                    $this->properties->titlePropertyId,
                    $this->properties->statedInPropertyId,
        Severity: Minor
        Found in lib/includes/Formatters/Reference/DataBridgeReferenceFormatter.php - About 1 hr to fix

          Function run has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              public function run(): bool {
                  $change = $this->getChange();
                  $titles = $this->getTitles();
          
                  if ( !$change || $titles === [] ) {
          Severity: Minor
          Found in client/includes/Changes/InjectRCRecordsJob.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 getMediaWikiPermissionsToCheck has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              private function getMediaWikiPermissionsToCheck( $action, $entityType ) {
                  if ( $action === self::ACTION_MW_CREATE ) {
                      $entityTypeSpecificCreatePermission = $entityType . '-create';
          
                      $permissions = [ 'read', 'edit', 'createpage' ];
          Severity: Minor
          Found in repo/includes/Store/WikiPageEntityStorePermissionChecker.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 generateDump has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              public function generateDump( EntityIdPager $idPager ): void {
                  $dumpCount = 0;
          
                  $this->preDump();
          
          
          Severity: Minor
          Found in repo/includes/Dumpers/DumpGenerator.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 getTermsSerializationWithFallbackInfo has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              private function getTermsSerializationWithFallbackInfo(
                  array $serialization,
                  array $termFallbackChains
              ) {
                  $newSerialization = $serialization;
          Severity: Minor
          Found in repo/includes/Api/ResultBuilder.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

          Method __construct has 14 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  ApiMain $mainModule,
                  string $moduleName,
                  StringNormalizer $stringNormalizer,
                  LanguageFallbackChainFactory $languageFallbackChainFactory,
                  SiteLinkGlobalIdentifiersProvider $siteLinkGlobalIdentifiersProvider,
          Severity: Major
          Found in repo/includes/Api/GetEntities.php - About 1 hr to fix

            Function collectNewAndOldTerms has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                private function collectNewAndOldTerms( ChangeOpFingerprintResult $changeOpsResult ): array {
                    $traversable = $this->makeRecursiveTraversable( $changeOpsResult );
            
                    $newTerms = [];
                    $oldTerms = [];
            Severity: Minor
            Found in repo/includes/Validators/FingerprintUniquenessValidator.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

            Method __construct has 14 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    EntityDataUriManager $uriManager,
                    HTMLCacheUpdater $htmlCacheUpdater,
                    EntityIdParser $entityIdParser,
                    EntityRevisionLookup $entityRevisionLookup,
                    EntityRedirectLookup $entityRedirectLookup,
            Severity: Major
            Found in repo/includes/LinkedData/EntityDataRequestHandler.php - About 1 hr to fix

              Function next has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function next() {
                      $id = null;
              
                      while ( $id === null ) {
                          $this->reader->next();
              Severity: Minor
              Found in repo/includes/IO/EntityIdReader.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 cleanupGregorianValue has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function cleanupGregorianValue( $dateValue, $precision ) {
                      try {
                          [ $minus, $y, $m, $d, $time ] = $this->parseDateValue( $dateValue );
                      } catch ( IllegalValueException $e ) {
                          return null;
              Severity: Minor
              Found in repo/includes/Rdf/DateTimeValueCleaner.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

              Method factory has 14 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      Language $contentLanguage,
                      HttpRequestFactory $httpRequestFactory,
                      IBufferingStatsdDataFactory $statsdDataFactory,
                      UserOptionsLookup $userOptionsLookup,
                      EntityContentFactory $entityContentFactory,
              Severity: Major
              Found in repo/includes/Hooks/OutputPageBeforeHTMLHookHandler.php - About 1 hr to fix

                Function addSiteLinks has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function addSiteLinks( Item $item ) {
                        $id = $item->getId();
                        $entityLName = $this->vocabulary->getEntityLName( $id );
                        $entityRepoName = $this->vocabulary->getEntityRepositoryName( $id );
                
                
                Severity: Minor
                Found in repo/includes/Rdf/SiteLinksRdfBuilder.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 equals has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function equals( Content $that = null ) {
                        if ( $that === $this ) {
                            return true;
                        }
                
                
                Severity: Minor
                Found in repo/includes/Content/EntityContent.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 14 (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!" );
                        }
                        $format = $this->getOption( 'format', 'json' );
                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 getTermMatchQueries has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function getTermMatchQueries(
                        IReadableDatabase $dbr,
                        TermIndexSearchCriteria $mask,
                        string $entityType,
                        $termType = null,
                Severity: Minor
                Found in lib/includes/Store/Sql/Terms/DatabaseMatchingTermsLookup.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 assertConfigArrayWellFormed has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function assertConfigArrayWellFormed( array $sourceConfig ) {
                        Assert::parameterElementType( 'array', $sourceConfig, '$sourceConfig' );
                
                        foreach ( $sourceConfig as $sourceName => $sourceData ) {
                            if ( !is_string( $sourceName ) ) {
                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

                Method __construct has 14 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        EntityIdParser $entityIdParser,
                        EntityIdComposer $entityIdComposer,
                        Deserializer $dataValueDeserializer,
                        NameTableStore $slotRoleStore,
                        DataAccessSettings $dataAccessSettings,
                Severity: Major
                Found in data-access/src/SingleEntitySourceServices.php - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language