wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 994 of 1,238 total issues

Method getPagesToMove has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function getPagesToMove(
        Title $source,
        Title $target,
        bool $moveSubPages,
        bool $fetchTranslatableSubpages,
Severity: Minor
Found in src/PageTranslation/TranslatableBundleMover.php - About 1 hr to fix

    Method sendEmail has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function sendEmail( User $sender, User $target, string $type ): void {
            $emergencyContact = $this->options->get( 'EmergencyContact' );
    
            $targetLang = $this->userOptionsManager->getOption( $target, 'language' );
    
    
    Severity: Minor
    Found in src/TranslatorSandbox/TranslateSandbox.php - About 1 hr to fix

      Method addForm has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function addForm(): void {
              $formDescriptor = [
                  'select' => [
                      'type' => 'select',
                      'name' => self::GROUPS,
      Severity: Minor
      Found in src/Statistics/MessageGroupStatsSpecialPage.php - About 1 hr to fix

        Method getSubpagesPerType has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getSubpagesPerType( TranslatableBundle $bundle, bool $fetchTalkPages ): array {
                $classifiedSubPages = $this->getEmptyResultSet();
        
                $classifiedSubPages['translationPages'] = $bundle->getTranslationPages();
                $classifiedSubPages['translationUnitPages'] = $bundle->getTranslationUnitPages();
        Severity: Minor
        Found in src/MessageGroupProcessing/SubpageListBuilder.php - About 1 hr to fix

          Method getDefinitions has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getDefinitions() {
                  global $wgTranslateSandboxLimit;
          
                  // This will contain the list of messages shown to the user
                  $list = [];
          Severity: Minor
          Found in messagegroups/SandboxMessageGroup.php - About 1 hr to fix

            Function _resolveDataElementOptions has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _resolveDataElementOptions: function(element, index) {
                    var me = this;
                    var custom = element && element.custom;
                    var cached = me._cachedDataOpts;
                    if (cached && !custom) {
            Severity: Minor
            Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

              Method handleRename has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function handleRename( string $target, string $replacement ): ?Title {
                      $newSourceTitle = null;
              
                      $sourceMessageHandle = new MessageHandle( $this->title );
                      $movableTitles = TranslateReplaceTitle::getTitlesForMove( $sourceMessageHandle, $replacement );
              Severity: Minor
              Found in src/Synchronization/UpdateMessageJob.php - About 1 hr to fix

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

                    public function execute( $par ): void {
                        $out = $this->getOutput();
                        $lang = $this->getLanguage();
                        $this->progressStatsTable = $this->progressStatsTableFactory->newFromContext( $this->getContext() );
                
                
                Severity: Minor
                Found in src/Statistics/ActiveLanguagesSpecialPage.php - About 1 hr to fix

                  Method isValid has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function isValid( &$reason ): bool {
                          $group = $this->group;
                          $pattern = $group->getSourceFilePath( '*' );
                          $filename = $group->getSourceFilePath( $this->languageCode );
                  
                  
                  Severity: Minor
                  Found in src/MessageGroupProcessing/MessageGroupCache.php - About 1 hr to fix

                    Method importData has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function importData(
                            array $messagesWithTranslations,
                            Authority $authority,
                            string $comment,
                            ?callable $progressReporter = null
                    Severity: Minor
                    Found in src/MessageGroupProcessing/CsvTranslationImporter.php - About 1 hr to fix

                      Method getIssues has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getIssues( Message $message, string $targetLanguage ): ValidationIssues {
                              $issues = new ValidationIssues();
                      
                              $pluralRule = GettextPlural::getPluralRule( $targetLanguage );
                              // Skip validation for languages for which we do not know the plural rule
                      Severity: Minor
                      Found in src/Validation/Validators/GettextPluralValidator.php - About 1 hr to fix

                        Function computeLabelSizes has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function computeLabelSizes(ctx, tickFonts, ticks, caches) {
                            var length = ticks.length;
                            var widths = [];
                            var heights = [];
                            var offsets = [];
                        Severity: Minor
                        Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

                          Method getAllowedParams has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function getAllowedParams() {
                                  return [
                                      'title' => [
                                          ParamValidator::PARAM_TYPE => 'string',
                                      ],
                          Severity: Minor
                          Found in src/PageTranslation/MarkForTranslationActionApi.php - About 1 hr to fix

                            Function buildTicks has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                buildTicks: function() {
                                    var me = this;
                                    var min = me.min;
                                    var max = me.max;
                                    var options = me.options;
                            Severity: Minor
                            Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

                              Method onDeleteTranslationUnit has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public static function onDeleteTranslationUnit(
                                      WikiPage $unit,
                                      User $user,
                                      $reason,
                                      $id,
                              Severity: Minor
                              Found in src/PageTranslation/Hooks.php - About 1 hr to fix

                                Method getAllowedParams has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    protected function getAllowedParams(): array {
                                        return [
                                            'group' => [
                                                ParamValidator::PARAM_TYPE => 'string',
                                                ParamValidator::PARAM_REQUIRED => true,
                                Severity: Minor
                                Found in src/MessageLoading/QueryMessageCollectionActionApi.php - About 1 hr to fix

                                  Method readFromVariable has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function readFromVariable( string $data ): array {
                                          $data = TextContent::normalizeLineEndings( $data );
                                          $lines = array_map( 'ltrim', explode( "\n", $data ) );
                                          $authors = $messages = [];
                                          $lineContinuation = false;
                                  Severity: Minor
                                  Found in src/FileFormatSupport/JavaFormat.php - About 1 hr to fix

                                    Function left has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        left: function ( position, data ) {
                                            var within = data.within,
                                                withinOffset = within.offset.left + within.scrollLeft,
                                                outerWidth = within.width,
                                                offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
                                    Severity: Minor
                                    Found in resources/src/ext.translate.groupselector/ui.position.js - 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 14 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function execute() {
                                            $groups = MessageGroups::singleton()->getGroups();
                                            $mwInstance = MediaWikiServices::getInstance();
                                            $jobQueueGroup = $mwInstance->getJobQueueGroup();
                                    
                                    
                                    Severity: Minor
                                    Found in scripts/refresh-translatable-pages.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 listPages has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function listPages(): void {
                                            $out = $this->getOutput();
                                    
                                            $res = self::loadPagesFromDB();
                                            $allPages = self::buildPageArray( $res );
                                    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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language