ckeditor/ckeditor5-engine

View on GitHub

Showing 564 of 564 total issues

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

    getMarkersToRemove() {
        const result = [];

        for ( const [ name, change ] of this._changedMarkers ) {
            if ( change.oldRange != null ) {
Severity: Major
Found in src/model/differ.js and 1 other location - About 2 hrs to fix
src/model/differ.js on lines 318..328

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

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

    findCorrespondingViewText( domText ) {
        if ( isInlineFiller( domText ) ) {
            return null;
        }

Severity: Minor
Found in src/view/domconverter.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 tryExtendingTo has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

function tryExtendingTo( data, value ) {
    // If found text, we can certainly put the focus in it. Let's just find a correct position
    // based on the unit.
    if ( value.type == 'text' ) {
        if ( data.unit === 'word' ) {
Severity: Minor
Found in src/model/utils/modifyselection.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 _consume has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

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

function getCorrectWordBreakPosition( walker, isForward ) {
    let textNode = walker.position.textNode;

    if ( textNode ) {
        let offset = walker.position.offset - textNode.startOffset;
Severity: Minor
Found in src/model/utils/modifyselection.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

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

    get focus() {
        if ( this._ranges.length > 0 ) {
            const range = this._ranges[ this._ranges.length - 1 ];

            return this._lastRangeBackward ? range.start : range.end;
Severity: Major
Found in src/model/selection.js and 1 other location - About 2 hrs to fix
src/model/selection.js on lines 126..134

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

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 anchor() {
        if ( this._ranges.length > 0 ) {
            const range = this._ranges[ this._ranges.length - 1 ];

            return this._lastRangeBackward ? range.end : range.start;
Severity: Major
Found in src/model/selection.js and 1 other location - About 2 hrs to fix
src/model/selection.js on lines 146..154

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

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

View has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class View {
    /**
     * @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance.
     */
    constructor( stylesProcessor ) {
Severity: Minor
Found in src/view/view.js - About 2 hrs to fix

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

        appendText( text, attributes, parent ) {
            if ( attributes instanceof DocumentFragment || attributes instanceof Element ) {
                this.insert( this.createText( text ), attributes, 'end' );
            } else {
                this.insert( this.createText( text, attributes ), parent, 'end' );
    Severity: Major
    Found in src/model/writer.js and 1 other location - About 2 hrs to fix
    src/model/writer.js on lines 343..349

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

    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

        appendElement( name, attributes, parent ) {
            if ( attributes instanceof DocumentFragment || attributes instanceof Element ) {
                this.insert( this.createElement( name ), attributes, 'end' );
            } else {
                this.insert( this.createElement( name, attributes ), parent, 'end' );
    Severity: Major
    Found in src/model/writer.js and 1 other location - About 2 hrs to fix
    src/model/writer.js on lines 325..331

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

    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 parseInlineStyles has a Cognitive Complexity of 17 (exceeds 5 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 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

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

        add( consumables ) {
            if ( consumables.name ) {
                this._canConsumeName = true;
            }
    
    
    Severity: Major
    Found in src/conversion/viewconsumable.js and 2 other locations - About 2 hrs to fix
    src/conversion/viewconsumable.js on lines 445..455
    src/conversion/viewconsumable.js on lines 474..484

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

    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

        revert( consumables ) {
            if ( consumables.name ) {
                this._canConsumeName = true;
            }
    
    
    Severity: Major
    Found in src/conversion/viewconsumable.js and 2 other locations - About 2 hrs to fix
    src/conversion/viewconsumable.js on lines 375..385
    src/conversion/viewconsumable.js on lines 445..455

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

    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

        consume( consumables ) {
            if ( consumables.name ) {
                this._canConsumeName = false;
            }
    
    
    Severity: Major
    Found in src/conversion/viewconsumable.js and 2 other locations - About 2 hrs to fix
    src/conversion/viewconsumable.js on lines 375..385
    src/conversion/viewconsumable.js on lines 474..484

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

    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

    DocumentSelection has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class DocumentSelection {
        /**
         * Creates new DocumentSelection instance.
         *
         *         // Creates empty selection without ranges.
    Severity: Minor
    Found in src/view/documentselection.js - About 2 hrs to fix

      Position has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class Position {
          /**
           * Creates a position.
           *
           * @param {module:engine/view/node~Node|module:engine/view/documentfragment~DocumentFragment} parent Position parent.
      Severity: Minor
      Found in src/view/position.js - About 2 hrs to fix

        Mapper has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export default class Mapper {
            /**
             * Creates an instance of the mapper.
             */
            constructor() {
        Severity: Minor
        Found in src/conversion/mapper.js - About 2 hrs to fix

          Model has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export default class Model {
              constructor() {
                  /**
                   * Model's marker collection.
                   *
          Severity: Minor
          Found in src/model/model.js - About 2 hrs to fix

            File insertcontent.js has 255 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
             */
            
            
            Severity: Minor
            Found in src/model/utils/insertcontent.js - About 2 hrs to fix

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

                  _canMergeRight( node, context ) {
                      const nextSibling = node.nextSibling;
              
                      return context.isLast &&
                          ( nextSibling 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 498..505

              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

              Severity
              Category
              Status
              Source
              Language