wikimedia/mediawiki-core

View on GitHub
includes/actions/ActionEntryPoint.php

Summary

Maintainability
F
5 days
Test Coverage

Function performRequest has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
Open

    protected function performRequest() {
        global $wgTitle;

        $context = $this->getContext();

Severity: Minor
Found in includes/actions/ActionEntryPoint.php - About 1 day 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

File ActionEntryPoint.php has 468 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace MediaWiki\Actions;

use Action;
Severity: Minor
Found in includes/actions/ActionEntryPoint.php - About 7 hrs to fix

    Function parseTitle has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function parseTitle( $request ) {
            $curid = $request->getInt( 'curid' );
            $title = $request->getText( 'title' );
    
            $ret = null;
    Severity: Minor
    Found in includes/actions/ActionEntryPoint.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 performRequest has 113 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function performRequest() {
            global $wgTitle;
    
            $context = $this->getContext();
    
    
    Severity: Major
    Found in includes/actions/ActionEntryPoint.php - About 4 hrs to fix

      Function initializeArticle has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function initializeArticle() {
              $context = $this->getContext();
      
              $title = $context->getTitle();
              $services = $this->getServiceContainer();
      Severity: Minor
      Found in includes/actions/ActionEntryPoint.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 parseTitle has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function parseTitle( $request ) {
              $curid = $request->getInt( 'curid' );
              $title = $request->getText( 'title' );
      
              $ret = null;
      Severity: Major
      Found in includes/actions/ActionEntryPoint.php - About 2 hrs to fix

        Method tryNormaliseRedirect has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function tryNormaliseRedirect( Title $title ): bool {
                $request = $this->getRequest();
                $output = $this->getOutput();
        
                if ( $request->getRawVal( 'action', 'view' ) != 'view'
        Severity: Minor
        Found in includes/actions/ActionEntryPoint.php - About 1 hr to fix

          Method initializeArticle has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function initializeArticle() {
                  $context = $this->getContext();
          
                  $title = $context->getTitle();
                  $services = $this->getServiceContainer();
          Severity: Minor
          Found in includes/actions/ActionEntryPoint.php - About 1 hr to fix

            Method performAction has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function performAction( Article $article, Title $requestTitle ) {
                    $request = $this->getRequest();
                    $output = $this->getOutput();
                    $title = $this->getTitle();
                    $user = $this->getUser();
            Severity: Minor
            Found in includes/actions/ActionEntryPoint.php - About 1 hr to fix

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

                  protected function execute() {
                      global $wgTitle;
              
                      // Get title from request parameters,
                      // is set on the fly by parseTitle the first time.
              Severity: Minor
              Found in includes/actions/ActionEntryPoint.php - About 1 hr to fix

                Function tryNormaliseRedirect has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function tryNormaliseRedirect( Title $title ): bool {
                        $request = $this->getRequest();
                        $output = $this->getOutput();
                
                        if ( $request->getRawVal( 'action', 'view' ) != 'view'
                Severity: Minor
                Found in includes/actions/ActionEntryPoint.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 performAction has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function performAction( Article $article, Title $requestTitle ) {
                        $request = $this->getRequest();
                        $output = $this->getOutput();
                        $title = $this->getTitle();
                        $user = $this->getUser();
                Severity: Minor
                Found in includes/actions/ActionEntryPoint.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

                Consider simplifying this complex logical expression.
                Open

                        if ( ( $action == 'view' || $action == 'render' ) // ... for actions that show content
                            && !$request->getCheck( 'oldid' ) // ... and are not old revisions
                            && !$request->getCheck( 'diff' ) // ... and not when showing diff
                            && $request->getRawVal( 'redirect' ) !== 'no' // ... unless explicitly told not to
                            // ... and the article is not a non-redirect image page with associated file
                Severity: Critical
                Found in includes/actions/ActionEntryPoint.php - About 1 hr to fix

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

                      protected function execute() {
                          global $wgTitle;
                  
                          // Get title from request parameters,
                          // is set on the fly by parseTitle the first time.
                  Severity: Minor
                  Found in includes/actions/ActionEntryPoint.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

                  Avoid deeply nested control flow statements.
                  Open

                                          if ( $target instanceof Title ) {
                                              if ( $target->isExternal() ) {
                                                  // Handle interwiki redirects
                                                  $target = SpecialPage::getTitleFor(
                                                      'GoToInterwiki',
                  Severity: Major
                  Found in includes/actions/ActionEntryPoint.php - About 45 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                            if ( $request->getRawVal( 'action', 'view' ) != 'view'
                                || $request->wasPosted()
                                || ( $request->getCheck( 'title' )
                                    && $title->getPrefixedDBkey() == $request->getText( 'title' ) )
                                || count( $request->getValueNames( [ 'action', 'title' ] ) )
                    Severity: Major
                    Found in includes/actions/ActionEntryPoint.php - About 40 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status