wikimedia/mediawiki-core

View on GitHub
includes/specials/pagers/AllMessagesTablePager.php

Summary

Maintainability
D
1 day
Test Coverage

File AllMessagesTablePager.php has 265 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
Severity: Minor
Found in includes/specials/pagers/AllMessagesTablePager.php - About 2 hrs to fix

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

        public function formatValue( $field, $value ) {
            $linkRenderer = $this->getLinkRenderer();
            switch ( $field ) {
                case 'am_title':
                    $title = Title::makeTitle( NS_MEDIAWIKI, $value . $this->suffix );
    Severity: Minor
    Found in includes/specials/pagers/AllMessagesTablePager.php - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

                  if ( $customised !== $this->custom &&
                      ( ( $asc && ( $key < $offset || !$offset ) ) || ( !$asc && $key > $offset ) ) &&
                      ( ( $this->prefix && preg_match( $this->prefix, $key ) ) || $this->prefix === false )
                  ) {
                      $actual = $this->msg( $key )->inLanguage( $this->lang )->plain();
      Severity: Critical
      Found in includes/specials/pagers/AllMessagesTablePager.php - About 1 hr to fix

        Function getCustomisedStatuses has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function getCustomisedStatuses(
                $messageNames,
                $langcode = 'en',
                $foreign = false,
                IReadableDatabase $dbr = null
        Severity: Minor
        Found in includes/specials/pagers/AllMessagesTablePager.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 reallyDoQuery has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function reallyDoQuery( $offset, $limit, $order ) {
                $asc = ( $order === self::QUERY_ASCENDING );
        
                $messageNames = $this->getAllMessages( $order );
                $statuses = self::getCustomisedStatuses(
        Severity: Minor
        Found in includes/specials/pagers/AllMessagesTablePager.php - About 1 hr to fix

          Method getCustomisedStatuses has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function getCustomisedStatuses(
                  $messageNames,
                  $langcode = 'en',
                  $foreign = false,
                  IReadableDatabase $dbr = null
          Severity: Minor
          Found in includes/specials/pagers/AllMessagesTablePager.php - About 1 hr to fix

            Method __construct has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function __construct(
                    IContextSource $context,
                    Language $contentLanguage,
                    LanguageFactory $languageFactory,
                    LinkRenderer $linkRenderer,
            Severity: Minor
            Found in includes/specials/pagers/AllMessagesTablePager.php - About 1 hr to fix

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

                  public function reallyDoQuery( $offset, $limit, $order ) {
                      $asc = ( $order === self::QUERY_ASCENDING );
              
                      $messageNames = $this->getAllMessages( $order );
                      $statuses = self::getCustomisedStatuses(
              Severity: Minor
              Found in includes/specials/pagers/AllMessagesTablePager.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 __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      IContextSource $context,
                      Language $contentLanguage,
                      LanguageFactory $languageFactory,
                      LinkRenderer $linkRenderer,
                      IConnectionProvider $dbProvider,
              Severity: Major
              Found in includes/specials/pagers/AllMessagesTablePager.php - About 50 mins to fix

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

                    protected function getCellAttrs( $field, $value ) {
                        $attr = [];
                        if ( $field === 'am_title' ) {
                            if ( $this->mCurrentRow->am_customised ) {
                                $attr += [ 'rowspan' => '2' ];
                Severity: Minor
                Found in includes/specials/pagers/AllMessagesTablePager.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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function __construct(
                        IContextSource $context,
                        Language $contentLanguage,
                        LanguageFactory $languageFactory,
                        LinkRenderer $linkRenderer,
                Severity: Minor
                Found in includes/specials/pagers/AllMessagesTablePager.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