ckeditor/ckeditor5-engine

View on GitHub

Showing 564 of 564 total issues

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

    getAncestors( options = { includeSelf: false, parentFirst: false } ) {
        const ancestors = [];
        let parent = options.includeSelf ? this : this.parent;

        while ( parent ) {
Severity: Major
Found in src/model/textproxy.js and 2 other locations - About 3 hrs to fix
src/model/node.js on lines 236..246
src/view/node.js on lines 167..177

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

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

UpcastWriter has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class UpcastWriter {
    /**
     * @param {module:engine/view/document~Document} document The view document instance in which this upcast writer operates.
     */
    constructor( document ) {
Severity: Minor
Found in src/view/upcastwriter.js - About 3 hrs to fix

    Function bufferOperation has 79 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        bufferOperation( operation ) {
            // Below we take an operation, check its type, then use its parameters in marking (private) methods.
            // The general rule is to not mark elements inside inserted element. All inserted elements are re-rendered.
            // Marking changes in them would cause a "double" changing then.
            //
    Severity: Major
    Found in src/model/differ.js - About 3 hrs to fix

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

              if ( this.isIntersecting( otherRange ) ) {
                  // Ranges intersect.
      
                  if ( this.containsPosition( otherRange.start ) ) {
                      // Given range start is inside this range. This means that we have to
      Severity: Major
      Found in src/model/range.js and 1 other location - About 3 hrs to fix
      src/view/range.js on lines 243..260

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

      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

              if ( this.isIntersecting( otherRange ) ) {
                  // Ranges intersect.
      
                  if ( this.containsPosition( otherRange.start ) ) {
                      // Given range start is inside this range. This means that we have to
      Severity: Major
      Found in src/view/range.js and 1 other location - About 3 hrs to fix
      src/model/range.js on lines 212..229

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

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

          viewPositionToDom( viewPosition ) {
              const viewParent = viewPosition.parent;
      
              if ( viewParent.is( 'text' ) ) {
                  const domParent = this.findCorrespondingDomText( viewParent );
      Severity: Minor
      Found in src/view/domconverter.js - About 3 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

      Node has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class Node {
          /**
           * Creates a model node.
           *
           * This is an abstract class, so this constructor should not be used directly.
      Severity: Minor
      Found in src/model/node.js - About 3 hrs to fix

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

            get focus() {
                if ( !this._ranges.length ) {
                    return null;
                }
                const range = this._ranges[ this._ranges.length - 1 ];
        Severity: Major
        Found in src/view/selection.js and 1 other location - About 2 hrs to fix
        src/view/selection.js on lines 162..170

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

        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

            getFirstRange() {
                let first = null;
        
                for ( const range of this._ranges ) {
                    if ( !first || range.start.isBefore( first.start ) ) {
        Severity: Major
        Found in src/model/selection.js and 1 other location - About 2 hrs to fix
        src/model/selection.js on lines 273..283

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

        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 ) {
                    return null;
                }
                const range = this._ranges[ this._ranges.length - 1 ];
        Severity: Major
        Found in src/view/selection.js and 1 other location - About 2 hrs to fix
        src/view/selection.js on lines 178..186

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

        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

        function bindWithDocument() {
            this.listenTo(
                this.root.document.model,
                'applyOperation',
                ( event, args ) => {
        Severity: Major
        Found in src/model/liveposition.js and 1 other location - About 2 hrs to fix
        src/model/liverange.js on lines 141..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 94.

        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

            getLastRange() {
                let last = null;
        
                for ( const range of this._ranges ) {
                    if ( !last || range.end.isAfter( last.end ) ) {
        Severity: Major
        Found in src/model/selection.js and 1 other location - About 2 hrs to fix
        src/model/selection.js on lines 251..261

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

        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

        function bindWithDocument() {
            this.listenTo(
                this.root.document.model,
                'applyOperation',
                ( event, args ) => {
        Severity: Major
        Found in src/model/liverange.js and 1 other location - About 2 hrs to fix
        src/model/liveposition.js on lines 151..166

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

        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

            _insertChild( index, items ) {
                const nodes = normalize( items );
        
                for ( const node of nodes ) {
                    // If node that is being added to this element is already inside another element, first remove it from the old parent.
        Severity: Major
        Found in src/model/documentfragment.js and 1 other location - About 2 hrs to fix
        src/model/element.js on lines 267..280

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

        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

            _insertChild( index, items ) {
                const nodes = normalize( items );
        
                for ( const node of nodes ) {
                    // If node that is being added to this element is already inside another element, first remove it from the old parent.
        Severity: Major
        Found in src/model/element.js and 1 other location - About 2 hrs to fix
        src/model/documentfragment.js on lines 290..303

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

        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

            _removeChildren( index, howMany = 1 ) {
                this._fireChange( 'children', this );
        
                for ( let i = index; i < index + howMany; i++ ) {
                    this._children[ i ].parent = null;
        Severity: Major
        Found in src/view/element.js and 1 other location - About 2 hrs to fix
        src/view/documentfragment.js on lines 201..209

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

        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

            _removeChildren( index, howMany = 1 ) {
                this._fireChange( 'children', this );
        
                for ( let i = index; i < index + howMany; i++ ) {
                    this._children[ i ].parent = null;
        Severity: Major
        Found in src/view/documentfragment.js and 1 other location - About 2 hrs to fix
        src/view/element.js on lines 645..653

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

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

            _previous() {
                let position = this.position.clone();
                const previousPosition = this.position;
                const parent = position.parent;
        
        
        Severity: Major
        Found in src/view/treewalker.js - About 2 hrs to fix

          Function stringify has 70 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function stringify( node, selectionOrPositionOrRange = null, markers = null ) {
              const model = new Model();
              const mapper = new Mapper();
              let selection, range;
          
          
          Severity: Major
          Found in src/dev-utils/model.js - About 2 hrs to fix

            Function _test has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

                _test( 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

            Severity
            Category
            Status
            Source
            Language