wikimedia/mediawiki-extensions-UniversalLanguageSelector

View on GitHub
resources/js/ext.uls.inputsettings.js

Summary

Maintainability
D
2 days
Test Coverage

File ext.uls.inputsettings.js has 380 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * ULS-based ime settings panel
 *
 * Copyright (C) 2012 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
 * Niklas Laxström, Pau Giner, Santhosh Thottingal, Siebrand Mazeland and other
Severity: Minor
Found in resources/js/ext.uls.inputsettings.js - About 5 hrs to fix

    Function prepareMoreLanguages has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            prepareMoreLanguages: function () {
                var inputSettings = this,
                    $languages, $moreLanguagesButton;
    
                $languages = this.$template.find( '.uls-ui-languages' );
    Severity: Major
    Found in resources/js/ext.uls.inputsettings.js - About 2 hrs to fix

      Function prepareLanguages has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              prepareLanguages: function () {
                  var inputSettings = this,
                      SUGGESTED_LANGUAGES_NUMBER = 3,
                      selectedImeLanguage = $.ime.preferences.getLanguage(),
                      languagesForButtons, $languages, suggestedLanguages,
      Severity: Major
      Found in resources/js/ext.uls.inputsettings.js - About 2 hrs to fix

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

                renderInputmethodOption: function ( imeId, selected ) {
                    var $imeLabel, name, description, $helplink, inputmethod, $inputMethodItem;
        
                    if ( imeId !== 'system' && !$.ime.sources[ imeId ] ) {
                        // imeId not known for jquery.ime.
        Severity: Minor
        Found in resources/js/ext.uls.inputsettings.js - About 1 hr to fix

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

                  apply: function () {
                      var previousIM,
                          inputSettings = this,
                          previousLanguage = inputSettings.savedRegistry.language,
                          currentlyEnabled = $.ime.preferences.isEnabled(),
          Severity: Minor
          Found in resources/js/ext.uls.inputsettings.js - About 1 hr to fix

            Function prepareInputmethods has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    prepareInputmethods: function ( language ) {
                        var index, inputSettings, $imeListContainer, defaultInputmethod,
                            imes, selected, imeId, $imeListTitle;
            
                        imes = $.ime.languages[ language ];
            Severity: Minor
            Found in resources/js/ext.uls.inputsettings.js - About 1 hr to fix

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

                              $button = $( '<button>' )
                                  .addClass( 'cdx-button uls-language-button autonym' )
                                  .text( $.uls.data.getAutonym( language ) )
                                  .prop( {
                                      lang: language,
              Severity: Major
              Found in resources/js/ext.uls.inputsettings.js and 1 other location - About 2 hrs to fix
              resources/js/ext.uls.displaysettings.js on lines 272..278

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

              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

                          for ( lang in suggestedLanguages ) {
                              // Skip already found languages
                              if ( languagesForButtons.indexOf( suggestedLanguages[ lang ] ) > -1 ) {
                                  continue;
                              }
              Severity: Major
              Found in resources/js/ext.uls.inputsettings.js and 1 other location - About 1 hr to fix
              resources/js/ext.uls.displaysettings.js on lines 244..256

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

              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

                          $moreLanguagesButton.on( 'click', function () {
                              inputSettings.$parent.hide();
                              mw.hook( 'mw.uls.ime.morelanguages' ).fire();
                          } );
              Severity: Minor
              Found in resources/js/ext.uls.inputsettings.js and 1 other location - About 40 mins to fix
              resources/js/ext.uls.displaysettings.js on lines 366..369

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

              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.languagesettings.modules = $.extend( $.fn.languagesettings.modules, {
                      input: InputSettings
                  } );
              Severity: Minor
              Found in resources/js/ext.uls.inputsettings.js and 1 other location - About 40 mins to fix
              resources/js/ext.uls.displaysettings.js on lines 727..729

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

              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