wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

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

    public function parseDocuments( array $documents ): array {
        $groups = [];
        $template = [];

        foreach ( $documents as $document ) {
Severity: Minor
Found in src/MessageGroupConfiguration/MessageGroupConfigurationParser.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 checkInput has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkInput(): Status {
        $status = Status::newGood();

        $msgGroup = MessageGroups::getGroup( $this->groupId );
        if ( $msgGroup === null ) {
Severity: Minor
Found in src/Synchronization/ExportTranslationsSpecialPage.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 run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function run(): bool {
        $lb = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
        if ( !$lb->waitForReplication() ) {
            $this->logWarning( 'Continuing despite replication lag' );
        }
Severity: Minor
Found in src/Statistics/RebuildMessageGroupStatsJob.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 doAction has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function doAction(
        string $action,
        MessageGroup $group,
        string $key,
        string $message
Severity: Minor
Found in src/Synchronization/MessageWebImporter.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 getSubgroups has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function getSubgroups( string $groupId ): ?array {
        $groups = $this->get( $groupId, 'subgroups' );
        if ( is_string( $groups ) ) {
            if ( str_contains( $groups, '|' ) ) {
                $groups = explode( '|', $groups );
Severity: Minor
Found in src/MessageProcessing/MessageGroupMetadata.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 execute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $mwServices = MediaWikiServices::getInstance();
        $config = $mwServices->getMainConfig();

        if ( !$config->get( 'TranslateGroupSynchronizationCache' ) ) {

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 execute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $name = $this->getOption( 'name', MessageChangeStorage::DEFAULT_NAME );
        if ( !MessageChangeStorage::isValidCdbName( $name ) ) {
            $this->fatalError( 'Invalid name' );
        }
Severity: Minor
Found in src/Synchronization/ImportExternalTranslationsMaintenanceScript.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 getMappedAggregateGroupIds has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function getMappedAggregateGroupIds(): array {
        $groupStructure = MessageGroups::getGroupStructure();
        // Flatten the group structure for easy indexing
        $groupIdAggregateMapped = [];
        foreach ( $groupStructure as $groupId => $mappedGroups ) {
Severity: Minor
Found in src/MessageGroupProcessing/MessageGroupSubscription.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 execute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $ignoreTrailingWhitespace = $this->getOption( 'ignore-trailing-whitespace' );
        $groups = $this->getGroups( $this->getArg( 0 ) );
        $matched = count( $groups );
        $this->output( "Pattern matched $matched file based message group(s).\n" );
Severity: Minor
Found in src/Diagnostics/FindUnsynchronizedDefinitionsMaintenanceScript.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 getNewState has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getNewState( array $stats, array $transitions ) {
        foreach ( $transitions as [ $newState, $conditions ] ) {
            $match = true;

            foreach ( $conditions as $type => $typeConditions ) {
Severity: Minor
Found in src/MessageGroupProcessing/MessageGroupStatesUpdaterJob.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 getGroupsById has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getGroupsById( array $ids, bool $skipMeta = false ): array {
        $groups = [];
        foreach ( $ids as $id ) {
            $group = self::getGroup( $id );

Severity: Minor
Found in src/MessageGroupProcessing/MessageGroups.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 expandWildcards has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public static function expandWildcards( $ids ): array {
        $all = [];

        $ids = (array)$ids;
        foreach ( $ids as $index => $id ) {
Severity: Minor
Found in src/MessageGroupProcessing/MessageGroups.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 listSubgroups has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function listSubgroups( string $groupId, array $subGroupIds ): string {
        $id = $this->htmlIdForGroup( $groupId, 'mw-tpa-grouplist-' );
        $out = Html::openElement( 'ol', [ 'id' => $id ] );

        // Get the respective groups and sort them
Severity: Minor
Found in src/MessageGroupProcessing/AggregateGroupsSpecialPage.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 writeReal has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    protected function writeReal( MessageCollection $collection ): string {
        $header = $this->doHeader( $collection );
        $header .= $this->doAuthors( $collection );
        $header .= "\n";

Severity: Minor
Found in src/FileFormatSupport/AppleFormat.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 readRow has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function readRow( string $line, string $sep ): array {
        if ( !str_contains( $line, '\\' ) ) {
            /* Nothing appears to be escaped in this line.
             * Just read the key and the value. */
            [ $key, $value ] = explode( $sep, $line, 2 );
Severity: Minor
Found in src/FileFormatSupport/JavaFormat.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 write has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function write( MessageCollection $collection ): void {
        $writePath = $this->writePath;

        if ( $writePath === null ) {
            throw new LogicException( 'Write path is not set. Set write path before calling write()' );
Severity: Minor
Found in src/FileFormatSupport/SimpleFormat.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 getDefinitions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDefinitions() {
        if ( !$this->language ) {
                throw new BadMethodCallException( 'Language not set' );
        }

Severity: Minor
Found in messagegroups/RecentMessageGroup.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 getDimensions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function getDimensions( elem ) {
    var raw = elem[ 0 ];
    if ( raw.nodeType === 9 ) {
        return {
            width: elem.width(),
Severity: Minor
Found in resources/src/ext.translate.groupselector/ui.position.js - About 1 hr to fix

    Function hcg has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    convert.rgb.hcg = function (rgb) {
        var r = rgb[0] / 255;
        var g = rgb[1] / 255;
        var b = rgb[2] / 255;
        var max = Math.max(Math.max(r, g), b);
    Severity: Minor
    Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

      Function saveHandler has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function saveHandler() {
              var list = [];
      
              $( '.mw-tpm-sp-error__message' ).addClass( 'hide' );
              if ( noOfSourceUnits < noOfTranslationUnits ) {
      Severity: Minor
      Found in resources/js/ext.translate.special.pagemigration.js - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language