wikimedia/mediawiki-extensions-Wikibase

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

Summary

Maintainability
D
3 days
Test Coverage

File MediaWikiEditEntity.php has 435 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare( strict_types = 1 );

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

    MediaWikiEditEntity has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MediaWikiEditEntity implements EditEntity {
    
        private EntityRevisionLookup $entityRevisionLookup;
        private EntityTitleStoreLookup $titleLookup;
        private EntityStore $entityStore;
    Severity: Minor
    Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 3 hrs to fix

      Method attemptSave has 90 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function attemptSave( EntityDocument $newEntity, string $summary, $flags, $token, $watch = null, array $tags = [] ) {
              $this->checkReadOnly( $newEntity ); // throws, exception formatted by MediaWiki (cf. MWExceptionRenderer::getExceptionTitle)
              $this->checkEntityId( $newEntity->getId() ); // throws internal error (unexpected condition)
      
              $watch = $this->getDesiredWatchState( $watch );
      Severity: Major
      Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 3 hrs to fix

        Function attemptSave has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public function attemptSave( EntityDocument $newEntity, string $summary, $flags, $token, $watch = null, array $tags = [] ) {
                $this->checkReadOnly( $newEntity ); // throws, exception formatted by MediaWiki (cf. MWExceptionRenderer::getExceptionTitle)
                $this->checkEntityId( $newEntity->getId() ); // throws internal error (unexpected condition)
        
                $watch = $this->getDesiredWatchState( $watch );
        Severity: Minor
        Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 2 hrs 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 15 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                EntityTitleStoreLookup $titleLookup,
                EntityRevisionLookup $entityLookup,
                EntityStore $entityStore,
                EntityPermissionChecker $permissionChecker,
                EntityDiffer $entityDiffer,
        Severity: Major
        Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 1 hr to fix

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

              private function fixEditConflict( EntityDocument $newEntity ): ?EntityDocument {
                  $baseRev = $this->getBaseRevision();
                  $latestRev = $this->getLatestRevision();
          
                  if ( !$latestRev ) {
          Severity: Minor
          Found in repo/includes/EditEntity/MediaWikiEditEntity.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 fixEditConflict has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function fixEditConflict( EntityDocument $newEntity ): ?EntityDocument {
                  $baseRev = $this->getBaseRevision();
                  $latestRev = $this->getLatestRevision();
          
                  if ( !$latestRev ) {
          Severity: Minor
          Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 1 hr to fix

            Method attemptSave has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function attemptSave( EntityDocument $newEntity, string $summary, $flags, $token, $watch = null, array $tags = [] ) {
            Severity: Minor
            Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 45 mins to fix

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

                  public function getBaseRevision(): ?EntityRevision {
                      if ( $this->baseRev === null ) {
                          $baseRevId = $this->getBaseRevisionId();
              
                          if ( $baseRevId === $this->getLatestRevisionId() ) {
              Severity: Minor
              Found in repo/includes/EditEntity/MediaWikiEditEntity.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

              Avoid too many return statements within this method.
              Open

                          return $this->status;
              Severity: Major
              Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return $this->status;
                Severity: Major
                Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return $this->status;
                  Severity: Major
                  Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return $patchedLatest;
                    Severity: Major
                    Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return $this->status;
                      Severity: Major
                      Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return $this->status;
                        Severity: Major
                        Found in repo/includes/EditEntity/MediaWikiEditEntity.php - About 30 mins to fix

                          There are no issues that match your filters.

                          Category
                          Status