wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

File MessageWebImporter.php has 402 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/MessageWebImporter.php - About 5 hrs to fix

    File TranslatablePage.php has 396 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/TranslatablePage.php - About 5 hrs to fix

      File MoveTranslatableBundleSpecialPage.php has 396 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/MoveTranslatableBundleSpecialPage.php - About 5 hrs to fix

        Hooks has 41 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Hooks {
            private const PAGEPROP_HAS_LANGUAGES_TAG = 'translate-has-languages-tag';
            /** @var bool Uuugly hacks */
            public static $allowTargetEdit = false;
            /** State flag used by DeleteTranslatableBundleJob for performance optimizations. */
        Severity: Minor
        Found in src/PageTranslation/Hooks.php - About 5 hrs to fix

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

              helpers$1.getMaximumWidth = function(domNode) {
                  var container = helpers$1._getParentNode(domNode);
                  if (!container) {
                      return domNode.clientWidth;
                  }
          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 10759..10772

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

          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

              helpers$1.getMaximumHeight = function(domNode) {
                  var container = helpers$1._getParentNode(domNode);
                  if (!container) {
                      return domNode.clientHeight;
                  }
          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 10745..10758

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

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

              public function onChangesListSpecialPageStructuredFilters( $special ): void {
                  $translateRcFilterDefault = $this->config->get( 'TranslateRcFilterDefault' );
                  $defaultFilter = $translateRcFilterDefault !== 'noaction' ?
                      $translateRcFilterDefault :
                      ChangesListStringOptionsFilterGroup::NONE;
          Severity: Major
          Found in src/RecentChangesTranslationFilterHookHandler.php - About 5 hrs to fix

            Function execute has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
            Open

                public function execute( $subPage ) {
                    $this->setHeaders();
                    $this->checkPermissions();
            
                    $server = $this->ttmServerFactory->getDefaultForQuerying();
            Severity: Minor
            Found in src/TtmServer/SearchTranslationsSpecialPage.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

            Function initMessages has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                public function initMessages(): void {
                    if ( $this->messages !== null ) {
                        return;
                    }
            
            
            Severity: Minor
            Found in src/MessageLoading/MessageCollection.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

            Function showChanges has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function showChanges( int $limit ): void {
                    $diff = new DifferenceEngine( $this->getContext() );
                    $diff->showDiffStyle();
                    $diff->setReducedLineNumbers();
                    $this->diff = $diff;
            Severity: Minor
            Found in src/Synchronization/ManageGroupsSpecialPage.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 ext.translate.special.pagemigration.js has 378 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            ( function () {
                'use strict';
                var noOfSourceUnits, noOfTranslationUnits,
                    pageName = '',
                    langCode = '',
            Severity: Minor
            Found in resources/js/ext.translate.special.pagemigration.js - About 5 hrs to fix

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

                  beforeUpdate: function(chart) {
                      var legendOpts = chart.options.legend;
                      var legend = chart.legend;
              
                      if (legendOpts) {
              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 15970..15987

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

              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

                  beforeUpdate: function(chart) {
                      var titleOpts = chart.options.title;
                      var titleBlock = chart.titleBlock;
              
                      if (titleOpts) {
              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 15726..15743

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

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

                  draw: function() {
                      var me = this;
                      var opts = me.options;
                      var labelOpts = opts.labels;
                      var globalDefaults = core_defaults.global;
              Severity: Major
              Found in resources/lib/Chart.js/Chart.js - About 4 hrs to fix

                Function addMessageUpdateChanges has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function addMessageUpdateChanges(
                        FileBasedMessageGroup $group,
                        string $language,
                        MessageSourceChange $changes,
                        int $reason,
                Severity: Minor
                Found in src/Synchronization/ExternalMessageSourceStateComparator.php - About 4 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 ext.translate.special.aggregategroups.js has 370 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                ( function () {
                    'use strict';
                
                    function getApiParams( $target ) {
                        return {
                Severity: Minor
                Found in resources/js/ext.translate.special.aggregategroups.js - About 4 hrs to fix

                  Function assign has 122 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function assign( ta ) {
                          if ( !ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has( ta ) ) { return; }
                  
                          var heightOffset = null,
                           clientWidth = null,
                  Severity: Major
                  Found in resources/lib/jquery.autosize.js - About 4 hrs to fix

                    TranslatablePage has 37 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class TranslatablePage extends TranslatableBundle {
                        /**
                         * List of keys in the metadata table that need to be handled for moves and deletions
                         * @phpcs-require-sorted-array
                         */
                    Severity: Minor
                    Found in src/PageTranslation/TranslatablePage.php - About 4 hrs to fix

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

                          protected function showConfirmation( PageMoveCollection $pageCollection, TranslatableBundle $bundle ): void {
                              $out = $this->getOutput();
                              $out->addBacklinkSubtitle( $this->oldTitle );
                              $out->addWikiMsg(
                                  'pt-movepage-intro',
                      Severity: Major
                      Found in src/PageTranslation/MoveTranslatableBundleSpecialPage.php - About 4 hrs to fix

                        Function parseFile has a Cognitive Complexity of 31 (exceeds 5 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: Minor
                        Found in src/MessageGroupProcessing/CsvTranslationImporter.php - About 4 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