wikimedia/mediawiki-extensions-UniversalLanguageSelector

View on GitHub

Showing 108 of 274 total issues

Function execute has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        // Avoid local configuration leaking to this script
        if ( $this->getConfig()->get( MainConfigNames::ExtraLanguageNames ) !== [] ) {
            $this->fatalError( 'You have entries in $wgExtraLanguageNames. Needs to be empty for this script.' );
        }
Severity: Minor
Found in data/LanguageNameIndexer.php - About 3 hrs 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 launchULS has 94 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function launchULS( $trigger, languagesObject, forCLS ) {
    var ulsConfig = {
        /**
         * Language selection handler
         *
Severity: Major
Found in resources/js/ext.uls.launch.js - About 3 hrs to fix

    Function normalizeBoundaries has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                    normalizeBoundaries: function() {
                        assertRangeValid(this);
    
                        var sc = this.startContainer, so = this.startOffset, ec = this.endContainer, eo = this.endOffset;
    
    
    Severity: Major
    Found in lib/rangy/rangy-core.js - About 3 hrs to fix

      File jquery.uls.core.js has 310 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
       * Universal Language Selector
       * ULS core component.
       *
       * Copyright (C) 2012 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
      Severity: Minor
      Found in lib/jquery.uls/src/jquery.uls.core.js - About 3 hrs to fix

        Function getTextRangeBoundaryPosition has 83 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    var getTextRangeBoundaryPosition = function(textRange, wholeRangeContainerElement, isStart, isCollapsed, startInfo) {
                        var workingRange = textRange.duplicate();
                        workingRange.collapse(isStart);
                        var containerElement = workingRange.parentElement();
        
        
        Severity: Major
        Found in lib/rangy/rangy-core.js - About 3 hrs to fix

          File vai-transliteration.js has 298 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          ( function ( $ ) {
              'use strict';
          
              var vaiTransliteration = {
                  id: 'vai-transliteration',
          Severity: Minor
          Found in lib/jquery.ime/rules/vai/vai-transliteration.js - About 3 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

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

              /**
               * jQuery Webfonts.
               *
               * Copyright (C) 2012 Santhosh Thottingal
               *
              Severity: Minor
              Found in lib/jquery.webfonts/src/jquery.webfonts.js - About 3 hrs to fix

                Function initPersonalEntryPoint has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function initPersonalEntryPoint() {
                        var $trigger = $( '.uls-trigger' );
                        var clickHandler;
                
                        if ( !userCanChangeLanguage() ) {
                Severity: Major
                Found in resources/js/ext.uls.interface.js - About 2 hrs to fix

                  Function showUndoTooltip has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function showUndoTooltip( previousLang, previousAutonym ) {
                          var trigger, popup, popupPosition,
                              configPosition = mw.config.get( 'wgULSPosition' ),
                              triggerSelector = ( configPosition === 'interlanguage' ) ?
                                  '.uls-settings-trigger, .mw-interlanguage-selector' :
                  Severity: Major
                  Found in resources/js/ext.uls.interface.js - About 2 hrs 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

                      File bo-ewts.js has 273 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      ( function ( $ ) {
                          'use strict';
                      
                          var boEWTS = {
                              id: 'bo-ewts',
                      Severity: Minor
                      Found in lib/jquery.ime/rules/bo/bo-ewts.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 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 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 parse has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                        parse: function() {
                                            var webfonts = this,
                                                // Fonts can be added indirectly via classes, but also with
                                                // style attributes. For lang attributes we will use our font
                                                // if they don't have explicit font already.
                                Severity: Major
                                Found in lib/jquery.webfonts/src/jquery.webfonts.js - About 2 hrs to fix

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

                                          getCSS: function( fontFamily, variant ) {
                                              var webfonts, base,
                                                  fontFaceRule, userAgent, fontStyle, fontFormats, fullFontName,
                                                  fontconfig = this.repository.get( fontFamily );
                                  
                                  
                                  Severity: Major
                                  Found in lib/jquery.webfonts/src/jquery.webfonts.js - About 2 hrs to fix

                                    Function execute has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function execute() {
                                            $base = dirname( __DIR__ );
                                    
                                            $relpath = '../data/fontrepo/fonts';
                                            $compiler = new FontRepoCompiler( "$base/data/fontrepo/fonts", $relpath );
                                    Severity: Minor
                                    Found in scripts/generate-font-test-page.php - About 2 hrs 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

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

                                        public function execute() {
                                            $base = dirname( __DIR__ );
                                    
                                            $relpath = '../data/fontrepo/fonts';
                                            $compiler = new FontRepoCompiler( "$base/data/fontrepo/fonts", $relpath );
                                    Severity: Major
                                    Found in scripts/generate-font-test-page.php - About 2 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language