ckeditor/ckeditor5-engine

View on GitHub

Showing 372 of 564 total issues

Function transformSets has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export function transformSets( operationsA, operationsB, options ) {
    // Create new arrays so the originally passed arguments are not changed.
    // No need to clone operations, they are cloned as they are transformed.
    operationsA = operationsA.slice();
    operationsB = operationsB.slice();
Severity: Minor
Found in src/model/operation/transform.js - About 55 mins to fix

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 _createAt has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    static _createAt( itemOrPosition, offset, stickiness = 'toNone' ) {
        if ( itemOrPosition instanceof Position ) {
            return new Position( itemOrPosition.root, itemOrPosition.path, itemOrPosition.stickiness );
        } else {
            const node = itemOrPosition;
Severity: Minor
Found in src/model/position.js - About 55 mins to fix

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 split has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    split( position, limitElement ) {
        this._assertWriterUsedCorrectly();

        let splitElement = position.parent;

Severity: Minor
Found in src/model/writer.js - About 55 mins to fix

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 _getTransformedByMergeOperation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    _getTransformedByMergeOperation( operation ) {
        // Special case when the marker is set on "the closing tag" of an element. Marker can be set like that during
        // transformations, especially when a content of a few block elements were removed. For example:
        //
        // {} is the transformed range, [] is the removed range.
Severity: Minor
Found in src/model/range.js - About 55 mins to fix

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 _addOperationForAffectedMarkers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    _addOperationForAffectedMarkers( type, positionOrRange ) {
        for ( const marker of this.model.markers ) {
            if ( !marker.managedUsingOperations ) {
                continue;
            }
Severity: Minor
Found in src/model/writer.js - About 55 mins to fix

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 checkMerge has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    checkMerge( positionOrBaseElement, elementToMerge = null ) {
        if ( positionOrBaseElement instanceof Position ) {
            const nodeBefore = positionOrBaseElement.nodeBefore;
            const nodeAfter = positionOrBaseElement.nodeAfter;

Severity: Minor
Found in src/model/schema.js - About 55 mins to fix

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 _processDataFromViewText has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    _processDataFromViewText( node ) {
        let data = node.data;

        // If any of node ancestors has a name which is in `preElements` array, then currently processed
        // view text node is (will be) in preformatted element. We should not change whitespaces then.
Severity: Minor
Found in src/view/domconverter.js - About 45 mins to fix

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 domSelectionToView has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    domSelectionToView( domSelection ) {
        // DOM selection might be placed in fake selection container.
        // If container contains fake selection - return corresponding view selection.
        if ( domSelection.rangeCount === 1 ) {
            let container = domSelection.getRangeAt( 0 ).startContainer;
Severity: Minor
Found in src/view/domconverter.js - About 45 mins to fix

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 attachDomRoot has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    attachDomRoot( domRoot, name = 'main' ) {
        const viewRoot = this.document.getRoot( name );

        // Set view root name the same as DOM root tag name.
        viewRoot._name = domRoot.tagName.toLowerCase();
Severity: Minor
Found in src/view/view.js - About 45 mins to fix

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 deeply nested control flow statements.
Open

                        if ( !this.sameSelectionCharacters && item.textOffset !== 0 && item.textOffset !== text.length ) {
                            throw new Error( `Parse error - range delimiter '${ item.bracket }' is placed inside text node.` );
                        }
Severity: Major
Found in src/dev-utils/view.js - About 45 mins to fix

    Function add has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        add( ...pattern ) {
            for ( let item of pattern ) {
                // String or RegExp pattern is used as element's name.
                if ( typeof item == 'string' || item instanceof RegExp ) {
                    item = { name: item };
    Severity: Minor
    Found in src/view/matcher.js - About 45 mins to fix

    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 getModelLength has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        getModelLength( viewNode ) {
            if ( this._viewToModelLengthCallbacks.get( viewNode.name ) ) {
                const callback = this._viewToModelLengthCallbacks.get( viewNode.name );
    
                return callback( viewNode );
    Severity: Minor
    Found in src/conversion/mapper.js - About 45 mins to fix

    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 test has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        test( consumables ) {
            // Check if name can be consumed.
            if ( consumables.name && !this._canConsumeName ) {
                return this._canConsumeName;
            }
    Severity: Minor
    Found in src/conversion/viewconsumable.js - About 45 mins to fix

    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 markerNameToElements has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        markerNameToElements( name ) {
            const boundElements = this._markerNameToElements.get( name );
    
            if ( !boundElements ) {
                return null;
    Severity: Minor
    Found in src/conversion/mapper.js - About 45 mins to fix

    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 _getTransformedByInsertion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        _getTransformedByInsertion( insertPosition, howMany ) {
            const transformed = Position._createAt( this );
    
            // This position can't be affected if insertion was in a different root.
            if ( this.root != insertPosition.root ) {
    Severity: Minor
    Found in src/model/position.js - About 45 mins to fix

    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 convertChanges has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        convertChanges( differ, markers, writer ) {
            // Before the view is updated, remove markers which have changed.
            for ( const change of differ.getMarkersToRemove() ) {
                this.convertMarkerRemove( change.name, change.range, writer );
            }
    Severity: Minor
    Found in src/conversion/downcastdispatcher.js - About 45 mins to fix

    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 transform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function transform( operation ) {
        // Transform the range by the operation. Join the result ranges if needed.
        const ranges = this.getTransformedByOperation( operation );
        const result = Range._createFromRanges( ranges );
    
    
    Severity: Minor
    Found in src/model/liverange.js - About 45 mins to fix

    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 _validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        _validate() {
            if ( !this.range.isFlat ) {
                /**
                 * The range to change is not flat.
                 *
    Severity: Minor
    Found in src/model/operation/attributeoperation.js - About 45 mins to fix

    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 _isInInsertedElement has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        _isInInsertedElement( element ) {
            const parent = element.parent;
    
            if ( !parent ) {
                return false;
    Severity: Minor
    Found in src/model/differ.js - About 45 mins to fix

    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 deeply nested control flow statements.
    Open

                            if ( incEnd > oldEnd ) {
                                // This case is similar to a case described when incoming change was insert and old change was attribute.
                                // See comment above.
                                //
                                // This time incoming change is attribute. We need to split incoming change in this case too.
    Severity: Major
    Found in src/model/differ.js - About 45 mins to fix
      Severity
      Category
      Status
      Source
      Language