wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

Method replaceSubtitle has 49 lines of code (exceeds 25 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 1 hr to fix

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

            } else if (position === 'bottom') {
                borderValue = alignBorderValue(me.top);
                y1 = chartArea.top;
                y2 = alignBorderValue(chartArea.bottom) - axisHalfWidth;
                ty1 = borderValue + axisHalfWidth;
    Severity: Major
    Found in resources/lib/Chart.js/Chart.js and 1 other location - About 1 hr to fix
    resources/lib/Chart.js/Chart.js on lines 12161..12167

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

    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

            } else {
                borderValue = alignBorderValue(me.left);
                x1 = chartArea.left;
                x2 = alignBorderValue(chartArea.right) - axisHalfWidth;
                tx1 = borderValue + axisHalfWidth;
    Severity: Major
    Found in resources/lib/Chart.js/Chart.js and 1 other location - About 1 hr to fix
    resources/lib/Chart.js/Chart.js on lines 12149..12155

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

    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['ru'] = [
        'AggregateGroups' => [ 'Агрегированные_группы' ],
        'ImportTranslations' => [ 'Импорт_переводов' ],
        'LanguageStats' => [ 'Статистика_языка' ],
        'ManageMessageGroups' => [ 'Управление_группами_сообщений' ],
    Severity: Major
    Found in Translate.alias.php and 3 other locations - About 1 hr to fix
    Translate.alias.php on lines 107..120
    Translate.alias.php on lines 243..256
    Translate.alias.php on lines 767..780

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

    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['av'] = [
        'AggregateGroups' => [ 'Агрегированные_группы' ],
        'ImportTranslations' => [ 'Импорт_переводов' ],
        'LanguageStats' => [ 'Статистика_языка' ],
        'ManageMessageGroups' => [ 'Управление_группами_сообщений' ],
    Severity: Major
    Found in Translate.alias.php and 3 other locations - About 1 hr to fix
    Translate.alias.php on lines 243..256
    Translate.alias.php on lines 767..780
    Translate.alias.php on lines 878..891

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

    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['nds-nl'] = [
        'AggregateGroups' => [ 'Samen-evoegden_groepen' ],
        'ImportTranslations' => [ 'Vertalingen_invoeren' ],
        'LanguageStats' => [ 'Taalstaotistieken' ],
        'ManageMessageGroups' => [ 'Berichtengroepen_beheren' ],
    Severity: Major
    Found in Translate.alias.php and 3 other locations - About 1 hr to fix
    Translate.alias.php on lines 107..120
    Translate.alias.php on lines 243..256
    Translate.alias.php on lines 878..891

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

    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['ce'] = [
        'AggregateGroups' => [ 'Агрегированни_тобанаш' ],
        'ImportTranslations' => [ 'Гоч_йинарш_импорт_яр' ],
        'LanguageStats' => [ 'Меттан_статистика' ],
        'ManageMessageGroups' => [ 'Хаамийн_тобанийн_урхалла_дар' ],
    Severity: Major
    Found in Translate.alias.php and 3 other locations - About 1 hr to fix
    Translate.alias.php on lines 107..120
    Translate.alias.php on lines 767..780
    Translate.alias.php on lines 878..891

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

    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 importHandler has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function importHandler( e ) {
            var $errorBox = $( '.mw-tpm-sp-error__message' ),
                $messageBox = $( '.mw-tpm-sp-instructions' );
    
            e.preventDefault();
    Severity: Minor
    Found in resources/js/ext.translate.special.pagemigration.js - About 1 hr to fix

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

          public function execute( $par ) {
              $this->addHelpLink( 'Help:Deletion_and_undeletion' );
      
              $request = $this->getRequest();
      
      
      Severity: Minor
      Found in src/PageTranslation/DeleteTranslatableBundleSpecialPage.php - About 1 hr to fix

        Method parseQueryString has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function parseQueryString( string $queryString, array $opts ): array {
                $fields = $highlights = [];
                $terms = preg_split( '/\s+/', $queryString );
                $match = $opts['match'];
                $case = $opts['case'];
        Severity: Minor
        Found in src/TtmServer/ElasticSearchTtmServer.php - About 1 hr to fix

          Method getData has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getData(): array {
                  // We need to get the primary group to get the correct file
                  // So $group can be different from $this->group
                  $group = $this->handle->getGroup();
                  if ( !$group instanceof FileBasedMessageGroup ) {
          Severity: Minor
          Found in src/TranslatorInterface/Aid/GettextDocumentationAid.php - About 1 hr to fix

            Method update has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function update( MessageHandle $handle, ?string $targetText ): bool {
                    if ( !$handle->isValid() || $handle->getCode() === '' ) {
                        return false;
                    }
            
            
            Severity: Minor
            Found in src/TtmServer/DatabaseTtmServer.php - About 1 hr to fix

              Method showLanguage has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function showLanguage( string $code, array $users, int $cachedAt ): void {
                      $out = $this->getOutput();
                      $lang = $this->getLanguage();
              
                      // Information to be used inside the foreach loop.
              Severity: Minor
              Found in src/Statistics/ActiveLanguagesSpecialPage.php - About 1 hr to fix

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

                    public function execute() {
                        $csvFilePath = $this->getArg( 0 );
                
                        $username = $this->getOption( 'user' );
                        $summary = $this->getOption( 'summary' );
                Severity: Minor
                Found in src/MessageGroupProcessing/ImportTranslationsFromCsv.php - About 1 hr to fix

                  Function exportGroup has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function exportGroup( MessageGroup $group, array $servers ): void {
                          $times = [
                              'total' => -microtime( true ),
                              'stats' => 0,
                              'init' => 0,
                  Severity: Minor
                  Found in scripts/ttmserver-export.php - About 1 hr 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 execute has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function execute() {
                          $this->checkUserRightsAny( 'pagetranslation' );
                  
                          $params = $this->extractRequestParams();
                          $title = $this->getTitleFromTitleOrPageId( $params );
                  Severity: Minor
                  Found in src/PageTranslation/MarkForTranslationActionApi.php - About 1 hr 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 tryMatch has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function tryMatch( $code, $mws, $gtLanguages, $clLanguages ) {
                          if ( $mws !== '' ) {
                              $mwExp = true;
                              $lang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( $code );
                          } else {
                  Severity: Minor
                  Found in scripts/plural-comparison.php - About 1 hr 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 onActionMark has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function onActionMark( Title $title, ?int $revision ): void {
                          $request = $this->getRequest();
                          $out = $this->getOutput();
                          $translateTitle = $request->getCheck( 'translatetitle' );
                  
                  
                  Severity: Minor
                  Found in src/PageTranslation/PageTranslationSpecialPage.php - About 1 hr 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 onMovePageTranslationUnits has a Cognitive Complexity of 15 (exceeds 5 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

                  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 fetchTranslatableTemplateAndTitle has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function fetchTranslatableTemplateAndTitle(
                          ?LinkTarget $contextLink,
                          ?LinkTarget $templateLink,
                          bool &$skip,
                          ?RevisionRecord &$revRecord
                  Severity: Minor
                  Found in src/PageTranslation/Hooks.php - About 1 hr 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