Function setupEditor
has 226 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setupEditor( page, skin, currentPageHTMLParser, router ) {
const
overlayManager = OverlayManager.getSingleton(),
isNewPage = page.id === 0;
File editor.js
has 357 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global $ */
const M = require( '../mobile.startup/moduleLoaderSingleton' ),
util = require( '../mobile.startup/util' ),
editorLoadingOverlay = require( './editorLoadingOverlay' ),
OverlayManager = require( '../mobile.startup/OverlayManager' ),
Function loadVisualEditorMaybe
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function loadVisualEditorMaybe() {
logInit( 'visualeditor' );
// Inform other interested code that we're loading the editor
/**
* Internal for use in GrowthExperiments only.
Function showLoading
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function showLoading() {
let $sectionTop, fakeScroll, enableVisualSectionEditing;
$( document.body ).addClass( 've-loading' );
Function getPreferredEditor
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function getPreferredEditor() {
if ( editorOverride ) {
// Temporary override, set via the URL for this request
// or by clicking the chosen mode when both tabs are shown
return editorOverride;
- 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 setupEditor
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function setupEditor( page, skin, currentPageHTMLParser, router ) {
const
overlayManager = OverlayManager.getSingleton(),
isNewPage = page.id === 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 onEditLinkClick
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function onEditLinkClick( elem, ev, router ) {
let section;
if ( $( EDITSECTION_SELECTOR ).length === 0 ) {
// If section edit links are not available, the only edit link
// should allow editing the whole page (T232170)
- 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 bindEditLinksLoginDrawer
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function bindEditLinksLoginDrawer( router ) {
let drawer;
function showLoginDrawer() {
if ( !drawer ) {
drawer = new CtaDrawer( {
Function init
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function init( currentPage, currentPageHTMLParser, skin, router ) {
let editErrorMessage, editRestrictions;
// see: https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#Page-specific
const isReadOnly = mw.config.get( 'wgMinervaReadOnly' );
const isEditable = !isReadOnly && mw.config.get( 'wgIsProbablyEditable' );
- 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
Avoid too many return
statements within this function. Open
return 'SourceEditor';