wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 994 of 1,238 total issues

File UpdateMessageJob.php has 312 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/UpdateMessageJob.php - About 3 hrs to fix

    Method showChanges has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function showChanges( int $limit ): void {
            $diff = new DifferenceEngine( $this->getContext() );
            $diff->showDiffStyle();
            $diff->setReducedLineNumbers();
            $this->diff = $diff;
    Severity: Major
    Found in src/Synchronization/ManageGroupsSpecialPage.php - About 3 hrs to fix

      Method doQuery has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function doQuery( string $sourceLanguage, string $targetLanguage, string $text ): array {
              if ( !$this->useWikimediaExtraPlugin() ) {
                  // ElasticTTM is currently not compatible with elasticsearch 2.x/5.x
                  // It needs FuzzyLikeThis ported via the wmf extra plugin
                  throw new RuntimeException( 'The wikimedia extra plugin is mandatory.' );
      Severity: Major
      Found in src/TtmServer/ElasticSearchTtmServer.php - About 3 hrs to fix

        Method getGraphData has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getGraphData( TranslationStatsGraphOptions $opts, Language $language ): array {
                $dbr = $this->dbProvider->getReplicaDatabase();
        
                $so = $this->getStatsProvider( $opts->getValue( 'count' ), $opts );
        
        
        Severity: Major
        Found in src/Statistics/TranslationStatsDataProvider.php - About 3 hrs to fix

          Function showTranslationMemory has 86 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  showTranslationMemory: function ( translations ) {
                      if ( !translations.length ) {
                          return;
                      }
          
          
          Severity: Major
          Found in resources/js/ext.translate.editor.helpers.js - About 3 hrs to fix

            Function sendNotifications has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                public function sendNotifications( array $changesToProcess ): void {
                    if ( !$this->isEnabled() || $changesToProcess === [] ) {
                        return;
                    }
            
            
            Severity: Minor
            Found in src/MessageGroupProcessing/MessageGroupSubscription.php - About 3 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 ActiveLanguagesSpecialPage.php has 308 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/ActiveLanguagesSpecialPage.php - About 3 hrs to fix

              MessageGroupOld has 28 functions (exceeds 20 allowed). Consider refactoring.
              Open

              abstract class MessageGroupOld implements MessageGroup {
                  /**
                   * Human-readable name of this group
                   * @var string
                   */
              Severity: Minor
              Found in messagegroups/MessageGroupOld.php - About 3 hrs to fix

                Function displayEmptyListHelp has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        displayEmptyListHelp: function () {
                            var messageTable = this,
                                // @todo Ugly! This should be provided somehow
                                selectedTab = $( '.tux-message-selector .selected' ).data( 'title' ),
                                $wrap = $( '<div>' ).addClass( 'tux-empty-list' ),
                Severity: Major
                Found in resources/js/ext.translate.messagetable.js - About 3 hrs to fix

                  Function displayPagesToMove has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function displayPagesToMove( PageMoveCollection $pageCollection, bool $leaveRedirect ): void {
                          $infoMessage = "\nThe following pages will be moved:\n";
                          $count = 0;
                          $subpagesCount = 0;
                          $talkpagesCount = 0;
                  Severity: Minor
                  Found in src/PageTranslation/MoveTranslatableBundleMaintenanceScript.php - About 3 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 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function execute() {
                          $codes = MediaWikiServices::getInstance()
                              ->getLanguageNameUtils()
                              ->getLanguageNames( LanguageNameUtils::AUTONYMS, LanguageNameUtils::ALL );
                  
                  
                  Severity: Minor
                  Found in scripts/createCheckIndex.php - About 3 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 createMessageGroup has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function createMessageGroup( string $id, array $info ): MessageGroup {
                          $conf = [];
                          $conf['BASIC']['class'] = MediaWikiExtensionMessageGroup::class;
                          $conf['BASIC']['id'] = $id;
                          $conf['BASIC']['namespace'] = $this->getNamespace();
                  Severity: Minor
                  Found in src/MessageGroupConfiguration/PremadeMediaWikiExtensionGroups.php - About 3 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 identifySafeLanguages has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function identifySafeLanguages(
                          FileBasedMessageGroup $group,
                          MessageSourceChange $changesForGroup,
                          int $importStrategy
                      ): array {
                  Severity: Minor
                  Found in src/Synchronization/ExternalMessageSourceStateImporter.php - About 3 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 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;
                          }
                  
                  
                  Severity: Minor
                  Found in src/FileFormatSupport/GettextFormat.php - About 3 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 showLanguages has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function showLanguages() {
                          var ulslanguages = [],
                              selectedClasss = '',
                              quickLanguageList = [],
                              unique = [];
                  Severity: Major
                  Found in resources/js/ext.translate.special.searchtranslations.js - About 3 hrs to fix

                    Method showAggregateGroup has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function showAggregateGroup( AggregateMessageGroup $group ): string {
                            $id = $group->getId();
                            $label = $group->getLabel();
                            $desc = $group->getDescription( $this->getContext() );
                            $sourceLanguage = $this->messageGroupMetadata->get( $id, 'sourcelanguagecode' );
                    Severity: Major
                    Found in src/MessageGroupProcessing/AggregateGroupsSpecialPage.php - About 3 hrs to fix

                      File MessageIndex.php has 301 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

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

                        Function load has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                load: function ( limit ) {
                                    var self = this,
                                        offset = this.$loader.data( 'offset' ),
                                        pageSize = limit || this.$loader.data( 'pagesize' );
                        
                        
                        Severity: Major
                        Found in resources/js/ext.translate.messagetable.js - About 3 hrs to fix

                          Method execute has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function execute() {
                                  $this->checkUserRightsAny( 'pagetranslation' );
                          
                                  $params = $this->extractRequestParams();
                                  $title = $this->getTitleFromTitleOrPageId( $params );
                          Severity: Major
                          Found in src/PageTranslation/MarkForTranslationActionApi.php - About 3 hrs to fix

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

                                public function __construct() {
                                    parent::__construct();
                                    $this->addDescription( 'Export translations to files.' );
                            
                                    $this->addOption(
                            Severity: Major
                            Found in src/Synchronization/ExportTranslationsMaintenanceScript.php - About 3 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language