wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

Method addForm has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function addForm(): void {
        $formDescriptor = [
            'select' => [
                'type' => 'select',
                'name' => self::GROUPS,
Severity: Minor
Found in src/Statistics/MessageGroupStatsSpecialPage.php - About 1 hr to fix

    Method getSubpagesPerType has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getSubpagesPerType( TranslatableBundle $bundle, bool $fetchTalkPages ): array {
            $classifiedSubPages = $this->getEmptyResultSet();
    
            $classifiedSubPages['translationPages'] = $bundle->getTranslationPages();
            $classifiedSubPages['translationUnitPages'] = $bundle->getTranslationUnitPages();
    Severity: Minor
    Found in src/MessageGroupProcessing/SubpageListBuilder.php - About 1 hr to fix

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

          public function getDefinitions() {
              global $wgTranslateSandboxLimit;
      
              // This will contain the list of messages shown to the user
              $list = [];
      Severity: Minor
      Found in messagegroups/SandboxMessageGroup.php - About 1 hr to fix

        Function _resolveDataElementOptions has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _resolveDataElementOptions: function(element, index) {
                var me = this;
                var custom = element && element.custom;
                var cached = me._cachedDataOpts;
                if (cached && !custom) {
        Severity: Minor
        Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

          Method handleRename has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function handleRename( string $target, string $replacement ): ?Title {
                  $newSourceTitle = null;
          
                  $sourceMessageHandle = new MessageHandle( $this->title );
                  $movableTitles = TranslateReplaceTitle::getTitlesForMove( $sourceMessageHandle, $replacement );
          Severity: Minor
          Found in src/Synchronization/UpdateMessageJob.php - About 1 hr to fix

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

                public function execute( $par ): void {
                    $out = $this->getOutput();
                    $lang = $this->getLanguage();
                    $this->progressStatsTable = $this->progressStatsTableFactory->newFromContext( $this->getContext() );
            
            
            Severity: Minor
            Found in src/Statistics/ActiveLanguagesSpecialPage.php - About 1 hr to fix

              Method isValid has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function isValid( &$reason ): bool {
                      $group = $this->group;
                      $pattern = $group->getSourceFilePath( '*' );
                      $filename = $group->getSourceFilePath( $this->languageCode );
              
              
              Severity: Minor
              Found in src/MessageGroupProcessing/MessageGroupCache.php - About 1 hr to fix

                Method importData has 45 lines of code (exceeds 25 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 1 hr to fix

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

                                      $( '<div>' )
                                          .addClass( 'two columns tux-list-status text-center' )
                                          .append(
                                              $( '<span>' )
                                                  .addClass( statusClass )
                  Severity: Major
                  Found in resources/js/ext.translate.messagetable.js and 1 other location - About 1 hr to fix
                  resources/src/ext.translate.specialTranslationStash/index.js on lines 78..91

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

                  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

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

                              $( '<div>' )
                                  .addClass( 'two columns tux-list-status text-center' )
                                  .append(
                                      $( '<span>' )
                                          .addClass( statusClass )
                  resources/js/ext.translate.messagetable.js on lines 208..221

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

                  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

                  Method getIssues has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getIssues( Message $message, string $targetLanguage ): ValidationIssues {
                          $issues = new ValidationIssues();
                  
                          $pluralRule = GettextPlural::getPluralRule( $targetLanguage );
                          // Skip validation for languages for which we do not know the plural rule
                  Severity: Minor
                  Found in src/Validation/Validators/GettextPluralValidator.php - About 1 hr to fix

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

                        var graphInfo = {
                                edits: mw.msg( 'translate-statsf-count-edits' ),
                                users: mw.msg( 'translate-statsf-count-users' ),
                                registrations: mw.msg( 'translate-statsf-count-registrations' ),
                                reviews: mw.msg( 'translate-statsf-count-reviews' ),
                    Severity: Major
                    Found in resources/js/ext.translate.translationstats.graphbuilder.js and 1 other location - About 1 hr to fix
                    resources/js/ext.translate.translationstats.graphbuilder.js on lines 14..20

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

                    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

                            }, granularityInfo = {
                                years: mw.msg( 'translate-statsf-scale-years' ),
                                months: mw.msg( 'translate-statsf-scale-months' ),
                                weeks: mw.msg( 'translate-statsf-scale-weeks' ),
                                days: mw.msg( 'translate-statsf-scale-days' ),
                    Severity: Major
                    Found in resources/js/ext.translate.translationstats.graphbuilder.js and 1 other location - About 1 hr to fix
                    resources/js/ext.translate.translationstats.graphbuilder.js on lines 8..14

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

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

                    function computeLabelSizes(ctx, tickFonts, ticks, caches) {
                        var length = ticks.length;
                        var widths = [];
                        var heights = [];
                        var offsets = [];
                    Severity: Minor
                    Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

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

                          protected function getAllowedParams() {
                              return [
                                  'title' => [
                                      ParamValidator::PARAM_TYPE => 'string',
                                  ],
                      Severity: Minor
                      Found in src/PageTranslation/MarkForTranslationActionApi.php - About 1 hr to fix

                        Function buildTicks has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            buildTicks: function() {
                                var me = this;
                                var min = me.min;
                                var max = me.max;
                                var options = me.options;
                        Severity: Minor
                        Found in resources/lib/Chart.js/Chart.js - About 1 hr to fix

                          Method onDeleteTranslationUnit has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function onDeleteTranslationUnit(
                                  WikiPage $unit,
                                  User $user,
                                  $reason,
                                  $id,
                          Severity: Minor
                          Found in src/PageTranslation/Hooks.php - About 1 hr to fix

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

                                protected function getAllowedParams(): array {
                                    return [
                                        'group' => [
                                            ParamValidator::PARAM_TYPE => 'string',
                                            ParamValidator::PARAM_REQUIRED => true,
                            Severity: Minor
                            Found in src/MessageLoading/QueryMessageCollectionActionApi.php - About 1 hr to fix

                              Method readFromVariable has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function readFromVariable( string $data ): array {
                                      $data = TextContent::normalizeLineEndings( $data );
                                      $lines = array_map( 'ltrim', explode( "\n", $data ) );
                                      $authors = $messages = [];
                                      $lineContinuation = false;
                              Severity: Minor
                              Found in src/FileFormatSupport/JavaFormat.php - About 1 hr to fix

                                Function left has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    left: function ( position, data ) {
                                        var within = data.within,
                                            withinOffset = within.offset.left + within.scrollLeft,
                                            outerWidth = within.width,
                                            offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
                                Severity: Minor
                                Found in resources/src/ext.translate.groupselector/ui.position.js - 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