wikimedia/mediawiki-extensions-Wikibase

View on GitHub
repo/includes/Actions/EditEntityAction.php

Summary

Maintainability
D
2 days
Test Coverage

File EditEntityAction.php has 359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare( strict_types = 1 );

namespace Wikibase\Repo\Actions;
Severity: Minor
Found in repo/includes/Actions/EditEntityAction.php - About 4 hrs to fix

    Function getStatus has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getStatus( WebRequest $req, RevisionRecord $latestRevision ): Status {
            if ( $req->getCheck( 'restore' ) ) { // nearly the same as undoafter without undo
                $olderRevision = $this->revisionLookup->getRevisionById( $req->getInt( 'restore' ) );
    
                if ( !$olderRevision ) {
    Severity: Minor
    Found in repo/includes/Actions/EditEntityAction.php - About 3 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 showUndoForm has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function showUndoForm(): void {
            $this->getOutput()->enableOOUI();
            $req = $this->getRequest();
    
            if ( $this->showPermissionError( 'read' ) || $this->showPermissionError( 'edit' ) ) {
    Severity: Major
    Found in repo/includes/Actions/EditEntityAction.php - About 2 hrs to fix

      Method getStatus has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function getStatus( WebRequest $req, RevisionRecord $latestRevision ): Status {
              if ( $req->getCheck( 'restore' ) ) { // nearly the same as undoafter without undo
                  $olderRevision = $this->revisionLookup->getRevisionById( $req->getInt( 'restore' ) );
      
                  if ( !$olderRevision ) {
      Severity: Minor
      Found in repo/includes/Actions/EditEntityAction.php - About 2 hrs to fix

        Function showUndoForm has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            private function showUndoForm(): void {
                $this->getOutput()->enableOOUI();
                $req = $this->getRequest();
        
                if ( $this->showPermissionError( 'read' ) || $this->showPermissionError( 'edit' ) ) {
        Severity: Minor
        Found in repo/includes/Actions/EditEntityAction.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 showConfirmationForm has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function showConfirmationForm( int $autoSummaryLength, int $undidRevision = 0 ): void {
                $req = $this->getRequest();
        
                $args = [
                    'action' => 'submit',
        Severity: Minor
        Found in repo/includes/Actions/EditEntityAction.php - About 1 hr to fix

          Method displayUndoDiff has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function displayUndoDiff( EntityContentDiff $diff ): void {
                  $tableClass = 'diff diff-contentalign-' . $this->getTitle()->getPageLanguage()->alignStart();
          
                  // add Wikibase styles, the diff may include entity links with labels, including fallback indicators
                  $this->getOutput()->addModuleStyles( [ 'wikibase.alltargets' ] );
          Severity: Minor
          Found in repo/includes/Actions/EditEntityAction.php - About 1 hr to fix

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

                    Article $article,
                    IContextSource $context,
                    PermissionManager $permissionManager,
                    RevisionLookup $revisionLookup,
                    AnonymousEditWarningBuilder $anonymousEditWarningBuilder,
            Severity: Major
            Found in repo/includes/Actions/EditEntityAction.php - About 50 mins to fix

              Avoid too many return statements within this method.
              Open

                          return Status::newFatal( 'edit_form_incomplete' ); //XXX: better message?
              Severity: Major
              Found in repo/includes/Actions/EditEntityAction.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return Status::newFatal( 'wikibase-undo-badpage', $this->getTitle(), $newerRevision->getId() );
                Severity: Major
                Found in repo/includes/Actions/EditEntityAction.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return Status::newFatal( 'wikibase-undo-samerev', $this->getTitle() );
                  Severity: Major
                  Found in repo/includes/Actions/EditEntityAction.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return Status::newFatal( 'wikibase-undo-badpage', $this->getTitle(), $olderRevision->getId() );
                    Severity: Major
                    Found in repo/includes/Actions/EditEntityAction.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return Status::newFatal( 'wikibase-undo-nocontent', $this->getTitle(), $olderRevision->getId() );
                      Severity: Major
                      Found in repo/includes/Actions/EditEntityAction.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return Status::newFatal( 'wikibase-undo-nocontent', $this->getTitle(), $newerRevision->getId() );
                        Severity: Major
                        Found in repo/includes/Actions/EditEntityAction.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return Status::newFatal( 'undo-norev', $req->getInt( 'undo' ) );
                          Severity: Major
                          Found in repo/includes/Actions/EditEntityAction.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return Status::newFatal( 'wikibase-undo-nocontent', $this->getTitle(), $latestRevision->getId() );
                            Severity: Major
                            Found in repo/includes/Actions/EditEntityAction.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                      return Status::newGood( [ $olderRevision, $newerRevision, $latestRevision ] );
                              Severity: Major
                              Found in repo/includes/Actions/EditEntityAction.php - About 30 mins to fix

                                There are no issues that match your filters.

                                Category
                                Status