ckeditor/ckeditor5-engine

View on GitHub

Showing 564 of 564 total issues

Function stringify has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export function stringify( node, selectionOrPositionOrRange = null, markers = null ) {
    const model = new Model();
    const mapper = new Mapper();
    let selection, range;

Severity: Minor
Found in src/dev-utils/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 _wrapChildren has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    _wrapChildren( parent, startOffset, endOffset, wrapElement ) {
        let i = startOffset;
        const wrapPositions = [];

        while ( i < endOffset ) {
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 _convertViewElements has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function _convertViewElements( rootNode ) {
    if ( rootNode.is( 'element' ) || rootNode.is( 'documentFragment' ) ) {
        // Convert element or leave document fragment.

        const convertedElement = rootNode.is( 'documentFragment' ) ?
Severity: Minor
Found in src/dev-utils/view.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 _formatReturnValue has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    _formatReturnValue( type, item, previousPosition, nextPosition, length ) {
        // Text is a specific parent, because contains string instead of children.
        // Walker doesn't enter to the Text except situations when walker is iterating over every single character,
        // or the bound starts/ends inside the Text. So when the position is at the beginning or at the end of the Text
        // we move it just before or just after Text.
Severity: Minor
Found in src/view/treewalker.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 _createRanges has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    _createRanges() {
        const ranges = [];
        let range = null;

        for ( const item of this._positions ) {
Severity: Minor
Found in src/dev-utils/view.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 isElementMatching has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function isElementMatching( element, pattern ) {
    // If pattern is provided as function - return result of that function;
    if ( typeof pattern == 'function' ) {
        return pattern( element );
    }
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 setTo has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    setTo( selectable, placeOrOffset, options ) {
        if ( selectable === null ) {
            this._setRanges( [] );
            this._setFakeOptions( placeOrOffset );
        } else if ( selectable instanceof Selection || selectable instanceof DocumentSelection ) {
Severity: Minor
Found in src/view/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 _updateChildren has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    _updateChildren( viewElement, options ) {
        const domElement = this.domConverter.mapViewToDom( viewElement );

        if ( !domElement ) {
            // If there is no `domElement` it means that it was already removed from DOM.
Severity: Minor
Found in src/view/renderer.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 _updateMarkers has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    _updateMarkers() {
        const markers = [];
        let changed = false;

        for ( const marker of this._model.markers ) {
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 isSimilar has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    isSimilar( otherElement ) {
        if ( !( otherElement instanceof Element ) ) {
            return false;
        }

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

    isTouching( otherPosition ) {
        let left = null;
        let right = null;
        const compare = this.compareWith( otherPosition );

Severity: Minor
Found in src/model/position.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 _createFromRanges has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    static _createFromRanges( ranges ) {
        if ( ranges.length === 0 ) {
            /**
             * At least one range has to be passed to
             * {@link module:engine/model/range~Range._createFromRanges `Range._createFromRanges()`}.
Severity: Minor
Found in src/model/range.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 updateMarker has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    updateMarker( markerOrName, options ) {
        this._assertWriterUsedCorrectly();

        const markerName = typeof markerOrName == 'string' ? markerOrName : markerOrName.name;
        const currentMarker = this.model.markers.get( markerName );
Severity: Minor
Found in src/model/writer.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 _getTransformedByMove has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    _getTransformedByMove( sourcePosition, targetPosition, howMany, spread = false ) {
        // Special case for transforming a collapsed range. Just transform it like a position.
        if ( this.isCollapsed ) {
            const newPos = this.start._getTransformedByMove( sourcePosition, targetPosition, howMany );

Severity: Minor
Found in src/model/range.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 viewToDom has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    viewToDom( viewNode, domDocument, options = {} ) {
        if ( viewNode.is( 'text' ) ) {
            const textData = this._processDataFromViewText( viewNode );

            return domDocument.createTextNode( textData );
Severity: Minor
Found in src/view/domconverter.js - About 1 hr to fix

    Function domPositionToView has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        domPositionToView( domParent, domOffset ) {
            if ( this.isBlockFiller( domParent, this.blockFillerMode ) ) {
                return this.domPositionToView( domParent.parentNode, indexOf( domParent ) );
            }
    
    
    Severity: Minor
    Found in src/view/domconverter.js - About 1 hr to fix

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

      export default class ClickObserver extends DomEventObserver {
          constructor( view ) {
              super( view );
      
              this.domEventType = 'click';
      Severity: Major
      Found in src/view/observer/clickobserver.js and 1 other location - About 1 hr to fix
      src/view/observer/mouseobserver.js on lines 20..30

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

      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

      export default class MouseObserver extends DomEventObserver {
          constructor( view ) {
              super( view );
      
              this.domEventType = 'mousedown';
      Severity: Major
      Found in src/view/observer/mouseobserver.js and 1 other location - About 1 hr to fix
      src/view/observer/clickobserver.js on lines 22..32

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

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

          _breakAttributes( position, forceSplitText = false ) {
              const positionOffset = position.offset;
              const positionParent = position.parent;
      
              // If position is placed inside EmptyElement - throw an exception as we cannot break inside.
      Severity: Minor
      Found in src/view/downcastwriter.js - About 1 hr to fix

        Function _wrapAttributeElement has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _wrapAttributeElement( wrapper, toWrap ) {
                if ( !canBeJoined( wrapper, toWrap ) ) {
                    return false;
                }
        
        
        Severity: Minor
        Found in src/view/downcastwriter.js - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language