wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 994 of 1,238 total issues

File MessageWebImporter.php has 402 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/MessageWebImporter.php - About 5 hrs to fix

    File TranslatablePage.php has 396 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      File MoveTranslatableBundleSpecialPage.php has 396 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

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

        Hooks has 41 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Hooks {
            private const PAGEPROP_HAS_LANGUAGES_TAG = 'translate-has-languages-tag';
            /** @var bool Uuugly hacks */
            public static $allowTargetEdit = false;
            /** State flag used by DeleteTranslatableBundleJob for performance optimizations. */
        Severity: Minor
        Found in src/PageTranslation/Hooks.php - About 5 hrs to fix

          Method onChangesListSpecialPageStructuredFilters has 134 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function onChangesListSpecialPageStructuredFilters( $special ): void {
                  $translateRcFilterDefault = $this->config->get( 'TranslateRcFilterDefault' );
                  $defaultFilter = $translateRcFilterDefault !== 'noaction' ?
                      $translateRcFilterDefault :
                      ChangesListStringOptionsFilterGroup::NONE;
          Severity: Major
          Found in src/RecentChangesTranslationFilterHookHandler.php - About 5 hrs to fix

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

                public function execute( $subPage ) {
                    $this->setHeaders();
                    $this->checkPermissions();
            
                    $server = $this->ttmServerFactory->getDefaultForQuerying();
            Severity: Minor
            Found in src/TtmServer/SearchTranslationsSpecialPage.php - About 5 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 initMessages has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                public function initMessages(): void {
                    if ( $this->messages !== null ) {
                        return;
                    }
            
            
            Severity: Minor
            Found in src/MessageLoading/MessageCollection.php - About 5 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 showChanges has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function showChanges( int $limit ): void {
                    $diff = new DifferenceEngine( $this->getContext() );
                    $diff->showDiffStyle();
                    $diff->setReducedLineNumbers();
                    $this->diff = $diff;
            Severity: Minor
            Found in src/Synchronization/ManageGroupsSpecialPage.php - About 5 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 ext.translate.special.pagemigration.js has 378 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            ( function () {
                'use strict';
                var noOfSourceUnits, noOfTranslationUnits,
                    pageName = '',
                    langCode = '',
            Severity: Minor
            Found in resources/js/ext.translate.special.pagemigration.js - About 5 hrs to fix

              Function draw has 123 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  draw: function() {
                      var me = this;
                      var opts = me.options;
                      var labelOpts = opts.labels;
                      var globalDefaults = core_defaults.global;
              Severity: Major
              Found in resources/lib/Chart.js/Chart.js - About 4 hrs to fix

                Function addMessageUpdateChanges has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function addMessageUpdateChanges(
                        FileBasedMessageGroup $group,
                        string $language,
                        MessageSourceChange $changes,
                        int $reason,
                Severity: Minor
                Found in src/Synchronization/ExternalMessageSourceStateComparator.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 ext.translate.special.aggregategroups.js has 370 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                ( function () {
                    'use strict';
                
                    function getApiParams( $target ) {
                        return {
                Severity: Minor
                Found in resources/js/ext.translate.special.aggregategroups.js - About 4 hrs to fix

                  Function assign has 122 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function assign( ta ) {
                          if ( !ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has( ta ) ) { return; }
                  
                          var heightOffset = null,
                           clientWidth = null,
                  Severity: Major
                  Found in resources/lib/jquery.autosize.js - About 4 hrs to fix

                    TranslatablePage has 37 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class TranslatablePage extends TranslatableBundle {
                        /**
                         * List of keys in the metadata table that need to be handled for moves and deletions
                         * @phpcs-require-sorted-array
                         */
                    Severity: Minor
                    Found in src/PageTranslation/TranslatablePage.php - About 4 hrs to fix

                      Method showConfirmation has 116 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function showConfirmation( PageMoveCollection $pageCollection, TranslatableBundle $bundle ): void {
                              $out = $this->getOutput();
                              $out->addBacklinkSubtitle( $this->oldTitle );
                              $out->addWikiMsg(
                                  'pt-movepage-intro',
                      Severity: Major
                      Found in src/PageTranslation/MoveTranslatableBundleSpecialPage.php - About 4 hrs to fix

                        Function parseFile has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function parseFile( string $csvFilePath ): Status {
                                if ( !file_exists( $csvFilePath ) || !is_file( $csvFilePath ) ) {
                                    return Status::newFatal(
                                        "CSV file path '$csvFilePath' does not exist, is not readable or is not a file"
                                    );
                        Severity: Minor
                        Found in src/MessageGroupProcessing/CsvTranslationImporter.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 getGraphData has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function getGraphData( TranslationStatsGraphOptions $opts, Language $language ): array {
                                $dbr = $this->dbProvider->getReplicaDatabase();
                        
                                $so = $this->getStatsProvider( $opts->getValue( 'count' ), $opts );
                        
                        
                        Severity: Minor
                        Found in src/Statistics/TranslationStatsDataProvider.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 114 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function execute( $parameters ) {
                                $this->setHeaders();
                        
                                $user = $this->getUser();
                                $request = $this->getRequest();
                        Severity: Major
                        Found in src/PageTranslation/PageTranslationSpecialPage.php - About 4 hrs to fix

                          File TranslateSpecialPage.php has 355 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

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

                            GroupSynchronizationCache has 35 functions (exceeds 20 allowed). Consider refactoring.
                            Open

                            class GroupSynchronizationCache {
                                private PersistentCache $cache;
                                private int $initialTimeoutSeconds;
                                private int $incrementalTimeoutSeconds;
                                /** @var string Cache tag used for groups */
                            Severity: Minor
                            Found in src/Synchronization/GroupSynchronizationCache.php - About 4 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language