wikimedia/mediawiki-core

View on GitHub
includes/skins/BaseTemplate.php

Summary

Maintainability
C
1 day
Test Coverage

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

    protected function getSidebar( $options = [] ) {
        // Force the rendering of the following portals
        $sidebar = $this->data['sidebar'];
        if ( !isset( $sidebar['SEARCH'] ) ) {
            // @phan-suppress-next-line PhanTypeMismatchDimAssignment False positive
Severity: Minor
Found in includes/skins/BaseTemplate.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 getSidebar has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function getSidebar( $options = [] ) {
        // Force the rendering of the following portals
        $sidebar = $this->data['sidebar'];
        if ( !isset( $sidebar['SEARCH'] ) ) {
            // @phan-suppress-next-line PhanTypeMismatchDimAssignment False positive
Severity: Major
Found in includes/skins/BaseTemplate.php - About 3 hrs to fix

    Method getFooter has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function getFooter( $iconStyle = 'icononly', $linkStyle = 'flat' ) {
            $validFooterIcons = $this->get( 'footericons' );
            if ( $iconStyle === 'icononly' ) {
                $this->unsetIconsWithoutImages( $validFooterIcons );
            } else {
    Severity: Minor
    Found in includes/skins/BaseTemplate.php - About 1 hr to fix

      Function getFooter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getFooter( $iconStyle = 'icononly', $linkStyle = 'flat' ) {
              $validFooterIcons = $this->get( 'footericons' );
              if ( $iconStyle === 'icononly' ) {
                  $this->unsetIconsWithoutImages( $validFooterIcons );
              } else {
      Severity: Minor
      Found in includes/skins/BaseTemplate.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 getFooterLinks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getFooterLinks( $option = null ) {
              $footerlinks = $this->get( 'footerlinks' );
      
              // Reduce footer links down to only those which are being used
              $validFooterLinks = [];
      Severity: Minor
      Found in includes/skins/BaseTemplate.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 unsetIconsWithoutImages has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          private function unsetIconsWithoutImages( array &$icons ) {
              // Unset any icons which don't have an image
              foreach ( $icons as $iconsKey => &$iconsBlock ) {
                  foreach ( $iconsBlock as $iconKey => $icon ) {
                      if ( !is_string( $icon ) && !isset( $icon['src'] ) ) {
      Severity: Minor
      Found in includes/skins/BaseTemplate.php - About 55 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