wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

Function afterDatasetsUpdate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    afterDatasetsUpdate: function(chart, options) {
        var count = (chart.data.datasets || []).length;
        var propagate = options.propagate;
        var sources = [];
        var meta, i, el, source;
Severity: Minor
Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

    Method applyFilter has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function applyFilter( string $filter, bool $condition, ?int $value ): void {
            $keys = $this->keys;
            if ( $filter === 'fuzzy' ) {
                $keys = $this->filterFuzzy( $keys, $condition );
            } elseif ( $filter === 'hastranslation' ) {
    Severity: Minor
    Found in src/MessageLoading/MessageCollection.php - About 1 hr to fix

      Method tabify has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function tabify( Skin $skin, array &$tabs ): void {
              $title = $skin->getTitle();
              if ( !$title->isSpecialPage() ) {
                  return;
              }
      Severity: Minor
      Found in src/Synchronization/ManageGroupsSpecialPage.php - About 1 hr to fix

        Method loadTranslationData has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function loadTranslationData( IDatabase $db, MessageHandle $handle ): array {
                $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
                $conditions = [];
        
                // The list of pages we want to select, and their latest versions
        Severity: Minor
        Found in src/TranslatorInterface/Aid/TranslationAidDataProvider.php - About 1 hr to fix

          Method getMessageParameters has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getMessageParameters(): array {
                  $params = parent::getMessageParameters();
          
                  $type = $this->entry->getFullType();
          
          
          Severity: Minor
          Found in src/LogFormatter.php - About 1 hr to fix

            Method getServersToUpdate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getServersToUpdate( ?string $requestedServiceId ): array {
                    $ttmServerFactory = Services::getInstance()->getTtmServerFactory();
                    if ( $requestedServiceId ) {
                        if ( !$ttmServerFactory->has( $requestedServiceId ) ) {
                            $this->logger->warning(
            Severity: Minor
            Found in src/TtmServer/TtmServerMessageUpdateJob.php - About 1 hr to fix

              Method subGroups has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function subGroups(
                      AggregateMessageGroup $parent,
                      array &$childIds = [],
                      string $fname = 'caller'
                  ): array {
              Severity: Minor
              Found in src/MessageGroupProcessing/MessageGroups.php - About 1 hr to fix

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

                    public function __construct() {
                        parent::__construct();
                        $this->addDescription(
                            'Export a translatable bundle into a file that can then be imported ' .
                            'into another wiki using the importTranslatableBundle.php script'

                  Method inAllLanguages has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function inAllLanguages(): array {
                          $dbr = $this->loadBalancer->getConnection( DB_REPLICA, 'vslow' );
                  
                          $res = $dbr->newSelectQueryBuilder()
                              ->select( [
                  Severity: Minor
                  Found in src/Statistics/TranslatorActivityQuery.php - About 1 hr to fix

                    Method getContents has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function getContents( $titles, int $namespace ): array {
                            $mwServices = MediaWikiServices::getInstance();
                            $dbr = $mwServices->getConnectionProvider()->getReplicaDatabase();
                            $revStore = $mwServices->getRevisionStore();
                            $titleContents = [];
                    Severity: Minor
                    Found in src/Utilities/Utilities.php - About 1 hr to fix

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

                          public function execute( $parameters ): void {
                              $this->setHeaders();
                              $this->addHelpLink( 'Help:Extension:Translate/Page translation administration' );
                      
                              $out = $this->getOutput();
                      Severity: Minor
                      Found in src/MessageGroupProcessing/AggregateGroupsSpecialPage.php - About 1 hr to fix

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

                                var $toggleAllButton = $( '<span>' ).addClass( 'collapsed' )
                                    .append(
                                        '[',
                                        $( '<a>' )
                                            .attr( 'href', '#' )
                        Severity: Major
                        Found in resources/src/ext.translate.special.languagestats/index.js and 1 other location - About 1 hr to fix
                        resources/src/ext.translate.special.languagestats/index.js on lines 43..67

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

                        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

                                helpers$1.each(scalesOptions.yAxes, function(yAxisOptions, index) {
                                    if (!yAxisOptions.id) {
                                        yAxisOptions.id = nextAvailableScaleId(scalesOptions.yAxes, 'y-axis-', index);
                                    }
                                });
                        Severity: Major
                        Found in resources/lib/Chart.js/Chart.js and 1 other location - About 1 hr to fix
                        resources/lib/Chart.js/Chart.js on lines 9443..9447

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

                        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

                                    var $toggler = $( '<span>' ).addClass( 'groupexpander collapsed' )
                                        .append(
                                            '[',
                                            $( '<a>' )
                                                .attr( 'href', '#' )
                        Severity: Major
                        Found in resources/src/ext.translate.special.languagestats/index.js and 1 other location - About 1 hr to fix
                        resources/src/ext.translate.special.languagestats/index.js on lines 85..113

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

                        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

                                helpers$1.each(scalesOptions.xAxes, function(xAxisOptions, index) {
                                    if (!xAxisOptions.id) {
                                        xAxisOptions.id = nextAvailableScaleId(scalesOptions.xAxes, 'x-axis-', index);
                                    }
                                });
                        Severity: Major
                        Found in resources/lib/Chart.js/Chart.js and 1 other location - About 1 hr to fix
                        resources/lib/Chart.js/Chart.js on lines 9449..9453

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

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

                            public static function addLanguageLinks( Title $title, array &$languageLinks ) {
                                global $wgPageTranslationLanguageList;
                        
                                if ( $wgPageTranslationLanguageList === 'tag-only' ) {
                                    return;
                        Severity: Minor
                        Found in src/PageTranslation/Hooks.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 parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function parse( string $text ): ParserOutput {
                                $nowiki = [];
                                $text = $this->armourNowiki( $nowiki, $text );
                        
                                $sections = [];
                        Severity: Minor
                        Found in src/PageTranslation/TranslatablePageParser.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 getAuthors has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function getAuthors(): array {
                                $this->loadTranslations();
                        
                                $authors = array_flip( $this->authors );
                        
                        
                        Severity: Minor
                        Found in src/MessageLoading/MessageCollection.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 getPagesToMove has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function getPagesToMove(
                                Title $source,
                                Title $target,
                                bool $moveSubPages,
                                bool $fetchTranslatableSubpages,
                        Severity: Minor
                        Found in src/PageTranslation/TranslatableBundleMover.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 doCreate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private function doCreate(): void {
                                $params = $this->extractRequestParams();
                        
                                // Do validations
                                foreach ( explode( '|', 'username|password|email' ) as $field ) {
                        Severity: Minor
                        Found in src/TranslatorSandbox/TranslatorSandboxActionApi.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