wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 994 of 1,238 total issues

File ExportTranslationsMaintenanceScript.php has 353 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace MediaWiki\Extension\Translate\Synchronization;

use FileBasedMessageGroup;
Severity: Minor
Found in src/Synchronization/ExportTranslationsMaintenanceScript.php - About 4 hrs to fix

    Function prepareInfoColumn has 111 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            prepareInfoColumn: function () {
                var $infoColumn = $( '<div>' ).addClass( 'infocolumn' ),
                    translateEditor = this;
    
                $infoColumn.append( $( '<div>' )
    Severity: Major
    Found in resources/js/ext.translate.editor.js - About 4 hrs to fix

      Method run has 111 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function run( ApiPageSet $resultPageSet = null ): void {
              $params = $this->extractRequestParams();
      
              $group = MessageGroups::getGroup( $params['group'] );
              if ( !$group ) {
      Severity: Major
      Found in src/MessageLoading/QueryMessageCollectionActionApi.php - About 4 hrs to fix

        Function parse has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

            public function parse() {
                $data = file_get_contents( $this->file );
                $data = TextContent::normalizeLineEndings( $data );
        
                $matches = [];
        Severity: Minor
        Found in scripts/poimport.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

        File GroupSynchronizationCache.php has 348 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        declare( strict_types = 1 );
        
        namespace MediaWiki\Extension\Translate\Synchronization;
        
        
        Severity: Minor
        Found in src/Synchronization/GroupSynchronizationCache.php - About 4 hrs to fix

          MessageSourceChange has 34 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class MessageSourceChange {
              /**
               * @var array[][][]
               * @phpcs:ignore Generic.Files.LineLength
               * @phan-var array<string,array<string,array<string|int,array{key:string,content:string,similarity?:float,matched_to?:string,previous_state?:string}>>>
          Severity: Minor
          Found in src/MessageSync/MessageSourceChange.php - About 4 hrs to fix

            File LanguageStatsSpecialPage.php has 346 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            declare( strict_types = 1 );
            
            namespace MediaWiki\Extension\Translate\Statistics;
            
            
            Severity: Minor
            Found in src/Statistics/LanguageStatsSpecialPage.php - About 4 hrs to fix

              Method languages has 107 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function languages( $data, $params, $parser ) {
                      global $wgPageTranslationLanguageList;
              
                      if ( $wgPageTranslationLanguageList === 'sidebar-only' ) {
                          return '';
              Severity: Major
              Found in src/PageTranslation/Hooks.php - About 4 hrs to fix

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

                    public function execute() {
                        $handle = fopen( $this->getArg( 0 ), 'r' );
                        // remove heading
                        // @phan-suppress-next-line PhanPluginUseReturnValueInternalKnown
                        fgets( $handle );
                Severity: Minor
                Found in scripts/translator-stats-process.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

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

                    public static function onGetUserPermissionsErrorsExpensive(
                        Title $title,
                        User $user,
                        $action,
                        &$result
                Severity: Minor
                Found in src/PageTranslation/Hooks.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

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

                    public function execute( $par ) {
                        $request = $this->getRequest();
                
                        $purge = $request->getVal( 'action' ) === 'purge';
                        if ( $purge && !$request->wasPosted() ) {
                Severity: Minor
                Found in src/Statistics/MessageGroupStatsSpecialPage.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

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

                    public function execute() {
                        $config = $this->getConfig();
                        $logger = LoggerFactory::getInstance( 'Translate.GroupSynchronization' );
                        $groupPattern = $this->getOption( 'group' ) ?? '';
                        $logger->info(
                Severity: Minor
                Found in src/Synchronization/BackportTranslationsMaintenanceScript.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

                Function displayRequestDetails has 105 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function displayRequestDetails( request ) {
                        var $reminderStatus = $( '<span>' ).addClass( 'reminder-status' ),
                            $detailsPane = $( '.details.pane' );
                        if ( request.reminderscount ) {
                            var agoText = moment.isMoment( request.lastreminder ) ? moment( request.lastreminder ).fromNow() : request.lastreminder;
                Severity: Major
                Found in resources/js/ext.translate.special.managetranslatorsandbox.js - About 4 hrs to fix

                  ElasticSearchTtmServer has 33 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class ElasticSearchTtmServer
                      extends TtmServer
                      implements ReadableTtmServer, WritableTtmServer, SearchableTtmServer
                  {
                      /**
                  Severity: Minor
                  Found in src/TtmServer/ElasticSearchTtmServer.php - About 4 hrs to fix

                    Method formatChange has 104 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function formatChange(
                            MessageGroup $group,
                            MessageSourceChange $changes,
                            string $language,
                            string $type,
                    Severity: Major
                    Found in src/Synchronization/ManageGroupsSpecialPage.php - About 4 hrs to fix

                      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();
                      Severity: Minor
                      Found in src/PageTranslation/PageTranslationSpecialPage.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

                      Function execute has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function execute(): void {
                              $params = $this->extractRequestParams();
                              $filter = $params['filter'];
                      
                              $groups = [];
                      Severity: Minor
                      Found in src/MessageGroupProcessing/QueryMessageGroupsActionApi.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 execute has 102 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function execute( $par ) {
                              $request = $this->getRequest();
                      
                              $purge = $request->getVal( 'action' ) === 'purge';
                              if ( $purge && !$request->wasPosted() ) {
                      Severity: Major
                      Found in src/Statistics/MessageGroupStatsSpecialPage.php - About 4 hrs to fix

                        Function positionElement has 100 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function positionElement( $targetElem, options ) {
                            // Make a copy, we don't want to modify arguments
                            options = $.extend( {}, options );
                        
                            var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
                        Severity: Major
                        Found in resources/src/ext.translate.groupselector/ui.position.js - About 4 hrs to fix

                          Function listGroups has 98 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function listGroups( groupList, parentGrouppath, $parent, level ) {
                                  var selectedClass = '',
                                      maxListSize = 10,
                                      currentGroup = $( '.facet.groups' ).data( 'group' ),
                                      resultCount = groupList.length;
                          Severity: Major
                          Found in resources/js/ext.translate.special.searchtranslations.js - About 3 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language