Showing 108 of 274 total issues
Function launchULS
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
Open
function launchULS( $trigger, languagesObject, forCLS ) {
var ulsConfig = {
/**
* Language selection handler
*
- Read upRead up
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
Open
prepareMoreLanguages: function () {
var $languages, $moreLanguagesButton,
displaySettings = this;
$languages = this.$template.find( 'div.uls-ui-languages' );
Function initInterlanguageEntryPoint
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function initInterlanguageEntryPoint() {
var $pLang = $( '#p-lang' );
var $trigger = $( '<button>' )
.addClass( 'uls-settings-trigger' )
Function renderInputmethodOption
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderInputmethodOption: function ( imeId, selected ) {
var $imeLabel, name, description, $helplink, inputmethod, $inputMethodItem;
if ( imeId !== 'system' && !$.ime.sources[ imeId ] ) {
// imeId not known for jquery.ime.
Function init
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function init() {
if (!isBrowser || api.initialized) {
return;
}
var testRange;
Function renderRegion
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderRegion: function ( $region, languages, itemsPerColumn, columnsPerRow ) {
var columnsClasses, i, lastItem, currentScript, nextScript, force,
languagesCount = languages.length,
items = [],
columns = [],
Method search
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function search( $searchKey, $typos = 0, $userLanguage = null ) {
$results = [];
$searchKey = mb_strtolower( $searchKey );
if ( mb_strlen( $searchKey ) > 100 ) {
Function addEmptyState
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function addEmptyState( uls ) {
var $emptyStateContainer = $( '<section>' ).addClass( 'uls-empty-state' );
function openActionsMenuEventHandler( event ) {
event.stopPropagation();
Function addIme
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
mw.ime.addIme = function ( $input ) {
var imeselector;
$input.ime( {
languages: mw.ime.getIMELanguageList(),
Function getCodepoint
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
public static function getCodepoint( $str ) {
$values = [];
$lookingFor = 1;
$strLen = strlen( $str );
$number = 0;
- Read upRead up
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 setLanguage
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
mw.uls.setLanguage = function ( language ) {
var api = new mw.Api();
function changeLanguageAnon() {
if ( mw.config.get( 'wgULSAnonCanChangeLanguage' ) ) {
Method onBeforePageDisplay
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function onBeforePageDisplay( $out, $skin ): void {
$unsupportedSkins = [ 'minerva', 'apioutput' ];
if ( in_array( $skin->getSkinName(), $unsupportedSkins, true ) ) {
return;
}
Function apply
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
apply: function () {
if ( !this.dirty ) {
// No changes to save in this module.
return;
}
Function clickHandler
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var clickHandler = function ( e ) {
var languagesettings = $trigger.data( 'languagesettings' ),
languageSettingsOptions;
if ( languagesettings ) {
Function keypress
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
keypress: function ( e ) {
var suggestion, query;
switch ( e.keyCode ) {
case 9: // Tab -> Autocomplete
Function setup
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
mw.webfonts.setup = function () {
// Initialize webfonts
var mediawikiFontRepository = $.webfonts.repository;
mediawikiFontRepository.base = mw.config.get( 'wgULSFontRepositoryBasePath' );
Function prepareFontSelector
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
prepareFontSelector: function ( target ) {
var language, fonts, $fontSelector, savedFont,
$systemFont, $fontLabel, $fontsSection;
// Get the language code from the right property -
Function replaceTextAtSelection
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ContentEditableEntry.prototype.replaceTextAtSelection = function (
precedingCharCount,
newText
) {
var textNode, textOffset, newOffset, newRange,
Function prepareLanguageList
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
prepareLanguageList: function () {
var languageCodeIndex,
$languageListWrapper,
$languageList,
languageList,
Function addRange
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
selProto.addRange = function(range, direction) {
if (implementsControlRange && implementsDocSelection && this.docSelection.type == CONTROL) {
addRangeToControlSelection(this, range);
} else {
if (isDirectionBackward(direction) && selectionHasExtend) {