ckeditor/ckeditor5-engine

View on GitHub

Showing 564 of 564 total issues

Function _getTransformedByInsertion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    _getTransformedByInsertion( insertPosition, howMany ) {
        const transformed = Position._createAt( this );

        // This position can't be affected if insertion was in a different root.
        if ( this.root != insertPosition.root ) {
Severity: Minor
Found in src/model/position.js - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function transform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function transform( operation ) {
    // Transform the range by the operation. Join the result ranges if needed.
    const ranges = this.getTransformedByOperation( operation );
    const result = Range._createFromRanges( ranges );

Severity: Minor
Found in src/model/liverange.js - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function _validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    _validate() {
        if ( !this.range.isFlat ) {
            /**
             * The range to change is not flat.
             *
Severity: Minor
Found in src/model/operation/attributeoperation.js - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function test has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    test( consumables ) {
        // Check if name can be consumed.
        if ( consumables.name && !this._canConsumeName ) {
            return this._canConsumeName;
        }
Severity: Minor
Found in src/conversion/viewconsumable.js - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function getModelLength has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    getModelLength( viewNode ) {
        if ( this._viewToModelLengthCallbacks.get( viewNode.name ) ) {
            const callback = this._viewToModelLengthCallbacks.get( viewNode.name );

            return callback( viewNode );
Severity: Minor
Found in src/conversion/mapper.js - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid deeply nested control flow statements.
Open

                        if ( inc.offset <= old.offset ) {
                            inc.nodesToHandle -= old.howMany;
                            old.howMany = 0;
                        } else if ( inc.offset < oldEnd ) {
                            const intersectionLength = oldEnd - inc.offset;
Severity: Major
Found in src/model/differ.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if ( incEnd <= oldEnd ) {
                                // On first sight in this case we don't need to split attribute operation into two.
                                // However the changes set is later converted to actions (see `_generateActionsFromChanges`).
                                // For that reason, no two changes may intersect.
                                // So we cannot have an attribute change that "contains" remove change.
    Severity: Major
    Found in src/model/differ.js - About 45 mins to fix

      Function removeDisallowedAttributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          removeDisallowedAttributes( nodes, writer ) {
              for ( const node of nodes ) {
                  // When node is a `Text` it has no children, so just filter it out.
                  if ( node.is( 'text' ) ) {
                      removeDisallowedAttributeFromNode( this, node, writer );
      Severity: Minor
      Found in src/model/schema.js - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

              if ( !this.anchor.isEqual( otherSelection.anchor ) || !this.focus.isEqual( otherSelection.focus ) ) {
                  return false;
              }
      Severity: Minor
      Found in src/model/selection.js and 1 other location - About 45 mins to fix
      src/view/selection.js on lines 329..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 50.

      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

      Avoid deeply nested control flow statements.
      Open

                              if ( inc.offset < old.offset ) {
                                  const intersectionLength = incEnd - old.offset;
      
                                  old.offset = inc.offset;
      
      
      Severity: Major
      Found in src/model/differ.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            } else if ( inc.offset >= old.offset && inc.offset < oldEnd ) {
                                if ( incEnd > oldEnd ) {
                                    inc.nodesToHandle = incEnd - oldEnd;
                                    inc.offset = oldEnd;
                                } else {
        Severity: Major
        Found in src/model/differ.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if ( incEnd > oldEnd ) {
                                      // This case is similar to a case described when incoming change was insert and old change was attribute.
                                      // See comment above.
                                      //
                                      // This time incoming change is attribute. We need to split incoming change in this case too.
          Severity: Major
          Found in src/model/differ.js - About 45 mins to fix

            Function _isInInsertedElement has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                _isInInsertedElement( element ) {
                    const parent = element.parent;
            
                    if ( !parent ) {
                        return false;
            Severity: Minor
            Found in src/model/differ.js - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function getLimitElement has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                getLimitElement( selectionOrRangeOrPosition ) {
                    let element;
            
                    if ( selectionOrRangeOrPosition instanceof Position ) {
                        element = selectionOrRangeOrPosition.parent;
            Severity: Minor
            Found in src/model/schema.js - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                    if ( !this.anchor.isEqual( otherSelection.anchor ) || !this.focus.isEqual( otherSelection.focus ) ) {
                        return false;
                    }
            Severity: Minor
            Found in src/view/selection.js and 1 other location - About 45 mins to fix
            src/model/selection.js on lines 208..210

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

            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

                toView( data ) {
                    // Convert input HTML data to DOM DocumentFragment.
                    const domFragment = this._toDom( data );
            
                    // Convert DOM DocumentFragment to view DocumentFragment.
            Severity: Minor
            Found in src/dataprocessor/htmldataprocessor.js and 1 other location - About 40 mins to fix
            src/controller/datacontroller.js on lines 190..196

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

            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 range.containsPosition( operation.sourcePosition ) ||
                            range.start.isEqual( operation.sourcePosition ) ||
                            range.containsPosition( operation.targetPosition );
            Severity: Minor
            Found in src/model/liverange.js and 1 other location - About 40 mins to fix
            src/model/writer.js on lines 1365..1367

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

            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 ( element.is( 'element' ) ) {
                        for ( const child of element.getChildren() ) {
                            this._addToClonedElementsGroup( child );
                        }
                    }
            Severity: Minor
            Found in src/view/downcastwriter.js and 1 other location - About 40 mins to fix
            src/view/downcastwriter.js on lines 1692..1696

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

            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

                                positionOrRange.containsPosition( markerRange.start ) ||
                                positionOrRange.start.isEqual( markerRange.start ) ||
                                positionOrRange.containsPosition( markerRange.end ) ||
            Severity: Minor
            Found in src/model/writer.js and 1 other location - About 40 mins to fix
            src/model/liverange.js on lines 211..213

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

            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 ( element.is( 'element' ) ) {
                        for ( const child of element.getChildren() ) {
                            this._removeFromClonedElementsGroup( child );
                        }
                    }
            Severity: Minor
            Found in src/view/downcastwriter.js and 1 other location - About 40 mins to fix
            src/view/downcastwriter.js on lines 1654..1658

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

            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