wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 994 of 1,238 total issues

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

    HookHandler has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class HookHandler implements
        ChangeTagsListActiveHook,
        ListDefinedTagsHook,
        ParserFirstCallInitHook,
        RevisionRecordInsertedHook,
    Severity: Minor
    Found in src/HookHandler.php - About 3 hrs to fix

      MessageGroupStats has 27 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class MessageGroupStats {
          /** Name of the database table */
          private const TABLE = 'translate_groupstats';
          /** Cache key for storage of all language stats */
          private const LANGUAGE_STATS_KEY = 'translate-all-language-stats';
      Severity: Minor
      Found in src/Statistics/MessageGroupStats.php - About 3 hrs to fix

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

            public function execute() {
                $dbr = $this->getDB( DB_REPLICA );
        
                $users = $dbr->newSelectQueryBuilder()
                    ->select( [
        Severity: Major
        Found in scripts/translator-stats.php - About 3 hrs to fix

          Function determineDataLimits has 79 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              determineDataLimits: function() {
                  var me = this;
                  var opts = me.options;
                  var chart = me.chart;
                  var datasets = chart.data.datasets;
          Severity: Major
          Found in resources/lib/Chart.js/Chart.js - About 3 hrs to fix

            Method addMessageUpdateChanges has 79 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function addMessageUpdateChanges(
                    FileBasedMessageGroup $group,
                    string $language,
                    MessageSourceChange $changes,
                    int $reason,
            Severity: Major
            Found in src/Synchronization/ExternalMessageSourceStateComparator.php - About 3 hrs to fix

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

                  public function execute() {
                      $dbr = $this->getDB( DB_REPLICA );
              
                      $users = $dbr->newSelectQueryBuilder()
                          ->select( [
              Severity: Minor
              Found in scripts/translator-stats.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 replaceSubtitle has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function replaceSubtitle( &$subpages, ?Skin $skin, OutputPage $out ) {
                      $linker = MediaWikiServices::getInstance()->getLinkRenderer();
              
                      $isTranslationPage = TranslatablePage::isTranslationPage( $out->getTitle() );
                      if ( !$isTranslationPage
              Severity: Minor
              Found in src/PageTranslation/Hooks.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 processSubmit has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function processSubmit(): void {
                      $req = $this->getRequest();
                      $out = $this->getOutput();
                      $errorGroups = [];
              
              
              Severity: Minor
              Found in src/Synchronization/ManageGroupsSpecialPage.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 setupTranslate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function setupTranslate(): void {
                      global $wgTranslateYamlLibrary, $wgLogTypes;
                      $hooks = [];
              
                      /*
              Severity: Minor
              Found in src/HookHandler.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 getParentGroups has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function getParentGroups( MessageGroup $targetGroup ): array {
                      $ids = self::getSharedGroups( $targetGroup );
                      if ( $ids === [] ) {
                          return [];
                      }
              Severity: Minor
              Found in src/MessageGroupProcessing/MessageGroups.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 getTranslatableLanguages has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getTranslatableLanguages() {
                      $groupConfiguration = $this->getConfiguration();
                      if ( !isset( $groupConfiguration['LANGUAGES'] ) ) {
                          // No LANGUAGES section in the configuration.
                          return null;
              Severity: Minor
              Found in messagegroups/MessageGroupBase.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

              Method showTranslationSettings has 77 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function showTranslationSettings( Title $target, ?ErrorPageError $block ): void {
                      $out = $this->getOutput();
                      $out->setPageTitle( $this->msg( 'tpt-translation-settings-page-title' )->text() );
              
                      $currentState = $this->translatablePageStateStore->get( $target );
              Severity: Major
              Found in src/PageTranslation/PageTranslationSpecialPage.php - About 3 hrs to fix

                Function update has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    update: function(changed) {
                        var me = this;
                        var opts = me._options;
                
                        // Need to regenerate the model because its faster than using extend and it is necessary due to the optimization in Chart.Element.transition
                Severity: Major
                Found in resources/lib/Chart.js/Chart.js - About 3 hrs to fix

                  Function render has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          render: function () {
                              // List of all reviewers
                              var reviewers = this.message.properties.reviewers || [];
                              // The id of the current user, converted to string as the are in reviewers
                              var userId = String( mw.config.get( 'wgUserId' ) );
                  Severity: Major
                  Found in resources/js/ext.translate.proofread.js - About 3 hrs to fix

                    Function fit has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        fit: function() {
                            var me = this;
                            var opts = me.options;
                            var labelOpts = opts.labels;
                            var display = opts.display;
                    Severity: Major
                    Found in resources/lib/Chart.js/Chart.js - About 3 hrs to fix

                      Method rebuild has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function rebuild( float $timestamp = null ): array {
                              static $recursion = 0;
                      
                              if ( $recursion > 0 ) {
                                  $msg = __METHOD__ . ': trying to recurse - building the index first time?';
                      Severity: Major
                      Found in src/MessageLoading/MessageIndex.php - About 3 hrs to fix

                        Function addTranslate has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                addTranslate: function ( message ) {
                                    var targetLangCode = this.$container.data( 'targetlangcode' ),
                                        sourceLangCode = this.$container.data( 'sourcelangcode' ),
                                        sourceLangDir = $.uls.data.getDir( sourceLangCode ),
                                        status = message.properties.status,
                        Severity: Major
                        Found in resources/js/ext.translate.messagetable.js - About 3 hrs to fix

                          PageTranslationSpecialPage has 26 functions (exceeds 20 allowed). Consider refactoring.
                          Open

                          class PageTranslationSpecialPage extends SpecialPage {
                              private const DISPLAY_STATUS_MAPPING = [
                                  TranslatablePageStatus::PROPOSED => 'proposed',
                                  TranslatablePageStatus::ACTIVE => 'active',
                                  TranslatablePageStatus::OUTDATED => 'outdated',
                          Severity: Minor
                          Found in src/PageTranslation/PageTranslationSpecialPage.php - About 3 hrs to fix

                            Method displayPagesToMove has 75 lines of code (exceeds 25 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: Major
                            Found in src/PageTranslation/MoveTranslatableBundleMaintenanceScript.php - About 3 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language