wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 994 of 1,238 total issues

ManageGroupsSpecialPage has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

class ManageGroupsSpecialPage extends SpecialPage {
    private const GROUP_SYNC_INFO_WRAPPER_CLASS = 'smg-group-sync-cache-info';
    private const RIGHT = 'translate-manage';
    protected DifferenceEngine $diff;
    /** Name of the import. */
Severity: Minor
Found in src/Synchronization/ManageGroupsSpecialPage.php - About 3 hrs to fix

    MessageGroupBase has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class MessageGroupBase implements MessageGroup {
        /** @var array */
        protected $conf;
        /** @var int|false */
        protected $namespace;
    Severity: Minor
    Found in messagegroups/MessageGroupBase.php - About 3 hrs to fix

      GettextFormat has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class GettextFormat extends SimpleFormat implements MetaYamlSchemaExtender {
          private bool $allowPotMode = false;
          private bool $offlineMode = false;
      
          public function supportsFuzzy(): string {
      Severity: Minor
      Found in src/FileFormatSupport/GettextFormat.php - About 3 hrs to fix

        File DeleteTranslatableBundleSpecialPage.php has 290 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/DeleteTranslatableBundleSpecialPage.php - About 2 hrs to fix

          Method parseFile has 74 lines of code (exceeds 25 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: Major
          Found in src/MessageGroupProcessing/CsvTranslationImporter.php - About 2 hrs to fix

            Function fit has 73 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                fit: function() {
                    var me = this;
                    // Reset
                    var minSize = me.minSize = {
                        width: 0,
            Severity: Major
            Found in resources/lib/Chart.js/Chart.js - About 2 hrs to fix

              Method onActionMark has 73 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function onActionMark( Title $title, ?int $revision ): void {
                      $request = $this->getRequest();
                      $out = $this->getOutput();
                      $translateTitle = $request->getCheck( 'translatetitle' );
              
              
              Severity: Major
              Found in src/PageTranslation/PageTranslationSpecialPage.php - About 2 hrs to fix

                Method __construct has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function __construct() {
                        parent::__construct();
                        $this->addArg(
                            'xml-path',
                            'Path to the XML file to be imported',

                  Function handleRenameSubmit has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function handleRenameSubmit(
                          MessageGroup $group,
                          MessageSourceChange $sourceChanges,
                          WebRequest $req,
                          string $language,
                  Severity: Minor
                  Found in src/Synchronization/ManageGroupsSpecialPage.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 backport has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function backport(
                          FileBasedMessageGroup $group,
                          string $source,
                          string $targetPath,
                          array $keyCompatibilityMap,
                  Severity: Minor
                  Found in src/Synchronization/BackportTranslationsMaintenanceScript.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 formatGroup has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function formatGroup( $mixed, array $props, int $depth = 0 ): array {
                          $params = $this->extractRequestParams();
                          $context = $this->getContext();
                  
                          // Default
                  Severity: Minor
                  Found in src/MessageGroupProcessing/QueryMessageGroupsActionApi.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

                  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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language