wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 994 of 1,238 total issues

MessageBundleMessageGroup has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

class MessageBundleMessageGroup implements MessageGroup {
    /** Name of the bundle (prefixed text of the bundle page) */
    private string $name;
    private string $groupId;
    private int $pageId;
Severity: Minor
Found in src/MessageBundleTranslation/MessageBundleMessageGroup.php - About 2 hrs to fix

    Function splineCurveMonotone has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        helpers$1.splineCurveMonotone = function(points) {
            // This function calculates Bézier control points in a similar way than |splineCurve|,
            // but preserves monotonicity of the provided data and ensures no local extremums are added
            // between the dataset discrete points due to the interpolation.
            // See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation
    Severity: Major
    Found in resources/lib/Chart.js/Chart.js - About 2 hrs to fix

      Method formatGroup has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function formatGroup( $mixed, array $props, int $depth = 0 ): array {
              $params = $this->extractRequestParams();
              $context = $this->getContext();
      
              // Default
      Severity: Major
      Found in src/MessageGroupProcessing/QueryMessageGroupsActionApi.php - About 2 hrs to fix

        File MessageSourceChange.php has 282 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * Contains a class to track changes to the messages when importing messages from remote source.
         * @author Abijeet Patro
         * @license GPL-2.0-or-later
        Severity: Minor
        Found in src/MessageSync/MessageSourceChange.php - About 2 hrs to fix

          Function save has 69 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  save: function () {
                      var translateEditor = this;
          
                      mw.hook( 'mw.translate.editor.beforeSubmit' ).fire( translateEditor.$editor );
                      var translation = translateEditor.$editor.find( '.tux-textarea-translation' ).val();
          Severity: Major
          Found in resources/js/ext.translate.editor.js - About 2 hrs to fix

            Function showData has 69 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function showData( apiResponse, options ) {
                        var graphData = getAxesLabelsAndData( apiResponse.data ),
                            graphDatasets = [],
                            datasetLabels = apiResponse.labels;
            
            
            Severity: Major
            Found in resources/js/ext.translate.translationstats.graphbuilder.js - About 2 hrs to fix

              Method createMessageGroup has 69 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function createMessageGroup( string $id, array $info ): MessageGroup {
                      $conf = [];
                      $conf['BASIC']['class'] = MediaWikiExtensionMessageGroup::class;
                      $conf['BASIC']['id'] = $id;
                      $conf['BASIC']['namespace'] = $this->getNamespace();
              Severity: Major
              Found in src/MessageGroupConfiguration/PremadeMediaWikiExtensionGroups.php - About 2 hrs to fix

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

                    public function execute() {
                        global $wgTranslateMessageNamespaces;
                
                        $namespace = $this->getOption( 'namespace', $wgTranslateMessageNamespaces );
                        $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
                Severity: Minor
                Found in scripts/populateFuzzy.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 parseQueryString has a Cognitive Complexity of 20 (exceeds 5 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 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 execute has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function execute() {
                        $params = $this->extractRequestParams();
                
                        $title = Title::newFromText( $params['title'] );
                        if ( !$title ) {
                Severity: Minor
                Found in src/TranslatorInterface/Aid/TranslationAidsActionApi.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 execute has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function execute( $par ) {
                        $this->target = $this->getLanguage()->getCode();
                        $request = $this->getRequest();
                
                        $this->purge = $request->getVal( 'action' ) === 'purge';
                Severity: Minor
                Found in src/Statistics/LanguageStatsSpecialPage.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 parseGettext has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function parseGettext( string $data ): array {
                        $mangler = $this->group->getMangler();
                        $useCtxtAsKey = $this->extra['CtxtAsKey'] ?? false;
                        $keyAlgorithm = 'simple';
                        if ( isset( $this->extra['keyAlgorithm'] ) ) {
                Severity: Minor
                Found in src/FileFormatSupport/GettextFormat.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

                File AggregateGroupsActionApi.php has 280 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                declare( strict_types = 1 );
                
                namespace MediaWiki\Extension\Translate\MessageGroupProcessing;
                
                
                Severity: Minor
                Found in src/MessageGroupProcessing/AggregateGroupsActionApi.php - About 2 hrs to fix

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

                      public function execute( $par ) {
                          $request = $this->getRequest();
                          $user = $this->getUser();
                          $this->addHelpLink( 'Help:Extension:Translate/Move_translatable_page' );
                          $out = $this->getOutput();
                  Severity: Major
                  Found in src/PageTranslation/MoveTranslatableBundleSpecialPage.php - About 2 hrs to fix

                    Method markForTranslation has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function markForTranslation(
                            TranslatablePageMarkOperation $operation,
                            TranslatablePageSettings $pageSettings,
                            User $user
                        ): int {
                    Severity: Major
                    Found in src/PageTranslation/TranslatablePageMarker.php - About 2 hrs to fix

                      Method showConfirmation has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function showConfirmation(): void {
                              $out = $this->getOutput();
                              $count = 0;
                              $subpageCount = 0;
                      
                      
                      Severity: Major
                      Found in src/PageTranslation/DeleteTranslatableBundleSpecialPage.php - About 2 hrs to fix

                        File ExportTranslationsSpecialPage.php has 278 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        <?php
                        declare( strict_types = 1 );
                        
                        namespace MediaWiki\Extension\Translate\Synchronization;
                        
                        
                        Severity: Minor
                        Found in src/Synchronization/ExportTranslationsSpecialPage.php - About 2 hrs to fix

                          Utilities has 24 functions (exceeds 20 allowed). Consider refactoring.
                          Open

                          class Utilities {
                              /**
                               * Does quick normalisation of message name so that in can be looked from the
                               * database.
                               * @param string $message Name of the message
                          Severity: Minor
                          Found in src/Utilities/Utilities.php - About 2 hrs to fix

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

                                public function __construct() {
                                    parent::__construct();
                                    $this->addDescription( 'Script to generate statistics about the localisation ' .
                                        'level of one or more message groups.' );
                                    $this->addOption(
                            Severity: Major
                            Found in scripts/groupStatistics.php - About 2 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language