wikimedia/mediawiki-core

View on GitHub
includes/actions/McrUndoAction.php

Summary

Maintainability
D
2 days
Test Coverage

File McrUndoAction.php has 388 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Temporary action for MCR undos
 * @file
 * @ingroup Actions
Severity: Minor
Found in includes/actions/McrUndoAction.php - About 5 hrs to fix

    Function onSubmit has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        public function onSubmit( $data ) {
            if ( !$this->getRequest()->getCheck( 'wpSave' ) ) {
                // Diff or preview
                return false;
            }
    Severity: Minor
    Found in includes/actions/McrUndoAction.php - About 4 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 onSubmit has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function onSubmit( $data ) {
            if ( !$this->getRequest()->getCheck( 'wpSave' ) ) {
                // Diff or preview
                return false;
            }
    Severity: Major
    Found in includes/actions/McrUndoAction.php - About 2 hrs to fix

      Method getNewRevision has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function getNewRevision() {
              $undoRev = $this->revisionLookup->getRevisionById( $this->undo );
              $oldRev = $this->revisionLookup->getRevisionById( $this->undoafter );
              $curRev = $this->curRev;
      
      
      Severity: Major
      Found in includes/actions/McrUndoAction.php - About 2 hrs to fix

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

            private function getNewRevision() {
                $undoRev = $this->revisionLookup->getRevisionById( $this->undo );
                $oldRev = $this->revisionLookup->getRevisionById( $this->undoafter );
                $curRev = $this->curRev;
        
        
        Severity: Minor
        Found in includes/actions/McrUndoAction.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 showPreview has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function showPreview( RevisionRecord $rev ) {
                // Mostly copied from EditPage::getPreviewText()
                $out = $this->getOutput();
        
                try {
        Severity: Minor
        Found in includes/actions/McrUndoAction.php - About 1 hr to fix

          Method getFormFields has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function getFormFields() {
                  $request = $this->getRequest();
                  $ret = [
                      'diff' => [
                          'type' => 'info',
          Severity: Minor
          Found in includes/actions/McrUndoAction.php - About 1 hr to fix

            Method show has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function show() {
                    // Send a cookie so anons get talk message notifications
                    // (copied from SubmitAction)
                    MediaWiki\Session\SessionManager::getGlobalSession()->persist();
            
            
            Severity: Minor
            Found in includes/actions/McrUndoAction.php - About 1 hr to fix

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

                      Article $article,
                      IContextSource $context,
                      ReadOnlyMode $readOnlyMode,
                      RevisionLookup $revisionLookup,
                      RevisionRenderer $revisionRenderer,
              Severity: Major
              Found in includes/actions/McrUndoAction.php - About 50 mins to fix

                Avoid too many return statements within this method.
                Open

                        return Status::newGood();
                Severity: Major
                Found in includes/actions/McrUndoAction.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return $updater->getStatus();
                  Severity: Major
                  Found in includes/actions/McrUndoAction.php - About 30 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status