wikimedia/mediawiki-core

View on GitHub
includes/skins/SkinTemplate.php

Summary

Maintainability
F
1 wk
Test Coverage

File SkinTemplate.php has 1059 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Copyright © Gabriel Wicke -- http://www.aulinx.de/
 *
 * This program is free software; you can redistribute it and/or modify
Severity: Major
Found in includes/skins/SkinTemplate.php - About 2 days to fix

    Function buildContentNavigationUrlsInternal has a Cognitive Complexity of 105 (exceeds 5 allowed). Consider refactoring.
    Open

        private function buildContentNavigationUrlsInternal() {
            if ( $this->contentNavigationCached ) {
                return $this->contentNavigationCached;
            }
            // Display tabs for the relevant title rather than always the title itself
    Severity: Minor
    Found in includes/skins/SkinTemplate.php - About 2 days 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 buildContentNavigationUrlsInternal has 291 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function buildContentNavigationUrlsInternal() {
            if ( $this->contentNavigationCached ) {
                return $this->contentNavigationCached;
            }
            // Display tabs for the relevant title rather than always the title itself
    Severity: Major
    Found in includes/skins/SkinTemplate.php - About 1 day to fix

      SkinTemplate has 36 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class SkinTemplate extends Skin {
          /**
           * @var string For QuickTemplate, the name of the subclass which will
           *   actually fill the template.
           */
      Severity: Minor
      Found in includes/skins/SkinTemplate.php - About 4 hrs to fix

        Method prepareQuickTemplate has 112 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function prepareQuickTemplate() {
                $title = $this->getTitle();
                $request = $this->getRequest();
                $out = $this->getOutput();
                $config = $this->getConfig();
        Severity: Major
        Found in includes/skins/SkinTemplate.php - About 4 hrs to fix

          Method buildPersonalUrls has 97 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function buildPersonalUrls( bool $includeNotifications = true ) {
                  $this->setupTemplateContext();
                  $title = $this->getTitle();
                  $authority = $this->getAuthority();
                  $request = $this->getRequest();
          Severity: Major
          Found in includes/skins/SkinTemplate.php - About 3 hrs to fix

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

                protected function buildPersonalUrls( bool $includeNotifications = true ) {
                    $this->setupTemplateContext();
                    $title = $this->getTitle();
                    $authority = $this->getAuthority();
                    $request = $this->getRequest();
            Severity: Minor
            Found in includes/skins/SkinTemplate.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

            Consider simplifying this complex logical expression.
            Open

                            if ( $this->getAuthority()->probablyCan( 'edit', $title ) ) {
                                // Builds CSS class for talk page links
                                $isTalkClass = $isTalk ? ' istalk' : '';
                                // Whether the user is editing the page
                                $isEditing = $onPage && ( $action == 'edit' || $action == 'submit' );
            Severity: Critical
            Found in includes/skins/SkinTemplate.php - About 2 hrs to fix

              Function getPortletsTemplateData has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function getPortletsTemplateData() {
                      if ( $this->portletsCached ) {
                          return $this->portletsCached;
                      }
                      $portlets = [];
              Severity: Minor
              Found in includes/skins/SkinTemplate.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 getPortletsTemplateData has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function getPortletsTemplateData() {
                      if ( $this->portletsCached ) {
                          return $this->portletsCached;
                      }
                      $portlets = [];
              Severity: Minor
              Found in includes/skins/SkinTemplate.php - About 1 hr to fix

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

                    private function buildContentActionUrls( $content_navigation ) {
                        // content_actions has been replaced with content_navigation for backwards
                        // compatibility and also for skins that just want simple tabs content_actions
                        // is now built by flattening the content_navigation arrays into one
                
                
                Severity: Minor
                Found in includes/skins/SkinTemplate.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 tabAction has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
                        $classes = [];
                        if ( $selected ) {
                            $classes[] = 'selected';
                        }
                Severity: Minor
                Found in includes/skins/SkinTemplate.php - About 1 hr to fix

                  Method makeSearchButtonInternal has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function makeSearchButtonInternal( $mode, $searchData, $attrs = [] ) {
                          switch ( $mode ) {
                              case 'go':
                                  $attrs['value'] ??= wfMessage( 'searcharticle' )->text();
                                  return Html::element(
                  Severity: Minor
                  Found in includes/skins/SkinTemplate.php - About 1 hr to fix

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

                        public function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
                            $classes = [];
                            if ( $selected ) {
                                $classes[] = 'selected';
                            }
                    Severity: Minor
                    Found in includes/skins/SkinTemplate.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 getWatchLinkAttrs has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function getWatchLinkAttrs(
                            string $mode, Authority $performer, Title $title, ?string $action, bool $onPage
                        ): array {
                            $isWatchMode = $action == 'watch';
                            $class = 'mw-watchlink ' . (
                    Severity: Minor
                    Found in includes/skins/SkinTemplate.php - About 1 hr to fix

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

                          private function makeContributionsLink(
                              array &$personal_urls,
                              string $key,
                              ?string $userName = null,
                              bool $active = false
                      Severity: Minor
                      Found in includes/skins/SkinTemplate.php - About 1 hr to fix

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

                            private function getSpecialPageAssociatedNavigationLinks( Title $title ): array {
                                $specialAssociatedNavigationLinks = [];
                                $specialFactory = MediaWikiServices::getInstance()->getSpecialPageFactory();
                                $special = $specialFactory->getPage( $title->getText() );
                                if ( $special === null ) {
                        Severity: Minor
                        Found in includes/skins/SkinTemplate.php - About 1 hr to fix

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

                              public function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
                          Severity: Minor
                          Found in includes/skins/SkinTemplate.php - About 35 mins to fix

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

                                    string $mode, Authority $performer, Title $title, ?string $action, bool $onPage
                            Severity: Minor
                            Found in includes/skins/SkinTemplate.php - About 35 mins to fix

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

                                  private function getWatchLinkAttrs(
                                      string $mode, Authority $performer, Title $title, ?string $action, bool $onPage
                                  ): array {
                                      $isWatchMode = $action == 'watch';
                                      $class = 'mw-watchlink ' . (
                              Severity: Minor
                              Found in includes/skins/SkinTemplate.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

                              Function getSpecialPageAssociatedNavigationLinks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private function getSpecialPageAssociatedNavigationLinks( Title $title ): array {
                                      $specialAssociatedNavigationLinks = [];
                                      $specialFactory = MediaWikiServices::getInstance()->getSpecialPageFactory();
                                      $special = $specialFactory->getPage( $title->getText() );
                                      if ( $special === null ) {
                              Severity: Minor
                              Found in includes/skins/SkinTemplate.php - About 25 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

                              Function prepareQuickTemplate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  protected function prepareQuickTemplate() {
                                      $title = $this->getTitle();
                                      $request = $this->getRequest();
                                      $out = $this->getOutput();
                                      $config = $this->getConfig();
                              Severity: Minor
                              Found in includes/skins/SkinTemplate.php - About 25 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