Showing 108 of 274 total issues
Function initModule
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
initModule: function ( moduleName, active ) {
var $settingsTitle, $settingsText, $settingsLink,
languageSettings = this,
module = new $.fn.languagesettings.modules[ moduleName ]( languageSettings ),
$settingsMenuItems = languageSettings.$window.find( '.settings-menu-items' );
Function keypress
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
keypress: function ( e ) {
var altGr = false,
c, input, replacement;
if ( !this.active ) {
Function addActionsMenuTriggers
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function addActionsMenuTriggers( uls ) {
var $ulsSettingsBlock = addLanguageSettingsTrigger( uls );
var actionItemsRegistry = mw.uls.ActionsMenuItemsRegistry;
actionItemsRegistry.on( 'register', onActionItemAdded );
Function render
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render: function () {
var $section,
$quicklist = this.buildQuicklist(),
regions = [],
regionNames = {
Function transliterate
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
transliterate: function ( input, context, altGr ) {
var patterns, regex, contextRegex, rule, replacement, i, retval;
if ( altGr ) {
patterns = this.inputmethod.patterns_x || [];
Function keydown
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
keydown: function ( e ) {
var ime = $( e.target ).data( 'ime' ),
firstInputmethod,
previousInputMethods,
languageCode;
Function getFontInfo
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
public function getFontInfo( $font, $fontpath ) {
$info = [];
$fontdir = basename( $fontpath );
if ( isset( $font['fontweight'] ) ) {
- 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 onUserGetLanguageObject
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
public function onUserGetLanguageObject( $user, &$code, $context ) {
if ( $this->config->get( 'ULSLanguageDetection' ) ) {
// Vary any caching based on the header value. Note that
// we need to vary regardless of whether we end up using
// the header or not, so that requests without the header
- 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 buildQuicklist
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
buildQuicklist: function () {
var quickList, $quickListSection, $quickListSectionTitle;
if ( this.$cachedQuicklist !== null ) {
return this.$cachedQuicklist;
Function loadContentLanguageSelector
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function loadContentLanguageSelector( ev ) {
var $target = $( ev.currentTarget );
// Avoid reinitializing ULS multiple times for an element
if ( $target.attr( 'data-uls-loaded' ) ) {
Function prepareInputMethods
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
prepareInputMethods: function ( languageCode ) {
var language = $.ime.languages[ languageCode ],
$imeList = this.$menu.find( '.ime-list' ),
imeSelector = this;
Function addLanguageSettingsToNonContentPages
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function addLanguageSettingsToNonContentPages() {
var $languageBtn = $( '#p-lang-btn' );
var clickHandler = function ( event ) {
event.stopPropagation();
mw.loader.using( languageSettingsModules ).then( function () {
Method getFontInfo
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function getFontInfo( $font, $fontpath ) {
$info = [];
$fontdir = basename( $fontpath );
if ( isset( $font['fontweight'] ) ) {
Function comparePoints
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function comparePoints(nodeA, offsetA, nodeB, offsetB) {
// See http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html#Level-2-Range-Comparing
var nodeC, root, childA, childB, n;
if (nodeA == nodeB) {
// Case 1: nodes are the same
Function load
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
$.ime.load = function ( inputmethodId ) {
var dependency,
deferred = $.Deferred();
if ( $.ime.inputmethods[ inputmethodId ] ) {
Method execute
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function execute() {
$request = $this->getRequest();
if ( !$request->wasPosted() ) {
$this->dieWithError( [ 'apierror-mustbeposted', $request->getText( 'action' ) ] );
}
Function apply
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
apply: function () {
var previousIM,
inputSettings = this,
previousLanguage = inputSettings.savedRegistry.language,
currentlyEnabled = $.ime.preferences.isEnabled(),
Method getCodepoint
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function getCodepoint( $str ) {
$values = [];
$lookingFor = 1;
$strLen = strlen( $str );
$number = 0;
Method onUserGetLanguageObject
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function onUserGetLanguageObject( $user, &$code, $context ) {
if ( $this->config->get( 'ULSLanguageDetection' ) ) {
// Vary any caching based on the header value. Note that
// we need to vary regardless of whether we end up using
// the header or not, so that requests without the header
Function moveToBookmark
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
moveToBookmark: function(bookmark) {
var containerNode = bookmark.containerNode;
var charIndex = 0;
this.setStart(containerNode, 0);
this.collapse(true);