wikimedia/mediawiki-extensions-UniversalLanguageSelector

View on GitHub

Showing 269 of 269 total issues

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

                    rangeProto.setStart = function(node, offset) {
                        try {
                            this.nativeRange.setStart(node, offset);
                        } catch (ex) {
                            this.nativeRange.setEnd(node, offset);
Severity: Major
Found in lib/rangy/rangy-core.js and 1 other location - About 2 hrs to fix
lib/rangy/rangy-core.js on lines 2327..2335

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

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

                    rangeProto.setEnd = function(node, offset) {
                        try {
                            this.nativeRange.setEnd(node, offset);
                        } catch (ex) {
                            this.nativeRange.setStart(node, offset);
Severity: Major
Found in lib/rangy/rangy-core.js and 1 other location - About 2 hrs to fix
lib/rangy/rangy-core.js on lines 2317..2325

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

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

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

                  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

                                  $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

                  Function launchULS has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function launchULS( $trigger, languagesObject, forCLS ) {
                      var ulsConfig = {
                          /**
                           * Language selection handler
                           *
                  Severity: Minor
                  Found in resources/js/ext.uls.launch.js - 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

                  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

                    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

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

                            patterns_x: [
                                [ '1', '\u200d' ],
                                [ '2', '\u200c' ],
                                [ '4', '₹' ],
                                [ 'i', 'ਗ਼' ],
                    Severity: Major
                    Found in lib/jquery.ime/rules/pa/pa-inscript2.js and 1 other location - About 1 hr to fix
                    lib/jquery.ime/rules/brx/brx-inscript2.js on lines 96..113

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

                    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

                            patterns_x: [
                                [ '1', '\u200d' ],
                                [ '2', '\u200c' ],
                                [ '4', '₹' ],
                                [ '\\+', 'ॠ' ],
                    Severity: Major
                    Found in lib/jquery.ime/rules/brx/brx-inscript2.js and 1 other location - About 1 hr to fix
                    lib/jquery.ime/rules/pa/pa-inscript2.js on lines 89..107

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

                    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

                    Function initInterlanguageEntryPoint has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function initInterlanguageEntryPoint() {
                            var $pLang = $( '#p-lang' );
                    
                            var $trigger = $( '<button>' )
                                .addClass( 'uls-settings-trigger' )
                    Severity: Minor
                    Found in resources/js/ext.uls.interface.js - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language