ckeditor/ckeditor5-engine

View on GitHub

Showing 564 of 564 total issues

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

    _canMergeLeft( node, context ) {
        const previousSibling = node.previousSibling;

        return context.isFirst &&
            ( previousSibling instanceof Element ) &&
Severity: Major
Found in src/model/utils/insertcontent.js and 1 other location - About 2 hrs to fix
src/model/utils/insertcontent.js on lines 515..522

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

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

Function _walkView has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    _walkView( root, callback ) {
        const ignore = this.ignoreRoot && this.root === root;

        if ( root.is( 'element' ) || root.is( 'documentFragment' ) ) {
            if ( root.is( 'element' ) && !ignore ) {
Severity: Minor
Found in src/dev-utils/view.js - About 2 hrs 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 clear has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    clear( range, element ) {
        validateRangeContainer( range, this.document );

        // Create walker on given range.
        // We walk backward because when we remove element during walk it modifies range end position.
Severity: Minor
Found in src/view/downcastwriter.js - About 2 hrs 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 render has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    render() {
        let inlineFillerPosition;

        // Refresh mappings.
        for ( const element of this.markedChildren ) {
Severity: Minor
Found in src/view/renderer.js - About 2 hrs 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 _mergeSiblingsOf has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    _mergeSiblingsOf( node, context ) {
        if ( !( node instanceof Element ) ) {
            return;
        }

Severity: Minor
Found in src/model/utils/insertcontent.js - About 2 hrs 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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        for ( const thisRange of this._ranges ) {
            let found = false;

            for ( const otherRange of otherSelection._ranges ) {
                if ( thisRange.isEqual( otherRange ) ) {
Severity: Major
Found in src/model/selection.js and 1 other location - About 2 hrs to fix
src/view/selection.js on lines 333..346

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

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        for ( const thisRange of this._ranges ) {
            let found = false;

            for ( const otherRange of otherSelection._ranges ) {
                if ( thisRange.isEqual( otherRange ) ) {
Severity: Major
Found in src/view/selection.js and 1 other location - About 2 hrs to fix
src/model/selection.js on lines 212..225

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

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 3 locations. Consider refactoring.
Open

    _removeStyle( property ) {
        this._fireChange( 'attributes', this );

        property = Array.isArray( property ) ? property : [ property ];
        property.forEach( name => this._styles.remove( name ) );
Severity: Major
Found in src/view/element.js and 2 other locations - About 2 hrs to fix
src/view/element.js on lines 727..732
src/view/element.js on lines 745..750

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

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 3 locations. Consider refactoring.
Open

    _addClass( className ) {
        this._fireChange( 'attributes', this );

        className = Array.isArray( className ) ? className : [ className ];
        className.forEach( name => this._classes.add( name ) );
Severity: Major
Found in src/view/element.js and 2 other locations - About 2 hrs to fix
src/view/element.js on lines 745..750
src/view/element.js on lines 792..797

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

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 2 locations. Consider refactoring.
Open

            return type === 'editableElement' || type === 'view:editableElement' ||
                // From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
                type === 'containerElement' || type === 'view:containerElement' ||
                type === this.name || type === 'view:' + this.name ||
                type === 'element' || type === 'view:element' ||
Severity: Major
Found in src/view/editableelement.js and 1 other location - About 2 hrs to fix
src/model/rootelement.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 75.

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 3 locations. Consider refactoring.
Open

    _removeClass( className ) {
        this._fireChange( 'attributes', this );

        className = Array.isArray( className ) ? className : [ className ];
        className.forEach( name => this._classes.delete( name ) );
Severity: Major
Found in src/view/element.js and 2 other locations - About 2 hrs to fix
src/view/element.js on lines 727..732
src/view/element.js on lines 792..797

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

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 2 locations. Consider refactoring.
Open

            return type === 'rootElement' || type === 'model:rootElement' ||
                // From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
                type === 'element' || type === 'model:element' ||
                type === this.name || type === 'model:' + this.name ||
                type === 'node' || type === 'model:node';
Severity: Major
Found in src/model/rootelement.js and 1 other location - About 2 hrs to fix
src/view/editableelement.js on lines 99..103

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

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

Function handleBackwardMovement has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    handleBackwardMovement( position, data ) {
        const attribute = this.attribute;

        // When the gravity is already overridden...
        if ( this._isGravityOverridden ) {
Severity: Minor
Found in src/utils/bindtwostepcarettoattribute.js - About 1 hr to fix

    Function _previous has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        _previous() {
            const previousPosition = this.position;
            const position = this.position.clone();
            const parent = this._visitedParent;
    
    
    Severity: Minor
    Found in src/model/treewalker.js - About 1 hr to fix

      Function changeAttribute has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function changeAttribute( attributeCreator ) {
          return ( evt, data, conversionApi ) => {
              const oldAttribute = attributeCreator( data.attributeOldValue, data );
              const newAttribute = attributeCreator( data.attributeNewValue, data );
      
      
      Severity: Minor
      Found in src/conversion/downcasthelpers.js - About 1 hr to fix

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

                for ( const child of json.nodes ) {
                    if ( child.name ) {
                        // If child has name property, it is an Element.
                        children.push( Element.fromJSON( child ) );
                    } else {
        Severity: Major
        Found in src/model/operation/insertoperation.js and 1 other location - About 1 hr to fix
        src/model/element.js on lines 315..323

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

        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 2 locations. Consider refactoring.
        Open

                    for ( const child of json.children ) {
                        if ( child.name ) {
                            // If child has name property, it is an Element.
                            children.push( Element.fromJSON( child ) );
                        } else {
        Severity: Major
        Found in src/model/element.js and 1 other location - About 1 hr to fix
        src/model/operation/insertoperation.js on lines 167..175

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

        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 2 locations. Consider refactoring.
        Open

                    if ( pattern instanceof RegExp ) {
                        if ( pattern.test( style ) ) {
                            match.push( name );
                        } else {
                            return null;
        Severity: Major
        Found in src/view/matcher.js and 1 other location - About 1 hr to fix
        src/view/matcher.js on lines 262..272

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

        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 2 locations. Consider refactoring.
        Open

                    } else if ( pattern instanceof RegExp ) {
                        if ( pattern.test( attribute ) ) {
                            match.push( name );
                        } else {
                            return null;
        Severity: Major
        Found in src/view/matcher.js and 1 other location - About 1 hr to fix
        src/view/matcher.js on lines 327..337

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

        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

        Function _next has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _next() {
                const previousPosition = this.position;
                const position = this.position.clone();
                const parent = this._visitedParent;
        
        
        Severity: Minor
        Found in src/model/treewalker.js - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language