ckeditor/ckeditor5-engine

View on GitHub

Showing 564 of 564 total issues

Function matchAll has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    matchAll( ...element ) {
        const results = [];

        for ( const singleElement of element ) {
            for ( const pattern of this._patterns ) {
Severity: Minor
Found in src/view/matcher.js - About 35 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 _convertElement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function _convertElement( viewDocument, viewElement ) {
    const info = _convertElementNameAndInfo( viewElement );
    const ElementConstructor = allowedTypes[ info.type ];
    const newElement = ElementConstructor ? new ElementConstructor( viewDocument, info.name ) : new ViewElement( viewDocument, info.name );

Severity: Minor
Found in src/dev-utils/view.js - About 35 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 _getTouchingViewTextNode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    _getTouchingViewTextNode( node, getNext ) {
        const treeWalker = new ViewTreeWalker( {
            startPosition: getNext ? ViewPosition._createAfter( node ) : ViewPosition._createBefore( node ),
            direction: getNext ? 'forward' : 'backward'
        } );
Severity: Minor
Found in src/view/domconverter.js - About 35 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 wrap has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    wrap( range, attribute ) {
        if ( !( attribute instanceof AttributeElement ) ) {
            throw new CKEditorError( 'view-writer-wrap-invalid-attribute', this.document );
        }

Severity: Minor
Found in src/view/downcastwriter.js - About 35 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 compareWith has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    compareWith( otherPosition ) {
        if ( this.root !== otherPosition.root ) {
            return 'different';
        }

Severity: Minor
Found in src/view/position.js - About 35 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 insert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    insert( position, nodes ) {
        nodes = isIterable( nodes ) ? [ ...nodes ] : [ nodes ];

        // Check if nodes to insert are instances of AttributeElements, ContainerElements, EmptyElements, UIElements or Text.
        validateNodesToInsert( nodes, this.document );
Severity: Minor
Found in src/view/downcastwriter.js - About 35 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 _addToClonedElementsGroup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    _addToClonedElementsGroup( element ) {
        // Add only if the element is in document tree.
        if ( !element.root.is( 'rootElement' ) ) {
            return;
        }
Severity: Minor
Found in src/view/downcastwriter.js - About 35 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 getNormalized has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    getNormalized( name, styles ) {
        if ( !name ) {
            return merge( {}, styles );
        }

Severity: Minor
Found in src/view/stylesmap.js - About 35 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 _needsInlineFillerAtSelection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    _needsInlineFillerAtSelection() {
        if ( this.selection.rangeCount != 1 || !this.selection.isCollapsed ) {
            return false;
        }

Severity: Minor
Found in src/view/renderer.js - About 35 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 _getAllUpcastDefinitions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function* _getAllUpcastDefinitions( definition ) {
    if ( definition.model.values ) {
        for ( const value of definition.model.values ) {
            const model = { key: definition.model.key, value };
            const view = definition.view[ value ];
Severity: Minor
Found in src/conversion/conversion.js - About 35 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 _getTransformedByMove has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    _getTransformedByMove( sourcePosition, targetPosition, howMany ) {
        // Update target position, as it could be affected by nodes removal.
        targetPosition = targetPosition._getTransformedByDeletion( sourcePosition, howMany );

        if ( sourcePosition.isEqual( targetPosition ) ) {
Severity: Minor
Found in src/model/position.js - About 35 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 _splitToAllowedParent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    _splitToAllowedParent( node, modelCursor ) {
        // Try to find allowed parent.
        const allowedParent = this.conversionApi.schema.findAllowedParent( modelCursor, node );

        // When there is no parent that allows to insert node then return `null`.
Severity: Minor
Found in src/conversion/upcastdispatcher.js - About 35 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 extractMarkersFromModelFragment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function extractMarkersFromModelFragment( modelItem, writer ) {
    const markerElements = new Set();
    const markers = new Map();

    // Create ModelTreeWalker.
Severity: Minor
Found in src/conversion/upcastdispatcher.js - About 35 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 updatePlaceholder has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function updatePlaceholder( writer, element, config ) {
    const { text, isDirectHost } = config;

    const hostElement = isDirectHost ? element : getChildPlaceholderHostSubstitute( element );
    let wasViewModified = false;
Severity: Minor
Found in src/view/placeholder.js - About 35 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 _findReplaceActions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    _findReplaceActions( actions, actualDom, expectedDom ) {
        // If there is no both 'insert' and 'delete' actions, no need to check for replaced elements.
        if ( actions.indexOf( 'insert' ) === -1 || actions.indexOf( 'delete' ) === -1 ) {
            return actions;
        }
Severity: Minor
Found in src/view/renderer.js - About 35 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 mergeBranches has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function mergeBranches( writer, startPos, endPos ) {
    const startParent = startPos.parent;
    const endParent = endPos.parent;

    // If both positions ended up in the same parent, then there's nothing more to merge:
Severity: Minor
Found in src/model/utils/deletecontent.js - About 35 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 _getChildrenSnapshot has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function _getChildrenSnapshot( children ) {
    const snapshot = [];

    for ( const child of children ) {
        if ( child.is( 'text' ) ) {
Severity: Minor
Found in src/model/differ.js - About 35 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 fromJSON has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    static fromJSON( json ) {
        let children = null;

        if ( json.children ) {
            children = [];
Severity: Minor
Found in src/model/element.js - About 35 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

Similar blocks of code found in 4 locations. Consider refactoring.
Open

    getFirstPosition() {
        const firstRange = this.getFirstRange();

        return firstRange ? firstRange.start.clone() : null;
    }
Severity: Major
Found in src/view/selection.js and 3 other locations - About 35 mins to fix
src/model/selection.js on lines 294..298
src/model/selection.js on lines 309..313
src/view/selection.js on lines 300..304

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 46.

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

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

    is( type ) {
        return type === 'text' || type === 'view:text' ||
            // From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
            type === 'node' || type === 'view:node';
    }
Severity: Major
Found in src/view/text.js and 3 other locations - About 35 mins to fix
src/model/liveposition.js on lines 82..86
src/model/liverange.js on lines 59..63
src/model/text.js on lines 84..88

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 46.

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

Further Reading

Severity
Category
Status
Source
Language