wikimedia/mediawiki-extensions-Wikibase

View on GitHub
repo/includes/Api/EditEntity.php

Summary

Maintainability
D
2 days
Test Coverage

File EditEntity.php has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare( strict_types = 1 );

namespace Wikibase\Repo\Api;
Severity: Minor
Found in repo/includes/Api/EditEntity.php - About 5 hrs to fix

    EditEntity has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class EditEntity extends ModifyEntity {
    
        public const PARAM_DATA = 'data';
    
        public const PARAM_CLEAR = 'clear';
    Severity: Minor
    Found in repo/includes/Api/EditEntity.php - About 3 hrs to fix

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

          protected function getExamplesMessages(): array {
              $id = $this->sandboxEntityIds[ 'mainItem' ];
      
              return [
                  // Creating new entities
      Severity: Minor
      Found in repo/includes/Api/EditEntity.php - About 1 hr to fix

        Method modifyEntity has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function modifyEntity( EntityDocument $entity, ChangeOp $changeOp, array $preparedParameters ): Summary {
                $data = $preparedParameters[self::PARAM_DATA];
        
                $exists = $this->entityExists( $entity->getId() );
        
        
        Severity: Minor
        Found in repo/includes/Api/EditEntity.php - About 1 hr to fix

          Method validateEntitySpecificParameters has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function validateEntitySpecificParameters(
                  array $preparedParameters,
                  EntityDocument $entity,
                  int $baseRevId
              ): void {
          Severity: Minor
          Found in repo/includes/Api/EditEntity.php - About 1 hr to fix

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

                    ApiMain $mainModule,
                    string $moduleName,
                    IBufferingStatsdDataFactory $statsdDataFactory,
                    EntityRevisionLookup $revisionLookup,
                    EntityIdParser $idParser,
            Severity: Major
            Found in repo/includes/Api/EditEntity.php - About 1 hr to fix

              Function validateEntitySpecificParameters has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function validateEntitySpecificParameters(
                      array $preparedParameters,
                      EntityDocument $entity,
                      int $baseRevId
                  ): void {
              Severity: Minor
              Found in repo/includes/Api/EditEntity.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 modifyEntity has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function modifyEntity( EntityDocument $entity, ChangeOp $changeOp, array $preparedParameters ): Summary {
                      $data = $preparedParameters[self::PARAM_DATA];
              
                      $exists = $this->entityExists( $entity->getId() );
              
              
              Severity: Minor
              Found in repo/includes/Api/EditEntity.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 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      ApiMain $mainModule,
                      string $moduleName,
                      IBufferingStatsdDataFactory $statsdDataFactory,
                      DataTypeDefinitions $dataTypeDefinitions,
                      EntityChangeOpProvider $entityChangeOpProvider,
              Severity: Major
              Found in repo/includes/Api/EditEntity.php - About 1 hr to fix

                There are no issues that match your filters.

                Category
                Status