wikimedia/mediawiki-extensions-Translate

View on GitHub
resources/js/ext.translate.messagetable.js

Summary

Maintainability
F
5 days
Test Coverage

File ext.translate.messagetable.js has 621 lines of code (exceeds 250 allowed). Consider refactoring.
Open

( function () {
    'use strict';

    var itemsClass = {
        proofread: '.tux-message-proofread',
Severity: Major
Found in resources/js/ext.translate.messagetable.js - About 1 day to fix

    Function displayEmptyListHelp has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            displayEmptyListHelp: function () {
                var messageTable = this,
                    // @todo Ugly! This should be provided somehow
                    selectedTab = $( '.tux-message-selector .selected' ).data( 'title' ),
                    $wrap = $( '<div>' ).addClass( 'tux-empty-list' ),
    Severity: Major
    Found in resources/js/ext.translate.messagetable.js - About 3 hrs to fix

      Function load has 80 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              load: function ( limit ) {
                  var self = this,
                      offset = this.$loader.data( 'offset' ),
                      pageSize = limit || this.$loader.data( 'pagesize' );
      
      
      Severity: Major
      Found in resources/js/ext.translate.messagetable.js - About 3 hrs to fix

        Function addTranslate has 75 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                addTranslate: function ( message ) {
                    var targetLangCode = this.$container.data( 'targetlangcode' ),
                        sourceLangCode = this.$container.data( 'sourcelangcode' ),
                        sourceLangDir = $.uls.data.getDir( sourceLangCode ),
                        status = message.properties.status,
        Severity: Major
        Found in resources/js/ext.translate.messagetable.js - About 3 hrs to fix

          Function switchMode has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  switchMode: function ( mode ) {
                      var messageTable = this,
                          filter = this.settings.filter,
                          userId = mw.config.get( 'wgUserId' );
          
          
          Severity: Major
          Found in resources/js/ext.translate.messagetable.js - About 2 hrs to fix

            Function addProofread has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    addProofread: function ( message ) {
                        var $message = $( '<div>' )
                            .addClass( 'row tux-message tux-message-proofread' );
            
                        this.$container.append( $message );
            Severity: Minor
            Found in resources/js/ext.translate.messagetable.js - About 1 hr to fix

              Function search has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      search: function ( query ) {
                          var resultCount = 0,
                              matcher = new RegExp( '(^|\\s|\\b)' + escapeRegex( query ), 'i' );
              
                          this.$container.find( itemsClass[ this.mode ] ).each( function () {
              Severity: Minor
              Found in resources/js/ext.translate.messagetable.js - About 1 hr to fix

                Function changeSettings has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        changeSettings: function ( changes ) {
                            // Clear current messages
                            this.clear();
                            this.settings = $.extend( this.settings, changes );
                
                
                Severity: Minor
                Found in resources/js/ext.translate.messagetable.js - About 1 hr to fix

                  Function listen has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          listen: function () {
                              var messageTable = this,
                                  $filterInput = this.$container.parent().find( '.tux-message-filter-box' );
                  
                              // Vector has transitions of 250ms which affect layout. Let those finish.
                  Severity: Minor
                  Found in resources/js/ext.translate.messagetable.js - About 1 hr to fix

                    Function getMessages has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            getMessages: function ( messageGroup, language, offset, limit, filter ) {
                    Severity: Minor
                    Found in resources/js/ext.translate.messagetable.js - About 35 mins to fix

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

                                          $( '<div>' )
                                              .addClass( 'eight columns tux-list-message' )
                                              .append(
                                                  $( '<span>' )
                                                      .addClass( 'tux-list-source' )
                      Severity: Major
                      Found in resources/js/ext.translate.messagetable.js and 1 other location - About 5 hrs to fix
                      resources/src/ext.translate.specialTranslationStash/index.js on lines 54..77

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

                      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

                          $.fn.messagetable = function ( options ) {
                              return this.each( function () {
                                  var $this = $( this ),
                                      data = $this.data( 'messagetable' );
                      
                      
                      Severity: Major
                      Found in resources/js/ext.translate.messagetable.js and 1 other location - About 4 hrs to fix
                      resources/js/ext.translate.editor.js on lines 1526..1541

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

                      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

                                      } else if ( selectedTab === 'unproofread' ) {
                                          $emptyListHeader.text( mw.msg( 'tux-empty-nothing-new-to-proofread' ) );
                                          $guide.text( mw.msg( 'tux-empty-you-can-help-providing' ) );
                                          $actions.append( messageTable.otherActionButton(
                                              'tux-empty-you-can-review-already-proofread',
                      Severity: Major
                      Found in resources/js/ext.translate.messagetable.js and 1 other location - About 2 hrs to fix
                      resources/js/ext.translate.messagetable.js on lines 672..700

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

                      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

                                      } else if ( selectedTab === 'translated' ) {
                                          $emptyListHeader.text( mw.msg( 'tux-empty-list-translated' ) );
                                          $guide.text( mw.msg( 'tux-empty-list-translated-guide' ) );
                                          $actions.append( messageTable.otherActionButton(
                                              'tux-empty-list-translated-action',
                      Severity: Major
                      Found in resources/js/ext.translate.messagetable.js and 1 other location - About 2 hrs to fix
                      resources/js/ext.translate.messagetable.js on lines 658..667

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

                      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 )
                      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

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

                                  $message.pagemode( {
                                      message: message,
                                      sourcelangcode: this.$container.data( 'sourcelangcode' ),
                                      targetlangcode: this.$container.data( 'targetlangcode' )
                                  } );
                      Severity: Minor
                      Found in resources/js/ext.translate.messagetable.js and 1 other location - About 50 mins to fix
                      resources/js/ext.translate.messagetable.js on lines 254..258

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

                      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

                                  $message.proofread( {
                                      message: message,
                                      sourcelangcode: this.$container.data( 'sourcelangcode' ),
                                      targetlangcode: this.$container.data( 'targetlangcode' )
                                  } );
                      Severity: Minor
                      Found in resources/js/ext.translate.messagetable.js and 1 other location - About 50 mins to fix
                      resources/js/ext.translate.messagetable.js on lines 317..321

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

                      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

                      There are no issues that match your filters.

                      Category
                      Status