wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 994 of 1,238 total issues

Function normalize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function normalize( array $validCounts ): void {
        $this->formOptions->validateIntBounds( 'days', 1, 10000 );
        $this->formOptions->validateIntBounds( 'width', 200, 1000 );
        $this->formOptions->validateIntBounds( 'height', 200, 1000 );

Severity: Minor
Found in src/Statistics/TranslationStatsGraphOptions.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 doExport has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private function doExport(): Status {
        $out = $this->getOutput();
        $group = MessageGroups::getGroup( $this->groupId );
        $collection = $this->setupCollection( $group );

Severity: Minor
Found in src/Synchronization/ExportTranslationsSpecialPage.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 getMessages has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function getMessages(): array {
        if ( $this->messages !== null ) {
            return $this->messages;
        }

Severity: Minor
Found in src/MessageBundleTranslation/MessageBundleContent.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 isTranslatableMessage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public static function isTranslatableMessage( MessageHandle $handle, string $targetLanguage ): bool {
        static $cache = [];

        if ( !$handle->isValid() ) {
            return false;
Severity: Minor
Found in src/MessageGroupProcessing/MessageGroups.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 12 (exceeds 5 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

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 readFromVariable has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function readFromVariable( string $data ): array {
        $reader = new SimpleXMLElement( $data );

        $messages = [];
        $mangler = $this->group->getMangler();
Severity: Minor
Found in src/FileFormatSupport/AndroidXmlFormat.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 fixMessageParams has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private function fixMessageParams( IContextSource $context, array $params ): array {
        $out = [];
        $lang = $context->getLanguage();

        foreach ( $params as $param ) {
Severity: Minor
Found in src/Validation/ValidationResult.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 init has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    LanguageFilter.prototype.init = function () {
        var languageFilter = this;

        var $clearButton = $( '<button>' )
            .addClass( 'clear-language-selector hide' )
Severity: Minor
Found in resources/js/ext.translate.special.managetranslatorsandbox.js - About 1 hr to fix

    Function alignHeaders has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function alignHeaders( units, translationUnits ) {
            // The content does not have information about the page title. Add an empty string
            // at the beginning of the translationUnits array to match the length of units and
            // translationUnits.
            if ( units.length && units[ 0 ].identifier === 'Page_display_title' ) {
    Severity: Minor
    Found in resources/js/ext.translate.special.pagemigration.js - About 1 hr to fix

      Function getMaxBorderWidth has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          getMaxBorderWidth: function(arcs) {
              var me = this;
              var max = 0;
              var chart = me.chart;
              var i, ilen, meta, arc, controller, options, borderWidth, hoverWidth;
      Severity: Minor
      Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

        Method getPageList has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function getPageList( array $pages, string $type ): string {
                $items = [];
                $tagsTextCache = [];
        
                $tagDiscouraged = $this->msg( 'tpt-tag-discouraged' )->escaped();
        Severity: Minor
        Found in src/PageTranslation/PageTranslationSpecialPage.php - About 1 hr to fix

          Method deleteAsynchronously has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function deleteAsynchronously(
                  Title $title,
                  bool $isTranslation,
                  UserIdentity $user,
                  array $subpageList,
          Severity: Minor
          Found in src/PageTranslation/TranslatableBundleDeleter.php - About 1 hr to fix

            Method requeueError has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function requeueError( string $serviceName, Exception $e ): void {
                    $this->logger->warning(
                        'Exception thrown while running {command} on ' .
                        'service {service}: {errorMessage}',
                        [
            Severity: Minor
            Found in src/TtmServer/TtmServerMessageUpdateJob.php - About 1 hr to fix

              Method getRenameJobParams has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function getRenameJobParams(
                      array $currentMsg,
                      MessageSourceChange $sourceChanges,
                      string $languageCode,
                      int $groupNamespace,
              Severity: Minor
              Found in src/Synchronization/ManageGroupsSpecialPage.php - About 1 hr to fix

                Method makeNumberColumns has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function makeNumberColumns( array $stats ): string {
                        $total = $stats[MessageGroupStats::TOTAL];
                        $translated = $stats[MessageGroupStats::TRANSLATED];
                        $fuzzy = $stats[MessageGroupStats::FUZZY];
                        $proofread = $stats[MessageGroupStats::PROOFREAD];
                Severity: Minor
                Found in src/Statistics/StatsTable.php - About 1 hr to fix

                  Method onPageSaveComplete has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function onPageSaveComplete(
                          $wikiPage,
                          $user,
                          $summary,
                          $flags,
                  Severity: Minor
                  Found in src/MessageBundleTranslation/Hooks.php - About 1 hr to fix

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

                        public function execute() {
                            $this->language = $this->getServiceContainer()->getContentLanguage();
                    
                            $groupInput = $this->getOption( 'group', '*' );
                            $groupIdPattern = self::commaList2Array( $groupInput );

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

                          public function getDefinitions() {
                              $groups = MessageGroups::getAllGroups();
                              $keys = [];
                      
                              /** @var $g MessageGroup */
                      Severity: Minor
                      Found in messagegroups/WorkflowStatesMessageGroup.php - About 1 hr to fix

                        Function interpolate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function interpolate(start, view, model, ease) {
                            var keys = Object.keys(model);
                            var i, ilen, key, actual, origin, target, type, c0, c1;
                        
                            for (i = 0, ilen = keys.length; i < ilen; ++i) {
                        Severity: Minor
                        Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

                          Function top has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              top: function ( position, data ) {
                                  var within = data.within,
                                      withinOffset = within.offset.top + within.scrollTop,
                                      outerHeight = within.height,
                                      offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
                          Severity: Minor
                          Found in resources/src/ext.translate.groupselector/ui.position.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language