Showing 27 of 30 total issues
Function modelChangePostFixer
has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring. Open
export function modelChangePostFixer( model, writer ) {
const changes = model.document.differ.getChanges();
const itemToListHead = new Map();
let applied = false;
- 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
File converters.js
has 461 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
Function modelChangePostFixer
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function modelChangePostFixer( model, writer ) {
const changes = model.document.differ.getChanges();
const itemToListHead = new Map();
let applied = false;
Function injectViewList
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
export function injectViewList( modelItem, injectedItem, conversionApi, model ) {
const injectedList = injectedItem.parent;
const mapper = conversionApi.mapper;
const viewWriter = conversionApi.writer;
- 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 modelViewSplitOnInsert
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
export function modelViewSplitOnInsert( evt, data, conversionApi ) {
if ( data.item.name != 'listItem' ) {
let viewPosition = conversionApi.mapper.toViewPosition( data.range.start );
const viewWriter = conversionApi.writer;
- 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 init
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
init() {
const editor = this.editor;
// Schema.
// Note: in case `$block` will ever be allowed in `listItem`, keep in mind that this feature
Function cleanListItem
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
export function cleanListItem( evt, data, conversionApi ) {
if ( conversionApi.consumable.test( data.viewItem, { name: true } ) ) {
if ( data.viewItem.childCount === 0 ) {
return;
}
- 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 _fixType
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function _fixType( blocks, isBackward, lowestIndent ) {
// We need to check previous sibling of first changed item and next siblings of last changed item.
const startingItem = isBackward ? blocks[ 0 ] : blocks[ blocks.length - 1 ];
if ( startingItem.is( 'listItem' ) ) {
- 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 init
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
init() {
const editor = this.editor;
const { editing, data, model } = editor;
// Extend schema.
Function injectViewList
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function injectViewList( modelItem, injectedItem, conversionApi, model ) {
const injectedList = injectedItem.parent;
const mapper = conversionApi.mapper;
const viewWriter = conversionApi.writer;
Function modelIndentPasteFixer
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
export function modelIndentPasteFixer( evt, [ content, selectable ] ) {
// Check whether inserted content starts from a `listItem`. If it does not, it means that there are some other
// elements before it and there is no need to fix indents, because even if we insert that content into a list,
// that list will be broken.
// Note: we also need to handle singular elements because inserting item with indent 0 into 0,1,[],2
- 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 execute
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
execute() {
const model = this.editor.model;
const document = model.document;
const blocks = Array.from( document.selection.getSelectedBlocks() )
.filter( block => checkCanBecomeListItem( block, model.schema ) );
Function viewToModelListItemChildrenConverter
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function viewToModelListItemChildrenConverter( listItemModel, viewChildren, conversionApi ) {
const { writer, schema } = conversionApi;
// A position after the last inserted `listItem`.
let nextPosition = writer.createPositionAfter( listItemModel );
- 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 dataModelViewInsertion
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function dataModelViewInsertion( model ) {
return ( evt, data, conversionApi ) => {
const consumable = conversionApi.consumable;
if ( !consumable.test( data.item, 'insert' ) ||
Function modelViewSplitOnInsert
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function modelViewSplitOnInsert( evt, data, conversionApi ) {
if ( data.item.name != 'listItem' ) {
let viewPosition = conversionApi.mapper.toViewPosition( data.range.start );
const viewWriter = conversionApi.writer;
Function viewToModelPosition
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function viewToModelPosition( model ) {
return ( evt, data ) => {
const viewPos = data.viewPosition;
const viewParent = viewPos.parent;
const mapper = data.mapper;
Function hoistNestedLists
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function hoistNestedLists( nextIndent, modelRemoveStartPosition, viewRemoveStartPosition, viewRemovedItem, conversionApi, model ) {
// Find correct previous model list item element.
// The element has to have either same or smaller indent than given reference indent.
// This will be the model element which will get nested items (if it has smaller indent) or sibling items (if it has same indent).
// Keep in mind that such element might not be found, if removed item was the first item.
Function _checkEnabled
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
_checkEnabled() {
// Check whether any of position's ancestor is a list item.
const listItem = first( this.editor.model.document.selection.getSelectedBlocks() );
// If selection is not in a list item, the command is disabled.
- 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 viewModelConverter
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function viewModelConverter( evt, data, conversionApi ) {
if ( conversionApi.consumable.consume( data.viewItem, { name: true } ) ) {
const writer = conversionApi.writer;
// 1. Create `listItem` model 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"
Further reading
Function hoistNestedLists
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function hoistNestedLists( nextIndent, modelRemoveStartPosition, viewRemoveStartPosition, viewRemovedItem, conversionApi, model ) {