wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

Function parseQueryString has a Cognitive Complexity of 20 (exceeds 5 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 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 execute has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $params = $this->extractRequestParams();

        $title = Title::newFromText( $params['title'] );
        if ( !$title ) {
Severity: Minor
Found in src/TranslatorInterface/Aid/TranslationAidsActionApi.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 execute has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute( $par ) {
        $this->target = $this->getLanguage()->getCode();
        $request = $this->getRequest();

        $this->purge = $request->getVal( 'action' ) === 'purge';
Severity: Minor
Found in src/Statistics/LanguageStatsSpecialPage.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 parseGettext has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private function parseGettext( string $data ): array {
        $mangler = $this->group->getMangler();
        $useCtxtAsKey = $this->extra['CtxtAsKey'] ?? false;
        $keyAlgorithm = 'simple';
        if ( isset( $this->extra['keyAlgorithm'] ) ) {
Severity: Minor
Found in src/FileFormatSupport/GettextFormat.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

File AggregateGroupsActionApi.php has 280 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare( strict_types = 1 );

namespace MediaWiki\Extension\Translate\MessageGroupProcessing;

Severity: Minor
Found in src/MessageGroupProcessing/AggregateGroupsActionApi.php - About 2 hrs to fix

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

        $.fn.pagemode = function ( options ) {
            return this.each( function () {
                var $this = $( this ),
                    data = $this.data( 'pagemode' );
    
    
    Severity: Major
    Found in resources/js/ext.translate.pagemode.js and 2 other locations - About 2 hrs to fix
    resources/js/ext.translate.proofread.js on lines 293..303
    resources/js/ext.translate.statsbar.js on lines 172..181

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

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

        $.fn.languagestatsbar = function ( options ) {
            return this.each( function () {
                var $this = $( this ),
                    data = $this.data( 'languagestatsbar' );
    
    
    Severity: Major
    Found in resources/js/ext.translate.statsbar.js and 2 other locations - About 2 hrs to fix
    resources/js/ext.translate.pagemode.js on lines 140..149
    resources/js/ext.translate.proofread.js on lines 293..303

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

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

        $.fn.proofread = function ( options ) {
            return this.each( function () {
                var $this = $( this ),
                    data = $this.data( 'proofread' );
    
    
    Severity: Major
    Found in resources/js/ext.translate.proofread.js and 2 other locations - About 2 hrs to fix
    resources/js/ext.translate.pagemode.js on lines 140..149
    resources/js/ext.translate.statsbar.js on lines 172..181

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

    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

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

        public function execute( $par ) {
            $request = $this->getRequest();
            $user = $this->getUser();
            $this->addHelpLink( 'Help:Extension:Translate/Move_translatable_page' );
            $out = $this->getOutput();
    Severity: Major
    Found in src/PageTranslation/MoveTranslatableBundleSpecialPage.php - About 2 hrs to fix

      Method markForTranslation has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function markForTranslation(
              TranslatablePageMarkOperation $operation,
              TranslatablePageSettings $pageSettings,
              User $user
          ): int {
      Severity: Major
      Found in src/PageTranslation/TranslatablePageMarker.php - About 2 hrs to fix

        Method showConfirmation has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function showConfirmation(): void {
                $out = $this->getOutput();
                $count = 0;
                $subpageCount = 0;
        
        
        Severity: Major
        Found in src/PageTranslation/DeleteTranslatableBundleSpecialPage.php - About 2 hrs to fix

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

            Utilities has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Utilities {
                /**
                 * Does quick normalisation of message name so that in can be looked from the
                 * database.
                 * @param string $message Name of the message
            Severity: Minor
            Found in src/Utilities/Utilities.php - About 2 hrs to fix

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

              function hslString(hsla, alpha) {
                 if (alpha < 1 || (hsla[3] && hsla[3] < 1)) {
                    return hslaString(hsla, alpha);
                 }
                 return "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)";
              Severity: Major
              Found in resources/lib/Chart.js/Chart.js and 1 other location - About 2 hrs to fix
              resources/lib/Chart.js/Chart.js on lines 1541..1546

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

              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

              function rgbString(rgba, alpha) {
                 if (alpha < 1 || (rgba[3] && rgba[3] < 1)) {
                    return rgbaString(rgba, alpha);
                 }
                 return "rgb(" + rgba[0] + ", " + rgba[1] + ", " + rgba[2] + ")";
              Severity: Major
              Found in resources/lib/Chart.js/Chart.js and 1 other location - About 2 hrs to fix
              resources/lib/Chart.js/Chart.js on lines 1574..1579

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

              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

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

                  public function __construct() {
                      parent::__construct();
                      $this->addDescription( 'Script to generate statistics about the localisation ' .
                          'level of one or more message groups.' );
                      $this->addOption(
              Severity: Major
              Found in scripts/groupStatistics.php - About 2 hrs to fix

                Function buildOrUpdateScales has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    buildOrUpdateScales: function() {
                        var me = this;
                        var options = me.options;
                        var scales = me.scales || {};
                        var items = [];
                Severity: Major
                Found in resources/lib/Chart.js/Chart.js - About 2 hrs to fix

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

                      public function execute(): void {
                          $this->checkUserRightsAny( self::RIGHT );
                          $params = $this->extractRequestParams();
                  
                          $groupId = $params['groupId'];
                  Severity: Major
                  Found in src/MessageGroupProcessing/ManageMessageGroupsActionApi.php - About 2 hrs to fix

                    File ext.translate.translationstats.graphbuilder.js has 276 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    /*!
                     * Graph component to display translation stats using ChartJS
                     * @license GPL-2.0-or-later
                     */
                    
                    
                    Severity: Minor
                    Found in resources/js/ext.translate.translationstats.graphbuilder.js - About 2 hrs to fix

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

                          public function execute() {
                              $dryRun = $this->hasOption( 'dry-run' );
                              $ttmServerId = $this->getOption( 'ttmserver' );
                              $shouldReindex = $this->getOption( 'reindex', false );
                      
                      
                      Severity: Major
                      Found in scripts/ttmserver-export.php - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language