File PageTranslationSpecialPage.php
has 1046 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare( strict_types = 1 );
namespace MediaWiki\Extension\Translate\PageTranslation;
Method showPage
has 186 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function showPage( TranslatablePageMarkOperation $operation ): void {
$page = $operation->getPage();
$out = $this->getOutput();
$out->addWikiMsg( 'tpt-showpage-intro' );
Method execute
has 114 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute( $parameters ) {
$this->setHeaders();
$user = $this->getUser();
$request = $this->getRequest();
Function execute
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function execute( $parameters ) {
$this->setHeaders();
$user = $this->getUser();
$request = $this->getRequest();
- Read upRead up
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 showPage
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
private function showPage( TranslatablePageMarkOperation $operation ): void {
$page = $operation->getPage();
$out = $this->getOutput();
$out->addWikiMsg( 'tpt-showpage-intro' );
- Read upRead up
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 showTranslationSettings
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function showTranslationSettings( Title $target, ?ErrorPageError $block ): void {
$out = $this->getOutput();
$out->setPageTitle( $this->msg( 'tpt-translation-settings-page-title' )->text() );
$currentState = $this->translatablePageStateStore->get( $target );
PageTranslationSpecialPage
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class PageTranslationSpecialPage extends SpecialPage {
private const DISPLAY_STATUS_MAPPING = [
TranslatablePageStatus::PROPOSED => 'proposed',
TranslatablePageStatus::ACTIVE => 'active',
TranslatablePageStatus::OUTDATED => 'outdated',
Method onActionMark
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function onActionMark( Title $title, ?int $revision ): void {
$request = $this->getRequest();
$out = $this->getOutput();
$translateTitle = $request->getCheck( 'translatetitle' );
Method actionLinks
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function actionLinks( array $page, string $type ): string {
// Performance optimization to avoid calling $this->msg in a loop
static $messageCache = null;
if ( $messageCache === null ) {
$messageCache = [
Method listPages
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function listPages(): void {
$out = $this->getOutput();
$res = self::loadPagesFromDB();
$allPages = self::buildPageArray( $res );
Function onActionMark
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected function onActionMark( Title $title, ?int $revision ): void {
$request = $this->getRequest();
$out = $this->getOutput();
$translateTitle = $request->getCheck( 'translatetitle' );
- Read upRead up
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 priorityLanguagesForm
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function priorityLanguagesForm( TranslatablePage $page ): void {
$groupId = $page->getMessageGroupId();
$interfaceLanguage = $this->getLanguage()->getCode();
$storedLanguages = (string)$this->messageGroupMetadata->get( $groupId, 'prioritylangs' );
$default = $storedLanguages !== '' ? explode( ',', $storedLanguages ) : [];
Function listPages
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function listPages(): void {
$out = $this->getOutput();
$res = self::loadPagesFromDB();
$allPages = self::buildPageArray( $res );
- Read upRead up
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 13 (exceeds 5 allowed). Consider refactoring. Open
private function getPageList( array $pages, string $type ): string {
$items = [];
$tagsTextCache = [];
$tagDiscouraged = $this->msg( 'tpt-tag-discouraged' )->escaped();
- Read upRead up
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 classifyPages
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function classifyPages( array $pages ): array {
$out = [
// The ideal state for pages: marked and up to date
'active' => [],
'proposed' => [],
Method getPageList
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getPageList( array $pages, string $type ): string {
$items = [];
$tagsTextCache = [];
$tagDiscouraged = $this->msg( 'tpt-tag-discouraged' )->escaped();
Function actionLinks
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function actionLinks( array $page, string $type ): string {
// Performance optimization to avoid calling $this->msg in a loop
static $messageCache = null;
if ( $messageCache === null ) {
$messageCache = [
- Read upRead up
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 9 arguments (exceeds 4 allowed). Consider refactoring. Open
LanguageFactory $languageFactory,
LinkBatchFactory $linkBatchFactory,
JobQueueGroup $jobQueueGroup,
PermissionManager $permissionManager,
TranslatablePageMarker $translatablePageMarker,
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return;
Function classifyPages
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function classifyPages( array $pages ): array {
$out = [
// The ideal state for pages: marked and up to date
'active' => [],
'proposed' => [],
- Read upRead up
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 displayStateInfoMessage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function displayStateInfoMessage( Title $title, TranslatableBundleState $bundleState ): void {
$stateId = $bundleState->getStateId();
if ( $stateId === TranslatableBundleState::UNSTABLE ) {
$infoMessage = $this->msg( 'tpt-translation-settings-unstable-notice' );
} elseif ( $stateId === TranslatableBundleState::PROPOSE ) {
- Read upRead up
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"