wikimedia/mediawiki-core

View on GitHub
includes/specialpage/SpecialPageFactory.php

Summary

Maintainability
F
6 days
Test Coverage

File SpecialPageFactory.php has 1509 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Factory for handling the special page list and generating SpecialPage objects.
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Major
Found in includes/specialpage/SpecialPageFactory.php - About 4 days to fix

    Function getAliasList has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getAliasList(): array {
            if ( $this->aliases === null ) {
                $aliases = $this->contLang->getSpecialPageAliases();
                $pageList = $this->getPageList();
    
    
    Severity: Minor
    Found in includes/specialpage/SpecialPageFactory.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 getPageList has 79 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function getPageList(): array {
            if ( !is_array( $this->list ) ) {
                $this->list = self::CORE_LIST;
    
                if ( !$this->options->get( MainConfigNames::DisableInternalSearch ) ) {
    Severity: Major
    Found in includes/specialpage/SpecialPageFactory.php - About 3 hrs to fix

      Function getLocalNameFor has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getLocalNameFor( $name, $subpage = false ) {
              $aliases = $this->contLang->getSpecialPageAliases();
              $aliasList = $this->getAliasList();
      
              // Find the first alias that maps back to $name
      Severity: Minor
      Found in includes/specialpage/SpecialPageFactory.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

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

          private function getPageList(): array {
              if ( !is_array( $this->list ) ) {
                  $this->list = self::CORE_LIST;
      
                  if ( !$this->options->get( MainConfigNames::DisableInternalSearch ) ) {
      Severity: Minor
      Found in includes/specialpage/SpecialPageFactory.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 capturePath has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function capturePath(
              PageReference $page, IContextSource $context, LinkRenderer $linkRenderer = null
          ) {
              // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgUser
              global $wgTitle, $wgOut, $wgRequest, $wgUser, $wgLang;
      Severity: Minor
      Found in includes/specialpage/SpecialPageFactory.php - About 1 hr to fix

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

            public function executePath( $path, IContextSource $context, $including = false,
                LinkRenderer $linkRenderer = null
            ) {
                if ( $path instanceof PageReference ) {
                    $path = $path->getDBkey();
        Severity: Minor
        Found in includes/specialpage/SpecialPageFactory.php - About 1 hr to fix

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

              public function executePath( $path, IContextSource $context, $including = false,
                  LinkRenderer $linkRenderer = null
              ) {
                  if ( $path instanceof PageReference ) {
                      $path = $path->getDBkey();
          Severity: Minor
          Found in includes/specialpage/SpecialPageFactory.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 getAliasList has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function getAliasList(): array {
                  if ( $this->aliases === null ) {
                      $aliases = $this->contLang->getSpecialPageAliases();
                      $pageList = $this->getPageList();
          
          
          Severity: Minor
          Found in includes/specialpage/SpecialPageFactory.php - About 1 hr to fix

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

                public function getLocalNameFor( $name, $subpage = false ) {
                    $aliases = $this->contLang->getSpecialPageAliases();
                    $aliasList = $this->getAliasList();
            
                    // Find the first alias that maps back to $name
            Severity: Minor
            Found in includes/specialpage/SpecialPageFactory.php - About 1 hr to fix

              Function getUsablePages has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getUsablePages( User $user ): array {
                      $pages = [];
                      foreach ( $this->getPageList() as $name => $rec ) {
                          $page = $this->getPage( $name );
                          if ( $page ) { // not null
              Severity: Minor
              Found in includes/specialpage/SpecialPageFactory.php - About 45 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

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

                      ServiceOptions $options,
                      Language $contLang,
                      ObjectFactory $objectFactory,
                      TitleFactory $titleFactory,
                      HookContainer $hookContainer
              Severity: Minor
              Found in includes/specialpage/SpecialPageFactory.php - About 35 mins to fix

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

                    public function getPage( $name ) {
                        [ $realName, /*...*/ ] = $this->resolveAlias( $name );
                
                        $specialPageList = $this->getPageList();
                
                
                Severity: Minor
                Found in includes/specialpage/SpecialPageFactory.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

                There are no issues that match your filters.

                Category
                Status