wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 994 of 1,238 total issues

Function getPageMoveCollection has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    public function getPageMoveCollection(
        Title $source,
        ?Title $target,
        User $user,
        string $reason,
Severity: Minor
Found in src/PageTranslation/TranslatableBundleMover.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 readFromVariable has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    public function readFromVariable( string $data ): array {
        $data = TextContent::normalizeLineEndings( $data );
        $lines = array_map( 'ltrim', explode( "\n", $data ) );
        $authors = $messages = [];
        $lineContinuation = false;
Severity: Minor
Found in src/FileFormatSupport/JavaFormat.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 readFromVariable has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    public function readFromVariable( string $data ): array {
        $lines = explode( "\n", $data );
        $authors = $messages = [];
        $linecontinuation = false;

Severity: Minor
Found in src/FileFormatSupport/AppleFormat.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 onLoadExtensionSchemaUpdates has 97 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function onLoadExtensionSchemaUpdates( $updater ) {
        $dir = dirname( __DIR__, 1 ) . '/sql';
        $dbType = $updater->getDB()->getType();

        if ( $dbType === 'mysql' || $dbType === 'sqlite' ) {
Severity: Major
Found in src/SchemaHookHandler.php - About 3 hrs to fix

    File ext.translate.special.searchtranslations.js has 327 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    ( function () {
        'use strict';
    
        var resultGroups;
    
    
    Severity: Minor
    Found in resources/js/ext.translate.special.searchtranslations.js - About 3 hrs to fix

      Function drawPoint has 95 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          drawPoint: function(ctx, style, radius, x, y, rotation) {
              var type, xOffset, yOffset, size, cornerRadius;
              var rad = (rotation || 0) * RAD_PER_DEG;
      
              if (style && typeof style === 'object') {
      Severity: Major
      Found in resources/lib/Chart.js/Chart.js - About 3 hrs to fix

        Method handleFuzzy has 94 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function handleFuzzy( Title $title, bool $invalidate, PageUpdater $updater, int $baseTranver ): void {
                global $wgTranslateDocumentationLanguageCode;
                $editResult = $updater->getEditResult();
                if ( !$invalidate && !$editResult->isExactRevert() ) {
                    return;
        Severity: Major
        Found in src/Synchronization/UpdateMessageJob.php - About 3 hrs to fix

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

              public function execute() {
                  $dryRun = $this->hasOption( 'dry-run' );
                  $ttmServerId = $this->getOption( 'ttmserver' );
                  $shouldReindex = $this->getOption( 'reindex', false );
          
          
          Severity: Minor
          Found in scripts/ttmserver-export.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 showPage has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              private function showPage( TranslatablePageMarkOperation $operation ): void {
                  $page = $operation->getPage();
                  $out = $this->getOutput();
                  $out->addWikiMsg( 'tpt-showpage-intro' );
          
          
          Severity: Minor
          Found in src/PageTranslation/PageTranslationSpecialPage.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 formatChange has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function formatChange(
                  MessageGroup $group,
                  MessageSourceChange $changes,
                  string $language,
                  string $type,
          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 successFunction has 93 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      var successFunction = function ( data ) {
                          var aggregateGroupId = data.aggregategroups.aggregategroupId;
                          var subGroupId = 'tp-subgroup-' + aggregateGroupId;
          
                          var $removeSpan = $( '<span>' ).attr( 'id', aggregateGroupId )
          Severity: Major
          Found in resources/js/ext.translate.special.aggregategroups.js - About 3 hrs to fix

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

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

                  public function execute() {
                      $config = $this->getConfig();
                      $logger = LoggerFactory::getInstance( 'Translate.GroupSynchronization' );
                      $groupPattern = $this->getOption( 'group' ) ?? '';
                      $logger->info(
              Severity: Major
              Found in src/Synchronization/BackportTranslationsMaintenanceScript.php - About 3 hrs to fix

                MessageGroups has 30 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class MessageGroups {
                    /** @var MessageGroup[]|null Map of (group ID => MessageGroup) */
                    private $groups;
                    /** @var MessageGroupLoader[]|null */
                    private $groupLoaders;
                Severity: Minor
                Found in src/MessageGroupProcessing/MessageGroups.php - About 3 hrs to fix

                  Method showTranslations has 91 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function showTranslations( Title $title ): void {
                          $handle = new MessageHandle( $title );
                          $namespace = $title->getNamespace();
                          $message = $handle->getKey();
                  
                  
                  Severity: Major
                  Found in src/TranslatorInterface/TranslationsSpecialPage.php - About 3 hrs to fix

                    Function import has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function import( array $changeData, string $name, int $importStrategy ): array {
                            $processed = [];
                            $skipped = [];
                            $jobs = [];
                    
                    
                    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

                    Method processSubmit has 89 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function processSubmit(): void {
                            $req = $this->getRequest();
                            $out = $this->getOutput();
                            $errorGroups = [];
                    
                    
                    Severity: Major
                    Found in src/Synchronization/ManageGroupsSpecialPage.php - About 3 hrs to fix

                      Function _computeGridLineItems has 88 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

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

                        File ext.translate.special.managegroups.js has 313 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        ( function () {
                            var RenameDropdown,
                                GroupSynchronization;
                        
                            $( function () {
                        Severity: Minor
                        Found in resources/js/ext.translate.special.managegroups.js - About 3 hrs to fix

                          File ttmserver-export.php has 313 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          <?php
                          /**
                           * Script to bootstrap TtmServer translation memory
                           *
                           * @author Niklas Laxström
                          Severity: Minor
                          Found in scripts/ttmserver-export.php - About 3 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language