wikimedia/mediawiki-extensions-UniversalLanguageSelector

View on GitHub

Showing 108 of 274 total issues

Function initModule has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        initModule: function ( moduleName, active ) {
            var $settingsTitle, $settingsText, $settingsLink,
                languageSettings = this,
                module = new $.fn.languagesettings.modules[ moduleName ]( languageSettings ),
                $settingsMenuItems = languageSettings.$window.find( '.settings-menu-items' );
Severity: Minor
Found in resources/js/ext.uls.languagesettings.js - About 1 hr to fix

    Function keypress has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            keypress: function ( e ) {
                var altGr = false,
                    c, input, replacement;
    
                if ( !this.active ) {
    Severity: Minor
    Found in lib/jquery.ime/jquery.ime.js - About 1 hr to fix

      Function addActionsMenuTriggers has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function addActionsMenuTriggers( uls ) {
              var $ulsSettingsBlock = addLanguageSettingsTrigger( uls );
      
              var actionItemsRegistry = mw.uls.ActionsMenuItemsRegistry;
              actionItemsRegistry.on( 'register', onActionItemAdded );
      Severity: Minor
      Found in resources/js/ext.uls.interface.js - About 1 hr to fix

        Function render has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                render: function () {
                    var $section,
                        $quicklist = this.buildQuicklist(),
                        regions = [],
                        regionNames = {
        Severity: Minor
        Found in lib/jquery.uls/src/jquery.uls.lcd.js - About 1 hr to fix

          Function transliterate has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  transliterate: function ( input, context, altGr ) {
                      var patterns, regex, contextRegex, rule, replacement, i, retval;
          
                      if ( altGr ) {
                          patterns = this.inputmethod.patterns_x || [];
          Severity: Minor
          Found in lib/jquery.ime/jquery.ime.js - About 1 hr to fix

            Function keydown has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    keydown: function ( e ) {
                        var ime = $( e.target ).data( 'ime' ),
                            firstInputmethod,
                            previousInputMethods,
                            languageCode;
            Severity: Minor
            Found in lib/jquery.ime/jquery.ime.js - About 1 hr to fix

              Function getFontInfo has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getFontInfo( $font, $fontpath ) {
                      $info = [];
                      $fontdir = basename( $fontpath );
              
                      if ( isset( $font['fontweight'] ) ) {
              Severity: Minor
              Found in includes/FontRepoCompiler.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 onUserGetLanguageObject has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function onUserGetLanguageObject( $user, &$code, $context ) {
                      if ( $this->config->get( 'ULSLanguageDetection' ) ) {
                          // Vary any caching based on the header value. Note that
                          // we need to vary regardless of whether we end up using
                          // the header or not, so that requests without the header
              Severity: Minor
              Found in includes/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 buildQuicklist has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      buildQuicklist: function () {
                          var quickList, $quickListSection, $quickListSectionTitle;
              
                          if ( this.$cachedQuicklist !== null ) {
                              return this.$cachedQuicklist;
              Severity: Minor
              Found in lib/jquery.uls/src/jquery.uls.lcd.js - About 1 hr to fix

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

                    function loadContentLanguageSelector( ev ) {
                        var $target = $( ev.currentTarget );
                
                        // Avoid reinitializing ULS multiple times for an element
                        if ( $target.attr( 'data-uls-loaded' ) ) {
                Severity: Minor
                Found in resources/js/ext.uls.interface.js - About 1 hr to fix

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

                          prepareInputMethods: function ( languageCode ) {
                              var language = $.ime.languages[ languageCode ],
                                  $imeList = this.$menu.find( '.ime-list' ),
                                  imeSelector = this;
                  
                  
                  Severity: Minor
                  Found in lib/jquery.ime/jquery.ime.js - About 1 hr to fix

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

                        function addLanguageSettingsToNonContentPages() {
                            var $languageBtn = $( '#p-lang-btn' );
                            var clickHandler = function ( event ) {
                                event.stopPropagation();
                                mw.loader.using( languageSettingsModules ).then( function () {
                    Severity: Minor
                    Found in resources/js/ext.uls.interface.js - About 1 hr to fix

                      Method getFontInfo has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getFontInfo( $font, $fontpath ) {
                              $info = [];
                              $fontdir = basename( $fontpath );
                      
                              if ( isset( $font['fontweight'] ) ) {
                      Severity: Minor
                      Found in includes/FontRepoCompiler.php - About 1 hr to fix

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

                                function comparePoints(nodeA, offsetA, nodeB, offsetB) {
                                    // See http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html#Level-2-Range-Comparing
                                    var nodeC, root, childA, childB, n;
                                    if (nodeA == nodeB) {
                                        // Case 1: nodes are the same
                        Severity: Minor
                        Found in lib/rangy/rangy-core.js - About 1 hr to fix

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

                              $.ime.load = function ( inputmethodId ) {
                                  var dependency,
                                      deferred = $.Deferred();
                          
                                  if ( $.ime.inputmethods[ inputmethodId ] ) {
                          Severity: Minor
                          Found in lib/jquery.ime/jquery.ime.js - About 1 hr to fix

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

                                public function execute() {
                                    $request = $this->getRequest();
                                    if ( !$request->wasPosted() ) {
                                        $this->dieWithError( [ 'apierror-mustbeposted', $request->getText( 'action' ) ] );
                                    }
                            Severity: Minor
                            Found in includes/Api/ApiULSSetLanguage.php - 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

                                Method getCodepoint has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public static function getCodepoint( $str ) {
                                        $values = [];
                                        $lookingFor = 1;
                                        $strLen = strlen( $str );
                                        $number = 0;
                                Severity: Minor
                                Found in data/LanguageNameSearch.php - About 1 hr to fix

                                  Method onUserGetLanguageObject has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function onUserGetLanguageObject( $user, &$code, $context ) {
                                          if ( $this->config->get( 'ULSLanguageDetection' ) ) {
                                              // Vary any caching based on the header value. Note that
                                              // we need to vary regardless of whether we end up using
                                              // the header or not, so that requests without the header
                                  Severity: Minor
                                  Found in includes/Hooks.php - About 1 hr to fix

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

                                                moveToBookmark: function(bookmark) {
                                                    var containerNode = bookmark.containerNode;
                                                    var charIndex = 0;
                                                    this.setStart(containerNode, 0);
                                                    this.collapse(true);
                                    Severity: Minor
                                    Found in lib/rangy/rangy-core.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language