Showing 436 of 912 total issues
Function parseMetadata
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.init.mw.ArticleTarget.prototype.parseMetadata = function ( response ) {
const data = response ? ( response.visualeditor || response.visualeditoredit ) : null;
if ( !data ) {
this.loadFail( 've-api', { errors: [ {
Function VeInitMwArticleTarget
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.init.mw.ArticleTarget = function VeInitMwArticleTarget( config ) {
config = config || {};
config.toolbarConfig = ve.extendObject( {
shadow: true,
actions: true,
Function queryCategoryStatus
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWCategoryWidget.prototype.queryCategoryStatus = function ( categoryNames ) {
// Get rid of any we already know the hidden status of, or have an entry
// if normalizedTitles (i.e. have been fetched before)
const categoryNamesToQuery = categoryNames.filter( ( name ) => {
if ( this.normalizedTitles[ name ] ) {
Function create
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
ve.ui.MWWikitextDataTransferHandlerFactory.prototype.create = function () {
// Parent method
const handler = ve.ui.MWWikitextDataTransferHandlerFactory.super.prototype.create.apply( this, arguments ),
resolve = handler.resolve.bind( 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 build
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
ve.ui.MWTocWidget.prototype.build = function () {
const $newTocList = $( '<ul>' ),
nodes = this.doc.getNodesByType( 'mwHeading', true ),
surfaceView = this.surface.getView(),
documentView = surfaceView.getDocument(),
- 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 addExactMatch
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
ve.ui.MWTemplateTitleInputWidget.prototype.addExactMatch = function ( response ) {
const query = this.getQueryValue(),
title = mw.Title.newFromText( query, this.namespace );
// No point in trying anything when the title is invalid
if ( !title ) {
- 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 save
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.init.mw.ArticleTarget.prototype.save = function ( doc, options ) {
// Prevent duplicate requests
if ( this.saving ) {
return this.saving;
}
Function onAttributeChange
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ce.MWBlockImageNode.prototype.onAttributeChange = function ( key, from, to ) {
// Mixin method
ve.ce.MWImageNode.prototype.onAttributeChange.apply( this, arguments );
if ( key === 'height' || key === 'width' ) {
Function generateBody
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWInternalLinkContextItem.static.generateBody = function ( linkCache, model, htmlDoc, context ) {
const lookupTitle = model.getAttribute( 'lookupTitle' ),
normalizedTitle = model.getAttribute( 'normalizedTitle' ),
href = model.getHref(),
title = mw.Title.newFromText( mw.libs.ve.normalizeParsoidResourceName( href ) ),
Function createCheckboxFields
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
createCheckboxFields: function ( checkboxesDef, widgetConfig ) {
const checkboxFields = [],
checkboxesByName = {};
if ( checkboxesDef ) {
Function requestPageData
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
requestPageData: function ( mode, pageName, options ) {
options = options || {};
const apiRequest = mode === 'source' ?
this.requestWikitext.bind( this, pageName, options ) :
this.requestParsoidData.bind( this, pageName, options );
Function getTarget
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getTarget( mode, section ) {
if ( !targetPromise ) {
// The TargetLoader module is loaded in the bottom queue, so it should have been
// requested already but it might not have finished loading yet
targetPromise = mw.loader.using( 'ext.visualEditor.targetLoader' )
Function confirmSelectedImage
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWMediaDialog.prototype.confirmSelectedImage = function () {
const obj = {},
info = this.selectedImageInfo;
if ( info ) {
Function restorePage
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.init.mw.DesktopArticleTarget.prototype.restorePage = function () {
// Restore any previous redirectMsg/redirectsub
this.setRealRedirectInterface();
if ( this.$originalCategories ) {
$( '#catlinks' ).replaceWith( this.$originalCategories );
Function VeUiMWCategoriesPage
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWCategoriesPage = function VeUiMWCategoriesPage( name, config ) {
// Configuration initialization
config = config || {};
// Parent constructor
Function addItems
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWCategoryWidget.prototype.addItems = function ( items, index ) {
const categoryItems = [],
// eslint-disable-next-line no-jquery/no-map-util
categoryNames = $.map( items, ( item ) => item.name );
Function getTargetDataFromHref
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
mw.libs.ve.getTargetDataFromHref = function ( href, doc ) {
function regexEscape( str ) {
return str.replace( /([.?*+^$[\]\\(){}|-])/g, '\\$1' );
}
Function onReplacePart
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWTemplateDialog.prototype.onReplacePart = function ( removed, added ) {
const removePages = [];
if ( removed ) {
// Remove parameter pages of removed templates
Function insertTransclusionNode
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.dm.MWTransclusionModel.prototype.insertTransclusionNode = function ( surfaceFragment, forceType ) {
const deferred = ve.createDeferred(),
baseNodeClass = ve.dm.MWTransclusionNode;
const insertNode = ( isInline, generatedContents ) => {
Function VeUiMWTemplatePlaceholderPage
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWTemplatePlaceholderPage = function VeUiMWTemplatePlaceholderPage( placeholder, name, config ) {
// Configuration initialization
config = ve.extendObject( {
scrollable: false
}, config );