wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

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

$specialPageAliases['ml'] = [
    'ImportTranslations' => [ 'പരിഭാഷാ_ഇറക്കുമതി' ],
    'LanguageStats' => [ 'ഭാഷാസ്ഥിതിവിവരം' ],
    'ManageMessageGroups' => [ 'സന്ദേശസംഘങ്ങളുടെകൈകാര്യം' ],
    'MessageGroupStats' => [ 'സന്ദേശഗണസ്ഥിതിവിവരം' ],
Severity: Major
Found in Translate.alias.php and 3 other locations - About 1 hr to fix
Translate.alias.php on lines 428..439
Translate.alias.php on lines 504..515
Translate.alias.php on lines 902..913

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 102.

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 4 locations. Consider refactoring.
Open

$specialPageAliases['ia'] = [
    'ImportTranslations' => [ 'Importar_traductiones' ],
    'LanguageStats' => [ 'Statisticas_de_linguas' ],
    'ManageMessageGroups' => [ 'Gerer_gruppos_de_messages' ],
    'MessageGroupStats' => [ 'Statisticas_de_gruppos_de_messages' ],
Severity: Major
Found in Translate.alias.php and 3 other locations - About 1 hr to fix
Translate.alias.php on lines 428..439
Translate.alias.php on lines 689..700
Translate.alias.php on lines 902..913

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 102.

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

Function updateElement has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    updateElement: function(point, index, reset) {
        var me = this;
        var custom = point.custom || {};
        var dataset = me.getDataset();
        var scale = me.chart.scale;
Severity: Minor
Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

    Function updateBezierControlPoints has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        updateBezierControlPoints: function() {
            var me = this;
            var meta = me.getMeta();
            var area = me.chart.chartArea;
            var points = meta.data || [];
    Severity: Minor
    Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

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

          public function execute() {
              global $wgTranslateGroupFiles, $wgTranslateYamlLibrary;
              $documents = [];
              $times = [];
              $mems = [];
      Severity: Minor
      Found in scripts/yaml-tests.php - About 1 hr to fix

        Function drawLegendBox has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                var drawLegendBox = function(x, y, legendItem) {
                    if (isNaN(boxWidth) || boxWidth <= 0) {
                        return;
                    }
        
        
        Severity: Minor
        Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

          Method isSourcePage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function isSourcePage( PageIdentity $page ): bool {
                  if ( !$page->exists() ) {
                      // No point in loading all translatable pages if the page
                      // doesn’t exist. This also avoids PreconditionExceptions
                      // if $page is a Title pointing to a non-proper page like
          Severity: Minor
          Found in src/PageTranslation/TranslatablePage.php - About 1 hr to fix

            Method getDocumentationBox has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getDocumentationBox(): string {
                    global $wgTranslateDocumentationLanguageCode;
            
                    if ( !$wgTranslateDocumentationLanguageCode ) {
                        throw new TranslationHelperException( 'Message documentation language code is not defined' );
            Severity: Minor
            Found in src/TranslatorInterface/LegacyTranslationAids.php - About 1 hr to fix

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

                  public function execute( $parameters ) {
                      $out = $this->getOutput();
                      $out->addModuleStyles( [
                          'ext.translate.special.translate.styles',
                          'jquery.uls.grid',
              Severity: Minor
              Found in src/TranslatorInterface/TranslateSpecialPage.php - About 1 hr to fix

                Method onMovePageTranslationUnits has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function onMovePageTranslationUnits(
                        LinkTarget $oldLinkTarget,
                        LinkTarget $newLinkTarget,
                        UserIdentity $userIdentity,
                        int $oldid,
                Severity: Minor
                Found in src/PageTranslation/Hooks.php - About 1 hr to fix

                  Method doReview has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function doReview( User $user, RevisionRecord $revRecord ): bool {
                          $dbw = $this->loadBalancer->getConnection( DB_PRIMARY );
                          $dbw->newInsertQueryBuilder()
                              ->insertInto( 'translate_reviews' )
                              ->ignore()
                  Severity: Minor
                  Found in src/TranslatorInterface/ReviewTranslationActionApi.php - About 1 hr to fix

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

                        public function __construct() {
                            parent::__construct();
                            $this->addDescription( 'Creates a dump file that can be imported to a TtmServer' );
                    
                            $this->addOption(
                    Severity: Minor
                    Found in src/TtmServer/ExportTtmServerDumpMaintenanceScript.php - About 1 hr to fix

                      Method formatWebSuggestions has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function formatWebSuggestions( array $queryData ): array {
                              $service = $queryData['service'];
                              $response = $queryData['response'];
                              $sourceLanguage = $queryData['language'];
                              $sourceText = $queryData['text'];
                      Severity: Minor
                      Found in src/TranslatorInterface/Aid/TTMServerAid.php - About 1 hr to fix

                        Method query has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function query( string $sourceLanguage, string $targetLanguage, string $text ): array {
                                // Calculate the bounds of the string length which are able
                                // to satisfy the cutoff percentage in edit distance.
                                $len = mb_strlen( $text );
                                $min = ceil( max( $len * $this->config['cutoff'], 2 ) );
                        Severity: Minor
                        Found in src/TtmServer/DatabaseTtmServer.php - About 1 hr to fix

                          Method getHopefullyValidConfigurations has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function getHopefullyValidConfigurations( string $data, ?callable $callback = null ): array {
                                  if ( !is_callable( $callback ) ) {
                                      $callback = static function ( $unused1, $unused2, $unused3 ) {
                                          /*noop*/
                                      };
                          Severity: Minor
                          Found in src/MessageGroupConfiguration/MessageGroupConfigurationParser.php - About 1 hr to fix

                            Method getGroupErrorInfo has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function getGroupErrorInfo( string $groupId ): GroupSynchronizationResponse {
                                    $groupMessageErrorTag = $this->getGroupMessageErrorTag( $groupId );
                                    $groupMessageEntries = $this->cache->getByTag( $groupMessageErrorTag );
                            
                                    $groupErrorKey = $this->getGroupErrorKey( $groupId );
                            Severity: Minor
                            Found in src/Synchronization/GroupSynchronizationCache.php - About 1 hr to fix

                              Method languageCloud has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private function languageCloud(): array {
                                      $cacheKey = $this->cache->makeKey( 'translate-supportedlanguages-language-cloud', 'v2' );
                              
                                      $data = $this->cache->get( $cacheKey );
                                      if ( is_array( $data ) ) {
                              Severity: Minor
                              Found in src/Statistics/ActiveLanguagesSpecialPage.php - About 1 hr to fix

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

                                    public function execute() {
                                        $params = $this->extractRequestParams();
                                
                                        $target = $this->validateTargetParamater( $params );
                                        $cache = $this->loadStatistics( $target, MessageGroupStats::FLAG_CACHE_ONLY );
                                Severity: Minor
                                Found in src/Statistics/QueryStatsActionApi.php - About 1 hr to fix

                                  Method getLanguagesFromHeader has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      private function getLanguagesFromHeader( array $csvHeader ): Status {
                                          if ( count( $csvHeader ) < 2 ) {
                                              return Status::newFatal(
                                                  'CSV has < 2 columns. Assuming that there are no languages to import'
                                              );
                                  Severity: Minor
                                  Found in src/MessageGroupProcessing/CsvTranslationImporter.php - About 1 hr to fix

                                    Method getAllowedParams has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        protected function getAllowedParams(): array {
                                            return [
                                                'do' => [
                                                    ParamValidator::PARAM_TYPE => [ 'associate', 'dissociate', 'remove', 'add', 'update' ],
                                                    ParamValidator::PARAM_REQUIRED => true,
                                    Severity: Minor
                                    Found in src/MessageGroupProcessing/AggregateGroupsActionApi.php - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language