File GettextFormat.php
has 512 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare( strict_types = 1 );
namespace MediaWiki\Extension\Translate\FileFormatSupport;
Function parseGettextSection
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private function parseGettextSection( string $section, ?int $pluralCount ): ?array {
if ( trim( $section ) === '' ) {
return null;
}
- 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
GettextFormat
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class GettextFormat extends SimpleFormat implements MetaYamlSchemaExtender {
private bool $allowPotMode = false;
private bool $offlineMode = false;
public function supportsFuzzy(): string {
Function parseGettext
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private function parseGettext( string $data ): array {
$mangler = $this->group->getMangler();
$useCtxtAsKey = $this->extra['CtxtAsKey'] ?? false;
$keyAlgorithm = 'simple';
if ( isset( $this->extra['keyAlgorithm'] ) ) {
- 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 parseGettext
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function parseGettext( string $data ): array {
$mangler = $this->group->getMangler();
$useCtxtAsKey = $this->extra['CtxtAsKey'] ?? false;
$keyAlgorithm = 'simple';
if ( isset( $this->extra['keyAlgorithm'] ) ) {
Function formatMessageBlock
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private function formatMessageBlock(
string $key,
Message $message,
array $trans,
array $pot,
- 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 parseGettextSection
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function parseGettextSection( string $section, ?int $pluralCount ): ?array {
if ( trim( $section ) === '' ) {
return null;
}
Method doGettextHeader
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function doGettextHeader( MessageCollection $collection, array $template ): string {
global $wgSitename;
$code = $collection->code;
$name = Utilities::getLanguageName( $code );
Method formatMessageBlock
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function formatMessageBlock(
string $key,
Message $message,
array $trans,
array $pot,
Method writeReal
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function writeReal( MessageCollection $collection ): string {
// FIXME: this should be the source language
$pot = $this->read( 'en' ) ?? [];
$code = $collection->code;
$template = $this->read( $code ) ?? [];
Method formatMessageBlock
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
string $key,
Message $message,
array $trans,
array $pot,
int $pluralCount,
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return GettextPlural::unflatten( $a, $expectedPluralCount )
=== GettextPlural::unflatten( $b, $expectedPluralCount );
Function processGettextPluralMessage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function processGettextPluralMessage( ?int $pluralCount, string $section ): string {
$actualForms = [];
for ( $i = 0; $i < $pluralCount; $i++ ) {
$match = $this->expectKeyword( "msgstr\\[$i\\]", $section );
- 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 doGettextHeader
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function doGettextHeader( MessageCollection $collection, array $template ): string {
global $wgSitename;
$code = $collection->code;
$name = Utilities::getLanguageName( $code );
- 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 isContentEqual
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function isContentEqual( ?string $a, ?string $b ): bool {
if ( $a === $b ) {
return true;
}
- 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"