Function addPartWidget
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
ve.ui.MWTransclusionOutlineWidget.prototype.addPartWidget = function ( part, newPosition, removed ) {
const keys = Object.keys( this.partWidgets ),
onlyPart = keys.length === 1 && this.partWidgets[ keys[ 0 ] ];
if ( onlyPart instanceof ve.ui.MWTransclusionOutlineTemplateWidget ) {
// To recalculate the height of the sticky header when we enter multi-part mode
Function setSelectionByPageName
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
ve.ui.MWTransclusionOutlineWidget.prototype.setSelectionByPageName = function ( pageName ) {
const selectedPartId = pageName ? pageName.split( '/', 1 )[ 0 ] : null,
isParameter = pageName ? pageName.length > selectedPartId.length : false;
for ( const partId in this.partWidgets ) {
- 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 addPartWidget
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
ve.ui.MWTransclusionOutlineWidget.prototype.addPartWidget = function ( part, newPosition, removed ) {
const keys = Object.keys( this.partWidgets ),
onlyPart = keys.length === 1 && this.partWidgets[ keys[ 0 ] ];
if ( onlyPart instanceof ve.ui.MWTransclusionOutlineTemplateWidget ) {
// To recalculate the height of the sticky header when we enter multi-part mode
- 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 findPartIdContainingElement
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
ve.ui.MWTransclusionOutlineWidget.prototype.findPartIdContainingElement = function ( element ) {
if ( element ) {
for ( const id in this.partWidgets ) {
const part = this.partWidgets[ id ];
if ( $.contains( part.$element[ 0 ], element ) ) {
- 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"