ckeditor/ckeditor5-engine

View on GitHub

Showing 564 of 564 total issues

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

    * getPositions( options = {} ) {
        options.boundaries = this;

        const treeWalker = new TreeWalker( options );

Severity: Major
Found in src/view/range.js and 1 other location - About 1 hr to fix
src/model/range.js on lines 417..427

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

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

    getPath() {
        const path = [];
        let node = this; // eslint-disable-line consistent-this

        while ( node.parent ) {
Severity: Major
Found in src/model/node.js and 1 other location - About 1 hr to fix
src/view/node.js on lines 146..156

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

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

    getPath() {
        const path = [];
        let node = this; // eslint-disable-line consistent-this

        while ( node.parent ) {
Severity: Major
Found in src/view/node.js and 1 other location - About 1 hr to fix
src/model/node.js on lines 215..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 71.

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

    * getPositions( options = {} ) {
        options.boundaries = this;

        const treeWalker = new TreeWalker( options );

Severity: Major
Found in src/model/range.js and 1 other location - About 1 hr to fix
src/view/range.js on lines 424..434

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

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

    get index() {
        let pos;

        if ( !this.parent ) {
            return null;
Severity: Major
Found in src/model/node.js and 1 other location - About 1 hr to fix
src/model/node.js on lines 106..118

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

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

    get startOffset() {
        let pos;

        if ( !this.parent ) {
            return null;
Severity: Major
Found in src/model/node.js and 1 other location - About 1 hr to fix
src/model/node.js on lines 82..94

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

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 domToView has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    domToView( domNode, options = {} ) {
        if ( this.isBlockFiller( domNode, this.blockFillerMode ) ) {
            return null;
        }

Severity: Minor
Found in src/view/domconverter.js - About 1 hr to fix

    Function _unwrapChildren has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        _unwrapChildren( parent, startOffset, endOffset, unwrapElement ) {
            let i = startOffset;
            const unwrapPositions = [];
    
            // Iterate over each element between provided offsets inside parent.
    Severity: Minor
    Found in src/view/downcastwriter.js - About 1 hr 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 matchStyles has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    function matchStyles( patterns, element ) {
        const match = [];
    
        for ( const name in patterns ) {
            const pattern = patterns[ name ];
    Severity: Minor
    Found in src/view/matcher.js - About 1 hr 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 _unwrapAttributeElement has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        _unwrapAttributeElement( wrapper, toUnwrap ) {
            if ( !canBeJoined( wrapper, toUnwrap ) ) {
                return false;
            }
    
    
    Severity: Minor
    Found in src/view/downcastwriter.js - About 1 hr 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 _revert has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        _revert( type, item ) {
            const items = isArray( item ) ? item : [ item ];
            const consumables = this._consumables[ type ];
    
            for ( const name of items ) {
    Severity: Minor
    Found in src/conversion/viewconsumable.js - About 1 hr 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 _updateAttributes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        _updateAttributes( clearAll ) {
            const newAttributes = toMap( this._getSurroundingAttributes() );
            const oldAttributes = toMap( this.getAttributes() );
    
            if ( clearAll ) {
    Severity: Minor
    Found in src/model/documentselection.js - About 1 hr 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 setTo has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        setTo( selectable, placeOrOffset, options ) {
            if ( selectable === null ) {
                this._setRanges( [] );
            } else if ( selectable instanceof Selection ) {
                this._setRanges( selectable.getRanges(), selectable.isBackward );
    Severity: Minor
    Found in src/model/selection.js - About 1 hr 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 hasContent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        hasContent( rangeOrElement, options ) {
            const range = rangeOrElement instanceof ModelElement ? ModelRange._createIn( rangeOrElement ) : rangeOrElement;
    
            if ( range.isCollapsed ) {
                return false;
    Severity: Minor
    Found in src/model/model.js - About 1 hr 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 constructor has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        constructor( model ) {
            /**
             * The {@link module:engine/model/model~Model model} that the document is a part of.
             *
             * @readonly
    Severity: Minor
    Found in src/model/document.js - About 1 hr to fix

      Function _getSurroundingAttributes has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _getSurroundingAttributes() {
              const position = this.getFirstPosition();
              const schema = this._model.schema;
      
              let attrs = null;
      Severity: Minor
      Found in src/model/documentselection.js - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                    if ( type === 'move' ) {
                        isAffected =
                            positionOrRange.containsPosition( markerRange.start ) ||
                            positionOrRange.start.isEqual( markerRange.start ) ||
                            positionOrRange.containsPosition( markerRange.end ) ||
        Severity: Critical
        Found in src/model/writer.js - About 1 hr to fix

          Function parse has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function parse( data, schema, options = {} ) {
              const mapper = new Mapper();
          
              // Replace not accepted by XML `$text` tag name by valid one `model-text-with-attributes`.
              data = data.replace( new RegExp( '\\$text', 'g' ), 'model-text-with-attributes' );
          Severity: Minor
          Found in src/dev-utils/model.js - About 1 hr to fix

            Function render has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                render() {
                    let inlineFillerPosition;
            
                    // Refresh mappings.
                    for ( const element of this.markedChildren ) {
            Severity: Minor
            Found in src/view/renderer.js - About 1 hr to fix

              Function parseInlineStyles has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function parseInlineStyles( stylesString ) {
                  // `null` if no quote was found in input string or last found quote was a closing quote. See below.
                  let quoteType = null;
                  let propertyNameStart = 0;
                  let propertyValueStart = 0;
              Severity: Minor
              Found in src/view/stylesmap.js - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language