wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

Method showPage has 186 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function showPage( TranslatablePageMarkOperation $operation ): void {
        $page = $operation->getPage();
        $out = $this->getOutput();
        $out->addWikiMsg( 'tpt-showpage-intro' );

Severity: Major
Found in src/PageTranslation/PageTranslationSpecialPage.php - About 7 hrs to fix

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

        public function execute(): void {
            $this->checkUserRightsAny( self::$right );
            $block = $this->getUser()->getBlock();
            if ( $block && $block->isSitewide() ) {
                $this->dieBlocked( $block );
    Severity: Major
    Found in src/MessageGroupProcessing/AggregateGroupsActionApi.php - About 6 hrs to fix

      File ServiceWiring.php has 456 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * List of services in this extension with construction instructions.
       *
       * @file
      Severity: Minor
      Found in src/ServiceWiring.php - About 6 hrs to fix

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

            public function execute() {
                $logger = LoggerFactory::getInstance( 'Translate.GroupSynchronization' );
                $groupPattern = $this->getOption( 'group' ) ?? '';
                $groupSkipPattern = $this->getOption( 'skipgroup' ) ?? '';
                $skipGroupSyncCheck = $this->hasOption( 'skip-group-sync-check' );
        Severity: Major
        Found in src/Synchronization/ExportTranslationsMaintenanceScript.php - About 6 hrs to fix

          Services has 46 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Services implements ContainerInterface {
              private ContainerInterface $container;
          
              private function __construct( ContainerInterface $container ) {
                  $this->container = $container;
          Severity: Minor
          Found in src/Services.php - About 6 hrs to fix

            File MessageGroupStats.php has 429 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            declare( strict_types = 1 );
            
            namespace MediaWiki\Extension\Translate\Statistics;
            
            
            Severity: Minor
            Found in src/Statistics/MessageGroupStats.php - About 6 hrs to fix

              Function handleFuzzy has a Cognitive Complexity of 41 (exceeds 5 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: Minor
              Found in src/Synchronization/UpdateMessageJob.php - About 6 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

              MessageCollection has 44 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class MessageCollection implements ArrayAccess, Iterator, Countable {
                  /**
                   * The queries can get very large because each message title is specified
                   * individually. Very large queries can confuse the database query planner.
                   * Queries are split into multiple separate queries having at most this many
              Severity: Minor
              Found in src/MessageLoading/MessageCollection.php - About 6 hrs to fix

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

                    public function execute( array $messages ): bool {
                        $context = RequestContext::getMain();
                        $output = $context->getOutput();
                
                        // Set up diff engine
                Severity: Major
                Found in src/Synchronization/MessageWebImporter.php - About 5 hrs to fix

                  File index.js has 414 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  ( function () {
                      'use strict';
                  
                      var groupsLoader, delay;
                  
                  
                  Severity: Minor
                  Found in resources/src/ext.translate.groupselector/index.js - About 5 hrs to fix

                    Function parseFile has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function parseFile(): array {
                            $defines = file_get_contents( $this->definitionFile );
                            $linefeed = '(\r\n|\n)';
                            $sections = array_map(
                                'trim',
                    Severity: Minor
                    Found in src/MessageGroupConfiguration/PremadeMediaWikiExtensionGroups.php - About 5 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 MessageGroups.php has 413 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/MessageGroups.php - About 5 hrs to fix

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

                                          $( '<div>' )
                                              .addClass( 'eight columns tux-list-message' )
                                              .append(
                                                  $( '<span>' )
                                                      .addClass( 'tux-list-source' )
                      Severity: Major
                      Found in resources/js/ext.translate.messagetable.js and 1 other location - About 5 hrs to fix
                      resources/src/ext.translate.specialTranslationStash/index.js on lines 54..77

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

                      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

                                  $( '<div>' )
                                      .addClass( 'eight columns tux-list-message' )
                                      .append(
                                          $( '<span>' )
                                              .addClass( 'tux-list-source' )
                      Severity: Major
                      Found in resources/src/ext.translate.specialTranslationStash/index.js and 1 other location - About 5 hrs to fix
                      resources/js/ext.translate.messagetable.js on lines 184..207

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

                      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

                              y: function(chart, e, options) {
                                  var position = getRelativePosition(e, chart);
                                  var items = [];
                                  var intersectsItem = false;
                      
                      
                      Severity: Major
                      Found in resources/lib/Chart.js/Chart.js and 1 other location - About 5 hrs to fix
                      resources/lib/Chart.js/Chart.js on lines 6933..6954

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

                      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 getHsla(string) {
                         if (!string) {
                            return;
                         }
                         var hsl = /^hsla?\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/;
                      Severity: Major
                      Found in resources/lib/Chart.js/Chart.js and 1 other location - About 5 hrs to fix
                      resources/lib/Chart.js/Chart.js on lines 1489..1503

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

                      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

                              x: function(chart, e, options) {
                                  var position = getRelativePosition(e, chart);
                                  var items = [];
                                  var intersectsItem = false;
                      
                      
                      Severity: Major
                      Found in resources/lib/Chart.js/Chart.js and 1 other location - About 5 hrs to fix
                      resources/lib/Chart.js/Chart.js on lines 6964..6985

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

                      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 getHwb(string) {
                         if (!string) {
                            return;
                         }
                         var hwb = /^hwb\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/;
                      Severity: Major
                      Found in resources/lib/Chart.js/Chart.js and 1 other location - About 5 hrs to fix
                      resources/lib/Chart.js/Chart.js on lines 1473..1487

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

                      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 TranslatablePageMarker.php has 408 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/TranslatablePageMarker.php - About 5 hrs to fix

                        Function run has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function run( ApiPageSet $resultPageSet = null ): void {
                                $params = $this->extractRequestParams();
                        
                                $group = MessageGroups::getGroup( $params['group'] );
                                if ( !$group ) {
                        Severity: Minor
                        Found in src/MessageLoading/QueryMessageCollectionActionApi.php - About 5 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