ckeditor/ckeditor5-engine

View on GitHub

Showing 372 of 564 total issues

Function _wrapAttributeElement has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    _wrapAttributeElement( wrapper, toWrap ) {
        if ( !canBeJoined( wrapper, toWrap ) ) {
            return false;
        }

Severity: Minor
Found in src/view/downcastwriter.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

Function jumpOverUiElement has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

function jumpOverUiElement( evt, data, domConverter ) {
    if ( data.keyCode == keyCodes.arrowright ) {
        const domSelection = data.domTarget.ownerDocument.defaultView.getSelection();
        const domSelectionCollapsed = domSelection.rangeCount == 1 && domSelection.getRangeAt( 0 ).collapsed;

Severity: Minor
Found in src/view/uielement.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

File selection.js has 309 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/selection.js - About 3 hrs to fix

    LiveSelection has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class LiveSelection extends Selection {
        // Creates an empty live selection for given {@link module:engine/model/document~Document}.
        // @param {module:engine/model/document~Document} doc Document which owns this selection.
        constructor( doc ) {
            super();
    Severity: Minor
    Found in src/model/documentselection.js - About 3 hrs to fix

      Schema has 28 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class Schema {
          /**
           * Creates schema instance.
           */
          constructor() {
      Severity: Minor
      Found in src/model/schema.js - About 3 hrs to fix

        Function _onMutations has 82 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _onMutations( domMutations ) {
                // As a result of this.flush() we can have an empty collection.
                if ( domMutations.length === 0 ) {
                    return;
                }
        Severity: Major
        Found in src/view/observer/mutationobserver.js - About 3 hrs to fix

          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

              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

                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

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

                        _previous() {
                            const previousPosition = this.position;
                            const position = this.position.clone();
                            const parent = this._visitedParent;
                    
                    
                    Severity: Minor
                    Found in src/model/treewalker.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 _getPositions has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        _getPositions( node ) {
                            if ( node.is( 'documentFragment' ) || node.is( 'element' ) ) {
                                // Copy elements into the array, when nodes will be removed from parent node this array will still have all the
                                // items needed for iteration.
                                const children = [ ...node.getChildren() ];
                    Severity: Major
                    Found in src/dev-utils/view.js - About 2 hrs to fix

                      Function _next has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          _next() {
                              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

                        Consider simplifying this complex logical expression.
                        Open

                                if ( !name ) {
                                    return type === 'containerElement' || type === 'view:containerElement' ||
                                        // From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
                                        type === this.name || type === 'view:' + this.name ||
                                        type === 'element' || type === 'view:element' ||
                        Severity: Critical
                        Found in src/view/containerelement.js - About 2 hrs to fix

                          Consider simplifying this complex logical expression.
                          Open

                                  if ( !name ) {
                                      return type === 'attributeElement' || type === 'view:attributeElement' ||
                                          // From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
                                          type === this.name || type === 'view:' + this.name ||
                                          type === 'element' || type === 'view:element' ||
                          Severity: Critical
                          Found in src/view/attributeelement.js - About 2 hrs to fix

                            Consider simplifying this complex logical expression.
                            Open

                                    if ( !name ) {
                                        return type === 'uiElement' || type === 'view:uiElement' ||
                                            // From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
                                            type === this.name || type === 'view:' + this.name ||
                                            type === 'element' || type === 'view:element' ||
                            Severity: Critical
                            Found in src/view/uielement.js - About 2 hrs to fix

                              Selection has 24 functions (exceeds 20 allowed). Consider refactoring.
                              Open

                              export default class Selection {
                                  /**
                                   * Creates new selection instance.
                                   *
                                   * **Note**: The selection constructor is available as a factory method:
                              Severity: Minor
                              Found in src/view/selection.js - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language