wikimedia/mediawiki-extensions-UniversalLanguageSelector

View on GitHub
lib/jquery.ime/jquery.ime.js

Summary

Maintainability
F
1 wk
Test Coverage

File jquery.ime.js has 2605 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*! jquery.ime - v0.2.0+20240513
* https://github.com/wikimedia/jquery.ime
* Copyright (c) 2024 Santhosh Thottingal; License: (GPL-2.0-or-later OR MIT) */
( function ( $ ) {
    'use strict';
Severity: Major
Found in lib/jquery.ime/jquery.ime.js - About 1 wk to fix

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

            listen: function () {
                var imeselector = this;
    
                imeselector.$imeSetting.on( 'click.ime', function ( e ) {
                    var $t = $( e.target );
    Severity: Major
    Found in lib/jquery.ime/jquery.ime.js - About 2 hrs to fix

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

              position: function () {
                  var menuWidth, menuTop, menuLeft, elementPosition,
                      top, left, cssTop, cssLeft, verticalRoom, overflowsOnRight,
                      imeSelector = this,
                      rtlElement = this.$element.css( 'direction' ) === 'rtl',
      Severity: Major
      Found in lib/jquery.ime/jquery.ime.js - About 2 hrs to fix

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

                prepareLanguageList: function () {
                    var languageCodeIndex,
                        $languageListWrapper,
                        $languageList,
                        languageList,
        Severity: Minor
        Found in lib/jquery.ime/jquery.ime.js - About 1 hr to fix

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

              ContentEditableEntry.prototype.replaceTextAtSelection = function (
                  precedingCharCount,
                  newText
              ) {
                  var textNode, textOffset, newOffset, newRange,
          Severity: Minor
          Found in lib/jquery.ime/jquery.ime.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 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 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 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 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

                      Avoid deeply nested control flow statements.
                      Open

                                                  if ( previousInputMethods[ 0 ] ) {
                                                      this.selectIM( previousInputMethods[ 0 ] );
                                                  } else {
                                                      // Provide the default input method in this case.
                                                      firstInputmethod =
                      Severity: Major
                      Found in lib/jquery.ime/jquery.ime.js - About 45 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return false;
                        Severity: Major
                        Found in lib/jquery.ime/jquery.ime.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return { noop: true, output: input };
                          Severity: Major
                          Found in lib/jquery.ime/jquery.ime.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                            return true;
                            Severity: Major
                            Found in lib/jquery.ime/jquery.ime.js - About 30 mins to fix

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

                                          if ( inputMethod !== 'system' ) {
                                              this.registry.previousInputMethods.unshift( inputMethod );
                                              this.registry.previousInputMethods =
                                                  this.registry.previousInputMethods.slice( 0, 5 );
                                          }
                              Severity: Major
                              Found in lib/jquery.ime/jquery.ime.js and 1 other location - About 1 hr to fix
                              lib/jquery.ime/jquery.ime.js on lines 1573..1576

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

                              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

                                          if ( this.registry.previousLanguages.indexOf( language ) === -1 ) {
                                              this.registry.previousLanguages.unshift( language );
                                              this.registry.previousLanguages = this.registry.previousLanguages.slice( 0, 5 );
                                          }
                              Severity: Major
                              Found in lib/jquery.ime/jquery.ime.js and 1 other location - About 1 hr to fix
                              lib/jquery.ime/jquery.ime.js on lines 1613..1617

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

                              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