Showing 436 of 912 total issues
Function onRequestImagesSuccess
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWGalleryDialog.prototype.onRequestImagesSuccess = function ( response ) {
const thumbUrls = {},
items = [],
config = { isMobile: this.isMobile, draggable: !this.isReadOnly() };
Function getHtml
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
getHtml: function ( newDoc, oldDoc ) {
function copyAttributes( from, to ) {
Array.prototype.forEach.call( from.attributes, ( attr ) => {
to.setAttribute( attr.name, attr.value );
} );
Method parseWikitext
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function parseWikitext( $newRevId, array $params ) {
$apiParams = [
'action' => 'parse',
'oldid' => $newRevId,
'prop' => 'text|revid|categorieshtml|sections|displaytitle|subtitle|modules|jsconfigvars',
Function describeChanges
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.dm.MWTransclusionNode.static.describeChanges = function ( attributeChanges ) {
const descriptions = [ ve.msg( 'visualeditor-changedesc-mwtransclusion' ) ];
// This method assumes that the behavior of isDiffComparable above remains
// the same, so it doesn't have to consider whether the actual template
Function generateContents
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ce.MWSignatureNode.prototype.generateContents = function () {
const doc = this.getModel().getDocument();
let abortable, aborted;
const abortedPromise = ve.createDeferred().reject( 'http',
{ textStatus: 'abort', exception: 'abort' } ).promise();
Function initialize
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.EditCheckInspector.prototype.initialize = function () {
// Parent method
ve.ui.EditCheckInspector.super.prototype.initialize.call( this );
// Survey panel
Function act
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
mw.editcheck.AddReferenceEditCheck.prototype.act = function ( choice, action, contextItem ) {
// The complex citoid workflow means that we can't just count on a single "windowAction" here...
const windowAction = ve.ui.actionFactory.create( 'window', contextItem.context.getSurface(), 'check' );
switch ( choice ) {
case 'accept':
Function isSaveable
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
ve.ui.MWGalleryDialog.prototype.isSaveable = function () {
// Check attributes
if ( this.originalMwDataNormalized ) {
const mwDataCopy = ve.copy( this.selectedNode.getAttribute( 'mw' ) );
this.updateMwData( mwDataCopy );
- 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 wrapText
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
ve.dm.MWWikitextSurfaceFragment.prototype.wrapText = function ( before, after, placeholder, forceWrap ) {
placeholder = OO.ui.resolveMsg( placeholder );
function unwrap( fragment ) {
const text = fragment.getText();
- 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
Method __construct
has 14 arguments (exceeds 4 allowed). Consider refactoring. Open
ApiMain $main,
string $name,
RevisionLookup $revisionLookup,
TempUserCreator $tempUserCreator,
UserFactory $userFactory,
Function syncScalableToType
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
ve.dm.MWImageNode.static.syncScalableToType = function ( type, mediaType, scalable ) {
const defaultThumbSize = mw.config.get( 'wgVisualEditorConfig' )
.thumbLimits[ mw.user.options.get( 'thumbsize' ) ];
const originalDimensions = scalable.getOriginalDimensions();
- 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 fetchSpecialCharList
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.init.mw.Platform.prototype.fetchSpecialCharList = function () {
return mw.loader.using( 'mediawiki.language.specialCharacters' ).then( () => {
const specialCharacterGroups = require( 'mediawiki.language.specialCharacters' ),
characters = {},
otherGroupName = mw.msg( 'visualeditor-special-characters-group-other' ),
Function resolveChangeQueue
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.dm.MWTransclusionModel.prototype.resolveChangeQueue = function ( queue ) {
const resolveQueue = [];
for ( let i = 0; i < queue.length; i++ ) {
const item = queue[ i ];
Function initialize
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWExportWikitextDialog.prototype.initialize = function () {
// Parent method
ve.ui.MWExportWikitextDialog.super.prototype.initialize.call( this );
this.titleInput = new mw.widgets.TitleInputWidget( {
Function getTeardownProcess
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWLinkNodeInspector.prototype.getTeardownProcess = function ( data ) {
data = data || {};
return ve.ui.MWLinkNodeInspector.super.prototype.getTeardownProcess.call( this, data )
.first( () => {
let value = this.targetInput.getValue();
Function VeInitMwDesktopArticleTarget
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.init.mw.DesktopArticleTarget = function VeInitMwDesktopArticleTarget( config ) {
// Parent constructor
ve.init.mw.DesktopArticleTarget.super.call( this, config );
// Parent constructor bound key event handlers, but we don't want them bound until
Function initialize
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWAddParameterPage.prototype.initialize = function () {
this.template
.connect( this, {
// There is a "change" event, but it triggers way to often even for content changes
add: 'onTemplateParametersChanged',
Function setDiffAndReview
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWSaveDialog.prototype.setDiffAndReview = function ( wikitextDiffPromise, visualDiffGeneratorPromise, baseDoc ) {
this.clearDiff();
function createDiffElement( visualDiff ) {
const diffElement = new ve.ui.DiffElement( visualDiff );
Function VeDmMWImageModel
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.dm.MWImageModel = function VeDmMWImageModel( parentDoc, config ) {
config = config || {};
// Mixin constructors
OO.EventEmitter.call( this );
Function initAutosave
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.init.mw.Target.prototype.initAutosave = function ( config ) {
// Old function signature
// TODO: Remove after fixed downstream
if ( typeof config === 'boolean' ) {
config = { suppressNotification: config };