Showing 30 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' ) ||
Identical blocks of code found in 3 locations. Consider refactoring. Open
if ( !consumable.test( data.item, 'insert' ) ||
!consumable.test( data.item, 'attribute:listType' ) ||
!consumable.test( data.item, 'attribute:listIndent' )
) {
return;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 61.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 3 locations. Consider refactoring. Open
if ( !consumable.test( data.item, 'insert' ) ||
!consumable.test( data.item, 'attribute:listType' ) ||
!consumable.test( data.item, 'attribute:listIndent' )
) {
return;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 61.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 3 locations. Consider refactoring. Open
if ( !consumable.test( data.item, 'insert' ) ||
!consumable.test( data.item, 'attribute:listType' ) ||
!consumable.test( data.item, 'attribute:listIndent' )
) {
return;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 61.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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.