wikimedia/mediawiki-extensions-UniversalLanguageSelector

View on GitHub

Showing 269 of 269 total issues

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

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

        function getIframeDocument(iframeEl) {
            if (typeof iframeEl.contentDocument != UNDEF) {
                return iframeEl.contentDocument;
            } else if (typeof iframeEl.contentWindow != UNDEF) {
                return iframeEl.contentWindow.document;
Severity: Major
Found in lib/rangy/rangy-core.js and 1 other location - About 1 hr to fix
lib/rangy/rangy-core.js on lines 676..684

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

        function getIframeWindow(iframeEl) {
            if (typeof iframeEl.contentWindow != UNDEF) {
                return iframeEl.contentWindow;
            } else if (typeof iframeEl.contentDocument != UNDEF) {
                return iframeEl.contentDocument.defaultView;
Severity: Major
Found in lib/rangy/rangy-core.js and 1 other location - About 1 hr to fix
lib/rangy/rangy-core.js on lines 666..674

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

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

Function renderInputmethodOption has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        renderInputmethodOption: function ( imeId, selected ) {
            var $imeLabel, name, description, $helplink, inputmethod, $inputMethodItem;

            if ( imeId !== 'system' && !$.ime.sources[ imeId ] ) {
                // imeId not known for jquery.ime.
Severity: Minor
Found in resources/js/ext.uls.inputsettings.js - About 1 hr to fix

    Function init has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function init() {
            if (!isBrowser || api.initialized) {
                return;
            }
            var testRange;
    Severity: Minor
    Found in lib/rangy/rangy-core.js - About 1 hr to fix

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

              cancel: function ( e ) {
                  if ( e && ( this.$element.is( e.target ) ||
                      $.contains( this.$element[ 0 ], e.target ) ) ) {
                      return;
                  }
      Severity: Major
      Found in lib/jquery.uls/src/jquery.uls.core.js and 1 other location - About 1 hr to fix
      resources/js/ext.uls.actions.menu.js on lines 88..95

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

      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

              cancel: function ( e ) {
                  if ( e && ( this.$template.is( e.target ) ||
                          $.contains( this.$template[ 0 ], e.target ) ) ) {
                      return;
                  }
      Severity: Major
      Found in resources/js/ext.uls.actions.menu.js and 1 other location - About 1 hr to fix
      lib/jquery.uls/src/jquery.uls.core.js on lines 315..322

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

      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

      Method search has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function search( $searchKey, $typos = 0, $userLanguage = null ) {
              $results = [];
              $searchKey = mb_strtolower( $searchKey );
      
              if ( mb_strlen( $searchKey ) > 100 ) {
      Severity: Minor
      Found in data/LanguageNameSearch.php - About 1 hr to fix

        Function renderRegion has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                renderRegion: function ( $region, languages, itemsPerColumn, columnsPerRow ) {
                    var columnsClasses, i, lastItem, currentScript, nextScript, force,
                        languagesCount = languages.length,
                        items = [],
                        columns = [],
        Severity: Minor
        Found in lib/jquery.uls/src/jquery.uls.lcd.js - About 1 hr to fix

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

                  patterns_x: [
                      [ '1', '\u200d' ],
                      [ '2', '\u200c' ],
                      [ '4', '₹' ],
                      [ '\\+', 'ॠ' ],
          Severity: Major
          Found in lib/jquery.ime/rules/ne/ne-inscript2.js and 2 other locations - About 1 hr to fix
          lib/jquery.ime/rules/mh/mh.js on lines 21..39
          lib/jquery.ime/rules/ta/ta-inscript2.js on lines 86..103

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

          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 3 locations. Consider refactoring.
          Open

                  patterns: [
                      [ 'Y', 'Ū' ],
                      [ 'S', 'Ā' ],
                      [ 'F', 'Ņ' ],
                      [ 'G', 'N̄' ],
          Severity: Major
          Found in lib/jquery.ime/rules/mh/mh.js and 2 other locations - About 1 hr to fix
          lib/jquery.ime/rules/ne/ne-inscript2.js on lines 96..112
          lib/jquery.ime/rules/ta/ta-inscript2.js on lines 86..103

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

          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 3 locations. Consider refactoring.
          Open

                  patterns_x: [
                      [ '1', '\u200d' ],
                      [ '2', '\u200c' ],
                      [ '4', '₹' ],
                      [ '0', '௰' ],
          Severity: Major
          Found in lib/jquery.ime/rules/ta/ta-inscript2.js and 2 other locations - About 1 hr to fix
          lib/jquery.ime/rules/mh/mh.js on lines 21..39
          lib/jquery.ime/rules/ne/ne-inscript2.js on lines 96..112

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

          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 addEmptyState has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function addEmptyState( uls ) {
                  var $emptyStateContainer = $( '<section>' ).addClass( 'uls-empty-state' );
          
                  function openActionsMenuEventHandler( event ) {
                      event.stopPropagation();
          Severity: Minor
          Found in resources/js/ext.uls.interface.js - About 1 hr to fix

            Function addIme has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                mw.ime.addIme = function ( $input ) {
                    var imeselector;
            
                    $input.ime( {
                        languages: mw.ime.getIMELanguageList(),
            Severity: Minor
            Found in resources/js/ext.uls.ime.js - About 1 hr to fix

              Function getCodepoint has a Cognitive Complexity of 13 (exceeds 5 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

              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

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

                      patterns_x: [
                          [ '1', '\u200d' ],
                          [ '2', '\u200c' ],
                          [ '4', '₹' ],
                          [ '\\+', 'ୠ' ],
              Severity: Major
              Found in lib/jquery.ime/rules/or/or-inscript2.js and 2 other locations - About 1 hr to fix
              lib/jquery.ime/rules/gom/gom-inscript2.js on lines 99..115
              lib/jquery.ime/rules/mr/mr-inscript2.js on lines 101..117

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

              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 3 locations. Consider refactoring.
              Open

                      patterns_x: [
                          [ '1', '\u200d' ],
                          [ '2', '\u200c' ],
                          [ '4', '₹' ],
                          [ '\\+', 'ॠ' ],
              Severity: Major
              Found in lib/jquery.ime/rules/gom/gom-inscript2.js and 2 other locations - About 1 hr to fix
              lib/jquery.ime/rules/mr/mr-inscript2.js on lines 101..117
              lib/jquery.ime/rules/or/or-inscript2.js on lines 97..112

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

              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 3 locations. Consider refactoring.
              Open

                      patterns_x: [
                          [ '1', '\u200d' ],
                          [ '2', '\u200c' ],
                          [ '4', '₹' ],
                          [ '\\+', 'ॠ' ],
              Severity: Major
              Found in lib/jquery.ime/rules/mr/mr-inscript2.js and 2 other locations - About 1 hr to fix
              lib/jquery.ime/rules/gom/gom-inscript2.js on lines 99..115
              lib/jquery.ime/rules/or/or-inscript2.js on lines 97..112

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

              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 setLanguage has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  mw.uls.setLanguage = function ( language ) {
                      var api = new mw.Api();
              
                      function changeLanguageAnon() {
                          if ( mw.config.get( 'wgULSAnonCanChangeLanguage' ) ) {
              Severity: Minor
              Found in resources/js/ext.uls.common.js - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language