ckeditor/ckeditor5-engine

View on GitHub

Showing 372 of 564 total issues

Function insertContent has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function insertContent( model, content, selectable, placeOrOffset ) {
    return model.change( writer => {
        let selection;

        if ( !selectable ) {
Severity: Minor
Found in src/model/utils/insertcontent.js - About 1 hr to fix

    Function prepareToElementConverter has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function prepareToElementConverter( config ) {
        const matcher = config.view ? new Matcher( config.view ) : null;
    
        return ( evt, data, conversionApi ) => {
            let match = {};
    Severity: Minor
    Found in src/conversion/upcasthelpers.js - About 1 hr to fix

      Function isSimilar has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          isSimilar( otherSelection ) {
              if ( this.isBackward != otherSelection.isBackward ) {
                  return false;
              }
      
      
      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 _updateChildrenMappings has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          _updateChildrenMappings( viewElement ) {
              const domElement = this.domConverter.mapViewToDom( viewElement );
      
              if ( !domElement ) {
                  // If there is no `domElement` it means that it was already removed from DOM and there is no need to process it.
      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 constructor has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          constructor( options = {} ) {
              if ( !options.boundaries && !options.startPosition ) {
                  /**
                   * Neither boundaries nor starting position of a `TreeWalker` have been defined.
                   *
      Severity: Minor
      Found in src/model/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 isEqual has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          isEqual( otherSelection ) {
              if ( this.rangeCount != otherSelection.rangeCount ) {
                  return false;
              } else if ( this.rangeCount === 0 ) {
                  return true;
      Severity: Minor
      Found in src/model/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 getSelectedContent has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function getSelectedContent( model, selection ) {
          return model.change( writer => {
              const frag = writer.createDocumentFragment();
              const range = selection.getFirstRange();
      
      
      Severity: Minor
      Found in src/model/utils/getselectedcontent.js - About 1 hr to fix

        Function setTo has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            setTo( selectable, placeOrOffset, options ) {
                if ( selectable === null ) {
                    this._setRanges( [] );
                } else if ( selectable instanceof Selection ) {
                    this._setRanges( selectable.getRanges(), selectable.isBackward );
        Severity: Minor
        Found in src/model/selection.js - About 1 hr to fix

          Function updateMarker has 35 lines of code (exceeds 25 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

            Function _stringifyTextRanges has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _stringifyTextRanges( node ) {
                    const length = node.data.length;
                    let result = node.data.split( '' );
                    let rangeStartToken, rangeEndToken;
            
            
            Severity: Minor
            Found in src/dev-utils/view.js - About 1 hr to fix

              Function findCorrespondingViewText has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  findCorrespondingViewText( domText ) {
                      if ( isInlineFiller( domText ) ) {
                          return null;
                      }
              
              
              Severity: Minor
              Found in src/view/domconverter.js - About 1 hr to fix

                Function setData has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function setData( model, data, options = {} ) {
                    if ( !( model instanceof Model ) ) {
                        throw new TypeError( 'Model needs to be an instance of module:engine/model/model~Model.' );
                    }
                
                
                Severity: Minor
                Found in src/dev-utils/model.js - About 1 hr to fix

                  Function convertSelection has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      convertSelection( selection, markers, writer ) {
                          const markersAtSelection = Array.from( markers.getMarkersAtPosition( selection.getFirstPosition() ) );
                  
                          this.conversionApi.writer = writer;
                          this.conversionApi.consumable = this._createSelectionConsumable( selection, markersAtSelection );
                  Severity: Minor
                  Found in src/conversion/downcastdispatcher.js - About 1 hr to fix

                    Function constructor has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        constructor() {
                            /**
                             * Model's marker collection.
                             *
                             * @readonly
                    Severity: Minor
                    Found in src/model/model.js - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                          if ( isStartInLimit || isEndInLimit ) {
                              const bothInSameParent = ( start.nodeAfter && end.nodeBefore ) && start.nodeAfter.parent === end.nodeBefore.parent;
                      
                              const expandStart = isStartInLimit && ( !bothInSameParent || !isInObject( start.nodeAfter, schema ) );
                              const expandEnd = isEndInLimit && ( !bothInSameParent || !isInObject( end.nodeBefore, schema ) );
                      Severity: Critical
                      Found in src/model/utils/selection-post-fixer.js - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

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

                          Consider simplifying this complex logical expression.
                          Open

                              if (
                                  a.sourcePosition.isEqual( b.sourcePosition ) && !a.targetPosition.isEqual( b.targetPosition ) &&
                                  !context.bWasUndone && context.abRelation != 'splitAtSource'
                              ) {
                                  const aToGraveyard = a.targetPosition.root.rootName == '$graveyard';
                          Severity: Critical
                          Found in src/model/operation/transform.js - About 1 hr to fix

                            Consider simplifying this complex logical expression.
                            Open

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

                              Function constructor has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  constructor( stylesProcessor ) {
                                      /**
                                       * Instance of the {@link module:engine/view/document~Document} associated with this view controller.
                                       *
                                       * @readonly
                              Severity: Minor
                              Found in src/view/view.js - About 1 hr to fix

                                Function _generateActionsFromChanges has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function _generateActionsFromChanges( oldChildrenLength, changes ) {
                                    const actions = [];
                                
                                    let offset = 0;
                                    let oldChildrenHandled = 0;
                                Severity: Minor
                                Found in src/model/differ.js - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language