wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

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

    public function execute() {
        $this->bundleMover = Services::getInstance()->getTranslatableBundleMover();

        $mwService = MediaWikiServices::getInstance();
        $this->titleParser = $mwService->getTitleParser();
Severity: Major
Found in src/PageTranslation/MoveTranslatableBundleMaintenanceScript.php - About 2 hrs to fix

    Method onSaveComplete has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function onSaveComplete(
            WikiPage $wikiPage,
            UserIdentity $userIdentity,
            string $summary,
            int $flags,
    Severity: Major
    Found in src/TranslatorInterface/TranslateEditAddons.php - About 2 hrs to fix

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

          public function execute() {
              $params = $this->extractRequestParams();
      
              $title = Title::newFromText( $params['title'] );
              if ( !$title ) {
      Severity: Major
      Found in src/TranslatorInterface/Aid/TranslationAidsActionApi.php - About 2 hrs to fix

        Function addMessage has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function addMessage( message ) {
            var $messageTable = $( '.tux-messagelist' ),
                sourceLanguage = $messageTable.data( 'sourcelangcode' ),
                sourceLanguageDir = $.uls.data.getDir( sourceLanguage ),
                targetLanguage = $messageTable.data( 'targetlangcode' ),
        Severity: Major
        Found in resources/src/ext.translate.specialTranslationStash/index.js - About 2 hrs to fix

          Function addExpanders has 71 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function addExpanders( $table ) {
                  var $metaRows = $( 'tr.AggregateMessageGroup', $table );
          
                  // Quick return
                  if ( !$metaRows.length ) {
          Severity: Major
          Found in resources/src/ext.translate.special.languagestats/index.js - About 2 hrs to fix

            Method actionLinks has 71 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function actionLinks( array $page, string $type ): string {
                    // Performance optimization to avoid calling $this->msg in a loop
                    static $messageCache = null;
                    if ( $messageCache === null ) {
                        $messageCache = [
            Severity: Major
            Found in src/PageTranslation/PageTranslationSpecialPage.php - About 2 hrs to fix

              Method getPageMoveCollection has 71 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getPageMoveCollection(
                      Title $source,
                      ?Title $target,
                      User $user,
                      string $reason,
              Severity: Major
              Found in src/PageTranslation/TranslatableBundleMover.php - About 2 hrs to fix

                Method parseFile has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function parseFile(): array {
                        $defines = file_get_contents( $this->definitionFile );
                        $linefeed = '(\r\n|\n)';
                        $sections = array_map(
                            'trim',
                Severity: Major
                Found in src/MessageGroupConfiguration/PremadeMediaWikiExtensionGroups.php - About 2 hrs to fix

                  Method sendNotifications has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function sendNotifications( array $changesToProcess ): void {
                          if ( !$this->isEnabled() || $changesToProcess === [] ) {
                              return;
                          }
                  
                  
                  Severity: Major
                  Found in src/MessageGroupProcessing/MessageGroupSubscription.php - About 2 hrs to fix

                    MessageBundleMessageGroup has 25 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class MessageBundleMessageGroup implements MessageGroup {
                        /** Name of the bundle (prefixed text of the bundle page) */
                        private string $name;
                        private string $groupId;
                        private int $pageId;
                    Severity: Minor
                    Found in src/MessageBundleTranslation/MessageBundleMessageGroup.php - About 2 hrs to fix

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

                      $specialPageAliases['lb'] = [
                          'ImportTranslations' => [ 'Iwwersetzungen_importéieren' ],
                          'LanguageStats' => [ 'Sproochestatistiken' ],
                          'ManageMessageGroups' => [ 'Gruppe_vu_Message_geréieren' ],
                          'ManageTranslatorSandbox' => [ 'Iwwersetzungssandkëscht_geréieren' ],
                      Severity: Major
                      Found in Translate.alias.php and 1 other location - About 2 hrs to fix
                      Translate.alias.php on lines 152..167

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

                      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

                      $specialPageAliases['bgn'] = [
                          'AggregateGroups' => [ 'گروپ_ئآنی_جم' ],
                          'ImportTranslations' => [ 'ترجمه_ئانی_درون_بررّگ' ],
                          'LanguageStats' => [ 'زبان_ئانی_سرجم' ],
                          'ManageMessageGroups' => [ 'پیامی_گروپ_ئانی_مدیریت' ],
                      Severity: Major
                      Found in Translate.alias.php and 1 other location - About 2 hrs to fix
                      Translate.alias.php on lines 634..649

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

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

                          helpers$1.splineCurveMonotone = function(points) {
                              // This function calculates Bézier control points in a similar way than |splineCurve|,
                              // but preserves monotonicity of the provided data and ensures no local extremums are added
                              // between the dataset discrete points due to the interpolation.
                              // See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation
                      Severity: Major
                      Found in resources/lib/Chart.js/Chart.js - About 2 hrs to fix

                        Method formatGroup has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function formatGroup( $mixed, array $props, int $depth = 0 ): array {
                                $params = $this->extractRequestParams();
                                $context = $this->getContext();
                        
                                // Default
                        Severity: Major
                        Found in src/MessageGroupProcessing/QueryMessageGroupsActionApi.php - About 2 hrs to fix

                          File MessageSourceChange.php has 282 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          <?php
                          /**
                           * Contains a class to track changes to the messages when importing messages from remote source.
                           * @author Abijeet Patro
                           * @license GPL-2.0-or-later
                          Severity: Minor
                          Found in src/MessageSync/MessageSourceChange.php - About 2 hrs to fix

                            Function save has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    save: function () {
                                        var translateEditor = this;
                            
                                        mw.hook( 'mw.translate.editor.beforeSubmit' ).fire( translateEditor.$editor );
                                        var translation = translateEditor.$editor.find( '.tux-textarea-translation' ).val();
                            Severity: Major
                            Found in resources/js/ext.translate.editor.js - About 2 hrs to fix

                              Function showData has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      function showData( apiResponse, options ) {
                                          var graphData = getAxesLabelsAndData( apiResponse.data ),
                                              graphDatasets = [],
                                              datasetLabels = apiResponse.labels;
                              
                              
                              Severity: Major
                              Found in resources/js/ext.translate.translationstats.graphbuilder.js - About 2 hrs to fix

                                Method createMessageGroup has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    protected function createMessageGroup( string $id, array $info ): MessageGroup {
                                        $conf = [];
                                        $conf['BASIC']['class'] = MediaWikiExtensionMessageGroup::class;
                                        $conf['BASIC']['id'] = $id;
                                        $conf['BASIC']['namespace'] = $this->getNamespace();
                                Severity: Major
                                Found in src/MessageGroupConfiguration/PremadeMediaWikiExtensionGroups.php - About 2 hrs to fix

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

                                      public function execute() {
                                          global $wgSitename, $wgTranslateMessageNamespaces;
                                  
                                          $days = (int)$this->getOption( 'days', 30 );
                                          $top = (int)$this->getOption( 'top', -1 );
                                  Severity: Minor
                                  Found in scripts/characterEditStats.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() {
                                          global $wgTranslateMessageNamespaces;
                                  
                                          $namespace = $this->getOption( 'namespace', $wgTranslateMessageNamespaces );
                                          $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
                                  Severity: Minor
                                  Found in scripts/populateFuzzy.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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language