wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 994 of 1,238 total issues

Method formatMessageBlock has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function formatMessageBlock(
        string $key,
        Message $message,
        array $trans,
        array $pot,
Severity: Minor
Found in src/FileFormatSupport/GettextFormat.php - About 2 hrs to fix

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

        public function getIssues( Message $message, string $targetLanguage ): ValidationIssues {
            $issues = new ValidationIssues();
    
            $definition = $message->definition();
            $translation = $message->translation();
    Severity: Minor
    Found in src/Validation/Validators/MediaWikiTimeListValidator.php - About 2 hrs to fix

      Function formatMessageGently has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              formatMessageGently: function ( text, key ) {
                  var protocols = mw.config.get( 'wgUrlProtocols' );
      
                  // Try to keep simple.
                  text = $( '<div>' ).text( text ).html();
      Severity: Minor
      Found in resources/js/ext.translate.parsers.js - About 1 hr to fix

        Function drawBody has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            drawBody: function(pt, vm, ctx) {
                var bodyFontSize = vm.bodyFontSize;
                var bodySpacing = vm.bodySpacing;
                var bodyAlign = vm._bodyAlign;
                var body = vm.body;
        Severity: Minor
        Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

          Function showMessageDocumentation has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  showMessageDocumentation: function ( documentation ) {
                      if ( !mw.config.get( 'wgTranslateDocumentationLanguageCode' ) ) {
                          return;
                      }
          
          
          Severity: Minor
          Found in resources/js/ext.translate.editor.helpers.js - About 1 hr to fix

            Method getTextForRendering has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getTextForRendering(
                    ?Message $msg,
                    Language $sourceLanguage,
                    Language $targetLanguage,
                    bool $wrapUntranslated,
            Severity: Minor
            Found in src/PageTranslation/TranslationUnit.php - About 1 hr to fix

              Function generateTicks has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function generateTicks(generationOptions, dataRange) {
                  var ticks = [];
                  // To get a "nice" value for the tick spacing, we will use the appropriately named
                  // "nice number" algorithm. See https://stackoverflow.com/questions/8506881/nice-label-algorithm-for-charts-with-minimum-ticks
                  // for details.
              Severity: Minor
              Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

                Method execute has 49 lines of code (exceeds 25 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 1 hr to fix

                  Method replaceSubtitle has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function replaceSubtitle( &$subpages, ?Skin $skin, OutputPage $out ) {
                          $linker = MediaWikiServices::getInstance()->getLinkRenderer();
                  
                          $isTranslationPage = TranslatablePage::isTranslationPage( $out->getTitle() );
                          if ( !$isTranslationPage
                  Severity: Minor
                  Found in src/PageTranslation/Hooks.php - About 1 hr to fix

                    Function importHandler has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function importHandler( e ) {
                            var $errorBox = $( '.mw-tpm-sp-error__message' ),
                                $messageBox = $( '.mw-tpm-sp-instructions' );
                    
                            e.preventDefault();
                    Severity: Minor
                    Found in resources/js/ext.translate.special.pagemigration.js - About 1 hr to fix

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

                          public function execute( $par ) {
                              $this->addHelpLink( 'Help:Deletion_and_undeletion' );
                      
                              $request = $this->getRequest();
                      
                      
                      Severity: Minor
                      Found in src/PageTranslation/DeleteTranslatableBundleSpecialPage.php - About 1 hr to fix

                        Method parseQueryString has 48 lines of code (exceeds 25 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 1 hr to fix

                          Method getData has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function getData(): array {
                                  // We need to get the primary group to get the correct file
                                  // So $group can be different from $this->group
                                  $group = $this->handle->getGroup();
                                  if ( !$group instanceof FileBasedMessageGroup ) {
                          Severity: Minor
                          Found in src/TranslatorInterface/Aid/GettextDocumentationAid.php - About 1 hr to fix

                            Method update has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function update( MessageHandle $handle, ?string $targetText ): bool {
                                    if ( !$handle->isValid() || $handle->getCode() === '' ) {
                                        return false;
                                    }
                            
                            
                            Severity: Minor
                            Found in src/TtmServer/DatabaseTtmServer.php - About 1 hr to fix

                              Method showLanguage has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private function showLanguage( string $code, array $users, int $cachedAt ): void {
                                      $out = $this->getOutput();
                                      $lang = $this->getLanguage();
                              
                                      // Information to be used inside the foreach loop.
                              Severity: Minor
                              Found in src/Statistics/ActiveLanguagesSpecialPage.php - About 1 hr to fix

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

                                    public function execute() {
                                        $csvFilePath = $this->getArg( 0 );
                                
                                        $username = $this->getOption( 'user' );
                                        $summary = $this->getOption( 'summary' );
                                Severity: Minor
                                Found in src/MessageGroupProcessing/ImportTranslationsFromCsv.php - About 1 hr to fix

                                  Function exportGroup has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      private function exportGroup( MessageGroup $group, array $servers ): void {
                                          $times = [
                                              'total' => -microtime( true ),
                                              'stats' => 0,
                                              'init' => 0,
                                  Severity: Minor
                                  Found in scripts/ttmserver-export.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 execute has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public function execute() {
                                          $this->checkUserRightsAny( 'pagetranslation' );
                                  
                                          $params = $this->extractRequestParams();
                                          $title = $this->getTitleFromTitleOrPageId( $params );
                                  Severity: Minor
                                  Found in src/PageTranslation/MarkForTranslationActionApi.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 tryMatch has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function tryMatch( $code, $mws, $gtLanguages, $clLanguages ) {
                                          if ( $mws !== '' ) {
                                              $mwExp = true;
                                              $lang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( $code );
                                          } else {
                                  Severity: Minor
                                  Found in scripts/plural-comparison.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 onActionMark has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected function onActionMark( Title $title, ?int $revision ): void {
                                          $request = $this->getRequest();
                                          $out = $this->getOutput();
                                          $translateTitle = $request->getCheck( 'translatetitle' );
                                  
                                  
                                  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