wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

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

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

            class ManageGroupsSpecialPage extends SpecialPage {
                private const GROUP_SYNC_INFO_WRAPPER_CLASS = 'smg-group-sync-cache-info';
                private const RIGHT = 'translate-manage';
                protected DifferenceEngine $diff;
                /** Name of the import. */
            Severity: Minor
            Found in src/Synchronization/ManageGroupsSpecialPage.php - About 3 hrs to fix

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

              abstract class MessageGroupBase implements MessageGroup {
                  /** @var array */
                  protected $conf;
                  /** @var int|false */
                  protected $namespace;
              Severity: Minor
              Found in messagegroups/MessageGroupBase.php - About 3 hrs to fix

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

                class GettextFormat extends SimpleFormat implements MetaYamlSchemaExtender {
                    private bool $allowPotMode = false;
                    private bool $offlineMode = false;
                
                    public function supportsFuzzy(): string {
                Severity: Minor
                Found in src/FileFormatSupport/GettextFormat.php - About 3 hrs to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                                  } else {
                                      $allChildRows.addClass( 'statstable-hide' );
                                      $el.add( $allToggles ).addClass( 'collapsed' ).removeClass( 'expanded' );
                                      $el.find( '> a' ).text( mw.msg( 'translate-langstats-expandall' ) );
                                      $allToggles.find( '> a' ).text( mw.msg( 'translate-langstats-expand' ) );
                  Severity: Major
                  Found in resources/src/ext.translate.special.languagestats/index.js and 1 other location - About 3 hrs to fix
                  resources/src/ext.translate.special.languagestats/index.js on lines 99..104

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 95.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                                  if ( $el.hasClass( 'collapsed' ) ) {
                                      $allChildRows.removeClass( 'statstable-hide' );
                                      $el.add( $allToggles ).removeClass( 'collapsed' ).addClass( 'expanded' );
                                      $el.find( '> a' ).text( mw.msg( 'translate-langstats-collapseall' ) );
                                      $allToggles.find( '> a' ).text( mw.msg( 'translate-langstats-collapse' ) );
                  Severity: Major
                  Found in resources/src/ext.translate.special.languagestats/index.js and 1 other location - About 3 hrs to fix
                  resources/src/ext.translate.special.languagestats/index.js on lines 104..109

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 95.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  $specialPageAliases['diq'] = [
                      'AggregateGroups' => [ 'GrubéAggregate' ],
                      'ImportTranslations' => [ 'AçarnayışaZerrefi' ],
                      'LanguageStats' => [ 'İstatistikêZıwani' ],
                      'ManageMessageGroups' => [ 'GrubanéMesacanİdareke' ],
                  Severity: Major
                  Found in Translate.alias.php and 1 other location - About 2 hrs to fix
                  Translate.alias.php on lines 362..377

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 141.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  $specialPageAliases['fa'] = [
                      'AggregateGroups' => [ 'جمع_گروه‌ها' ],
                      'ImportTranslations' => [ 'درون‌بری_ترجمه‌ها' ],
                      'LanguageStats' => [ 'آمار_زبان‌ها' ],
                      'ManageMessageGroups' => [ 'مدیریت_گروه‌های_پیغام' ],
                  Severity: Major
                  Found in Translate.alias.php and 1 other location - About 2 hrs to fix
                  Translate.alias.php on lines 295..310

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 141.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  File DeleteTranslatableBundleSpecialPage.php has 290 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/DeleteTranslatableBundleSpecialPage.php - About 2 hrs to fix

                    Method parseFile has 74 lines of code (exceeds 25 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: Major
                    Found in src/MessageGroupProcessing/CsvTranslationImporter.php - About 2 hrs to fix

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

                          fit: function() {
                              var me = this;
                              // Reset
                              var minSize = me.minSize = {
                                  width: 0,
                      Severity: Major
                      Found in resources/lib/Chart.js/Chart.js - About 2 hrs to fix

                        Method onActionMark has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function onActionMark( Title $title, ?int $revision ): void {
                                $request = $this->getRequest();
                                $out = $this->getOutput();
                                $translateTitle = $request->getCheck( 'translatetitle' );
                        
                        
                        Severity: Major
                        Found in src/PageTranslation/PageTranslationSpecialPage.php - About 2 hrs to fix

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

                              public function __construct() {
                                  parent::__construct();
                                  $this->addArg(
                                      'xml-path',
                                      'Path to the XML file to be imported',

                            Function handleRenameSubmit has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function handleRenameSubmit(
                                    MessageGroup $group,
                                    MessageSourceChange $sourceChanges,
                                    WebRequest $req,
                                    string $language,
                            Severity: Minor
                            Found in src/Synchronization/ManageGroupsSpecialPage.php - About 2 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 backport has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function backport(
                                    FileBasedMessageGroup $group,
                                    string $source,
                                    string $targetPath,
                                    array $keyCompatibilityMap,
                            Severity: Minor
                            Found in src/Synchronization/BackportTranslationsMaintenanceScript.php - About 2 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 formatGroup has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                            Open

                                protected function formatGroup( $mixed, array $props, int $depth = 0 ): array {
                                    $params = $this->extractRequestParams();
                                    $context = $this->getContext();
                            
                                    // Default
                            Severity: Minor
                            Found in src/MessageGroupProcessing/QueryMessageGroupsActionApi.php - About 2 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

                            Severity
                            Category
                            Status
                            Source
                            Language