wikimedia/mediawiki-extensions-UniversalLanguageSelector

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

Summary

Maintainability
F
3 days
Test Coverage

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

/*!
 * ULS-based display 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.displaysettings.js - About 6 hrs to fix

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

            prepareLanguages: function () {
                var $loginCta,
                    displaySettings = this,
                    SUGGESTED_LANGUAGES_NUMBER = 3,
                    anonsAllowed = mw.config.get( 'wgULSAnonCanChangeLanguage' ),
    Severity: Major
    Found in resources/js/ext.uls.displaysettings.js - About 3 hrs to fix

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

              listen: function () {
                  var displaySettings = this,
                      $contentFontSelector = this.$template.find( '#content-font-selector' ),
                      $uiFontSelector = this.$template.find( '#ui-font-selector' ),
                      $tabButtons = displaySettings.$template.find( '.uls-display-settings-tab-switcher button' );
      Severity: Major
      Found in resources/js/ext.uls.displaysettings.js - About 2 hrs to fix

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

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

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

                  apply: function () {
                      if ( !this.dirty ) {
                          // No changes to save in this module.
                          return;
                      }
          Severity: Minor
          Found in resources/js/ext.uls.displaysettings.js - About 1 hr to fix

            Function prepareFontSelector has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    prepareFontSelector: function ( target ) {
                        var language, fonts, $fontSelector, savedFont,
                            $systemFont, $fontLabel, $fontsSection;
            
                        // Get the language code from the right property -
            Severity: Minor
            Found in resources/js/ext.uls.displaysettings.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.displaysettings.js and 1 other location - About 2 hrs to fix
              resources/js/ext.uls.inputsettings.js on lines 294..300

              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

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

                          $uiFontSelector.on( 'change', function () {
                              displaySettings.markDirty();
                              mw.webfonts.preferences.setFont( displaySettings.uiLanguage,
                                  $( this ).val()
                              );
              Severity: Major
              Found in resources/js/ext.uls.displaysettings.js and 1 other location - About 2 hrs to fix
              resources/js/ext.uls.displaysettings.js on lines 579..585

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

              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

                          $contentFontSelector.on( 'change', function () {
                              displaySettings.markDirty();
                              mw.webfonts.preferences.setFont( displaySettings.contentLanguage,
                                  $( this ).val()
                              );
              Severity: Major
              Found in resources/js/ext.uls.displaysettings.js and 1 other location - About 2 hrs to fix
              resources/js/ext.uls.displaysettings.js on lines 571..577

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

              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.displaysettings.js and 1 other location - About 1 hr to fix
              resources/js/ext.uls.inputsettings.js on lines 260..272

              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

                          this.$template.find( '#content-font-selector-label strong' )
                              .text( $.i18n( 'ext-uls-webfonts-select-for', $.uls.data.getAutonym( this.contentLanguage ) ) );
              Severity: Minor
              Found in resources/js/ext.uls.displaysettings.js and 1 other location - About 50 mins to fix
              resources/js/ext.uls.displaysettings.js on lines 498..499

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

              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

                          this.$template.find( '#ui-font-selector-label strong' )
                              .text( $.i18n( 'ext-uls-webfonts-select-for', $.uls.data.getAutonym( this.uiLanguage ) ) );
              Severity: Minor
              Found in resources/js/ext.uls.displaysettings.js and 1 other location - About 50 mins to fix
              resources/js/ext.uls.displaysettings.js on lines 500..501

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

              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 () {
                              displaySettings.$parent.hide();
                              mw.hook( 'mw.uls.interface.morelanguages' ).fire();
                          } );
              Severity: Minor
              Found in resources/js/ext.uls.displaysettings.js and 1 other location - About 40 mins to fix
              resources/js/ext.uls.inputsettings.js on lines 400..403

              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 = Object.assign( $.fn.languagesettings.modules, {
                      display: DisplaySettings
                  } );
              Severity: Minor
              Found in resources/js/ext.uls.displaysettings.js and 1 other location - About 40 mins to fix
              resources/js/ext.uls.inputsettings.js on lines 593..595

              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