wikimedia/mediawiki-extensions-UniversalLanguageSelector

View on GitHub

Showing 108 of 269 total issues

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

        autofill: function ( langCode, languageName ) {
            var autonym, userInput, suggestion;

            if ( !this.$suggestion.length ) {
                return;
Severity: Minor
Found in lib/jquery.uls/src/jquery.uls.languagefilter.js - 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

      Method levenshteinDistance has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function levenshteinDistance( $str1, $str2 ) {
              if ( $str1 === $str2 ) {
                  return 0;
              }
              $length1 = mb_strlen( $str1, 'UTF-8' );
      Severity: Minor
      Found in data/LanguageNameSearch.php - About 1 hr to fix

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

                append: function ( langCode, regionCode ) {
                    var i, regions;
        
                    if ( !$.uls.data.languages[ langCode ] ) {
                        // Language is unknown or not in the list of languages for this context.
        Severity: Minor
        Found in lib/jquery.uls/src/jquery.uls.lcd.js - About 1 hr to fix

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

                  prepareInputmethods: function ( language ) {
                      var index, inputSettings, $imeListContainer, defaultInputmethod,
                          imes, selected, imeId, $imeListTitle;
          
                      imes = $.ime.languages[ language ];
          Severity: Minor
          Found in resources/js/ext.uls.inputsettings.js - About 1 hr to fix

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

                        var createBoundaryTextRange = function(boundaryPosition, isStart) {
                            var boundaryNode, boundaryParent, boundaryOffset = boundaryPosition.offset;
                            var doc = dom.getDocument(boundaryPosition.node);
                            var workingNode, childNodes, workingRange = getBody(doc).createTextRange();
                            var nodeIsDataNode = isCharacterDataNode(boundaryPosition.node);
            Severity: Minor
            Found in lib/rangy/rangy-core.js - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                              if (comparison == -1 && boundaryNode && isCharacterDataNode(boundaryNode)) {
                                  // This is a character data node (text, comment, cdata). The working range is collapsed at the start of
                                  // the node containing the text range's boundary, so we move the end of the working range to the
                                  // boundary point and measure the length of its text to get the boundary's offset within the node.
                                  workingRange.setEndPoint(isStart ? "EndToStart" : "EndToEnd", textRange);
              Severity: Major
              Found in lib/rangy/rangy-core.js - About 1 hr to fix

                Function onBeforePageDisplay has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function onBeforePageDisplay( $out, $skin ): void {
                        $unsupportedSkins = [ 'minerva', 'apioutput' ];
                        if ( in_array( $skin->getSkinName(), $unsupportedSkins, true ) ) {
                            return;
                        }
                Severity: Minor
                Found in includes/Hooks.php - About 55 mins 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 appendLanguages has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function appendLanguages( &$languages, $fontLanguages, $fontname ) {
                        foreach ( $fontLanguages as $rcode ) {
                            $code = str_replace( '*', '', $rcode );
                
                            if ( !isset( $languages[$code] ) ) {
                Severity: Minor
                Found in includes/FontRepoCompiler.php - About 55 mins 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

                Avoid deeply nested control flow statements.
                Open

                                        for (var i = 0, len = sel.rangeCount; i < len; ++i) {
                                            sel._ranges[i] = new api.WrappedRange(sel.nativeSelection.getRangeAt(i));
                                        }
                Severity: Major
                Found in lib/rangy/rangy-core.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              if (selectionSupportsMultipleRanges) {
                                                  previousRangeCount = this.rangeCount;
                                              } else {
                                                  this.removeAllRanges();
                                                  previousRangeCount = 0;
                  Severity: Major
                  Found in lib/rangy/rangy-core.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                        if (ec == sibling) {
                                                            ec = sc;
                                                            eo += sc.length;
                                                        }
                    Severity: Major
                    Found in lib/rangy/rangy-core.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  if (addRangeBackwardToNative) {
                                                      addRangeBackwardToNative(sel, originalSelectionRanges[i]);
                                                  } else {
                                                      api.warn("Rangy initialization: original selection was backwards but selection has been restored forwards because the browser does not support Selection.extend");
                                                      sel.addRange(originalSelectionRanges[i]);
                      Severity: Major
                      Found in lib/rangy/rangy-core.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                    if (controlRange.length) {
                                                        doc = getDocument( controlRange.item(0) );
                                                    }
                        Severity: Major
                        Found in lib/rangy/rangy-core.js - About 45 mins to fix

                          Function onSkinAfterPortlet has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function onSkinAfterPortlet( $skin, $name, &$content ) {
                                  if ( $name !== 'lang' ) {
                                      return;
                                  }
                          
                          
                          Severity: Minor
                          Found in includes/Hooks.php - About 45 mins 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

                          Avoid deeply nested control flow statements.
                          Open

                                                      if (this.rangeCount == previousRangeCount + 1) {
                                                          // The range was added successfully
                          
                                                          // Check whether the range that we added to the selection is reflected in the last range extracted from
                                                          // the selection
                          Severity: Major
                          Found in lib/rangy/rangy-core.js - About 45 mins 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

                              Function updateNativeRange has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                              function updateNativeRange(range, startContainer, startOffset, endContainer, endOffset) {
                              Severity: Minor
                              Found in lib/rangy/rangy-core.js - About 35 mins to fix

                                Function getTextRangeBoundaryPosition has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                            var getTextRangeBoundaryPosition = function(textRange, wholeRangeContainerElement, isStart, isCollapsed, startInfo) {
                                Severity: Minor
                                Found in lib/rangy/rangy-core.js - About 35 mins to fix

                                  Function updateBoundaries has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                          function updateBoundaries(range, startContainer, startOffset, endContainer, endOffset) {
                                  Severity: Minor
                                  Found in lib/rangy/rangy-core.js - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language