wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

Function getData has a Cognitive Complexity of 16 (exceeds 5 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 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 unflattenCLDRPlurals has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function unflattenCLDRPlurals( string $key, string $message ) {
        // Quick escape.
        if ( !str_contains( $message, '{{PLURAL' ) ) {
            return false;
        }
Severity: Minor
Found in src/MessageProcessing/ArrayFlattener.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 getMetadata has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function getMetadata(): MessageBundleMetadata {
        if ( $this->metadata !== null ) {
            return $this->metadata;
        }

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

    public function findMessage( $language, $key, $possibleStates = [], &$modificationType = null ) {
        $allChanges = [];
        $allChanges[self::ADDITION] = $this->getAdditions( $language );
        $allChanges[self::DELETION] = $this->getDeletions( $language );
        $allChanges[self::CHANGE] = $this->getChanges( $language );
Severity: Minor
Found in src/MessageSync/MessageSourceChange.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 handleRename has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    protected function handleRename(
        MessageGroup $group,
        MessageSourceChange $sourceChanges,
        string $msgKey,
        string $keyToRename,
Severity: Minor
Found in src/MessageGroupProcessing/ManageMessageGroupsActionApi.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 importData has a Cognitive Complexity of 16 (exceeds 5 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 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 update has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    update: function(reset) {
        var me = this;
        var chart = me.chart;
        var chartArea = chart.chartArea;
        var opts = chart.options;
Severity: Major
Found in resources/lib/Chart.js/Chart.js - About 2 hrs to fix

    Function getCaretPosition has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        getCaretPosition: function(tooltipPoint, size, vm) {
            var x1, x2, x3, y1, y2, y3;
            var caretSize = vm.caretSize;
            var cornerRadius = vm.cornerRadius;
            var xAlign = vm.xAlign;
    Severity: Major
    Found in resources/lib/Chart.js/Chart.js - About 2 hrs to fix

      Method translationPageHeader has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function translationPageHeader( IContextSource $context, TranslatablePage $page ) {
              global $wgTranslateKeepOutdatedTranslations;
      
              $title = $context->getTitle();
              if ( !$title->exists() ) {
      Severity: Major
      Found in src/PageTranslation/Hooks.php - About 2 hrs to fix

        Method messageSelector has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function messageSelector(): string {
                $output = Html::openElement( 'div', [ 'class' => 'row tux-messagetable-header hide' ] );
                $output .= Html::openElement( 'div', [ 'class' => 'nine columns' ] );
                $output .= Html::openElement( 'ul', [ 'class' => 'row tux-message-selector' ] );
                $userId = $this->getUser()->getId();
        Severity: Major
        Found in src/TranslatorInterface/TranslateSpecialPage.php - About 2 hrs to fix

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

              public function execute( $par ) {
                  $output = $this->getOutput();
                  $this->setHeaders();
                  $this->checkPermissions();
                  $this->addHelpLink( 'Help:Extension:Translate/Page translation administration' );
          Severity: Major
          Found in src/PageTranslation/MigrateTranslatablePageSpecialPage.php - About 2 hrs to fix

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

                public function execute() {
                    $services = MediaWikiServices::getInstance();
                    $db = $services->getDBLoadBalancer()->getConnection( DB_PRIMARY );
            
                    $dbGroupIds = $db->newSelectQueryBuilder()
            Severity: Major
            Found in src/Statistics/CleanupTranslationProgressStatsMaintenanceScript.php - About 2 hrs to fix

              Method showAggregateGroups has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function showAggregateGroups( array $aggregates ): void {
                      $out = $this->getOutput();
                      $out->addModules( 'ext.translate.special.aggregategroups' );
              
                      $nojs = Html::errorBox(
              Severity: Major
              Found in src/MessageGroupProcessing/AggregateGroupsSpecialPage.php - About 2 hrs to fix

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

                    private function eGroup( string $name, FormOptions $opts ): string {
                        $value = implode( ',', $opts[$name] );
                
                        $select = $this->groupSelector();
                        $select->setTargetId( 'group' );
                Severity: Major
                Found in src/Statistics/TranslationStatsSpecialPage.php and 1 other location - About 2 hrs to fix
                src/Statistics/TranslationStatsSpecialPage.php on lines 193..201

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

                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

                    private function eLanguage( string $name, FormOptions $opts ): string {
                        $value = implode( ',', $opts[$name] );
                
                        $select = $this->languageSelector();
                        $select->setTargetId( 'language' );
                Severity: Major
                Found in src/Statistics/TranslationStatsSpecialPage.php and 1 other location - About 2 hrs to fix
                src/Statistics/TranslationStatsSpecialPage.php on lines 215..223

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

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

                EntitySelectorWidget.prototype.getLookupMenuOptionsFromData = function ( response ) {
                    var groups = response.groups || [];
                    var messages = response.messages || [];
                    var finalResult = [];
                    var i = 0;
                Severity: Major
                Found in resources/src/ext.translate.entity.selector/index.js - About 2 hrs to fix

                  Method listPages has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function listPages(): void {
                          $out = $this->getOutput();
                  
                          $res = self::loadPagesFromDB();
                          $allPages = self::buildPageArray( $res );
                  Severity: Major
                  Found in src/PageTranslation/PageTranslationSpecialPage.php - About 2 hrs to fix

                    Method setup has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function setup( ?string $parameters ): void {
                            $request = $this->getRequest();
                    
                            $defaults = [
                                'language' => $this->getLanguage()->getCode(),
                    Severity: Major
                    Found in src/TranslatorInterface/TranslateSpecialPage.php - About 2 hrs to fix

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

                          protected function getAllowedParams(): array {
                              $available = $this->getSearchableTtmServers();
                      
                              $filters = $this->getAllowedFilters();
                      
                      
                      Severity: Major
                      Found in src/TtmServer/SearchTranslationsActionApi.php - About 2 hrs to fix

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

                            public function execute( $parameters ) {
                                $this->setHeaders();
                        
                                // Security and validity checks
                                if ( !$this->userCanExecute( $this->getUser() ) ) {
                        Severity: Major
                        Found in src/Synchronization/ImportTranslationsSpecialPage.php - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language