ckeditor/ckeditor5-list

View on GitHub

Showing 27 of 30 total issues

Function modelChangePostFixer has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring.
Open

export function modelChangePostFixer( model, writer ) {
    const changes = model.document.differ.getChanges();
    const itemToListHead = new Map();

    let applied = false;
Severity: Minor
Found in src/converters.js - About 1 day 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 converters.js has 461 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/converters.js - About 7 hrs to fix

    Function modelChangePostFixer has 109 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function modelChangePostFixer( model, writer ) {
        const changes = model.document.differ.getChanges();
        const itemToListHead = new Map();
    
        let applied = false;
    Severity: Major
    Found in src/converters.js - About 4 hrs to fix

      Function injectViewList has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

      export function injectViewList( modelItem, injectedItem, conversionApi, model ) {
          const injectedList = injectedItem.parent;
          const mapper = conversionApi.mapper;
          const viewWriter = conversionApi.writer;
      
      
      Severity: Minor
      Found in src/utils.js - About 4 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 modelViewSplitOnInsert has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

      export function modelViewSplitOnInsert( evt, data, conversionApi ) {
          if ( data.item.name != 'listItem' ) {
              let viewPosition = conversionApi.mapper.toViewPosition( data.range.start );
      
              const viewWriter = conversionApi.writer;
      Severity: Minor
      Found in src/converters.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 init has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          init() {
              const editor = this.editor;
      
              // Schema.
              // Note: in case `$block` will ever be allowed in `listItem`, keep in mind that this feature
      Severity: Major
      Found in src/listediting.js - About 3 hrs to fix

        Function cleanListItem has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

        export function cleanListItem( evt, data, conversionApi ) {
            if ( conversionApi.consumable.test( data.viewItem, { name: true } ) ) {
                if ( data.viewItem.childCount === 0 ) {
                    return;
                }
        Severity: Minor
        Found in src/converters.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 _fixType has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

        function _fixType( blocks, isBackward, lowestIndent ) {
            // We need to check previous sibling of first changed item and next siblings of last changed item.
            const startingItem = isBackward ? blocks[ 0 ] : blocks[ blocks.length - 1 ];
        
            if ( startingItem.is( 'listItem' ) ) {
        Severity: Minor
        Found in src/listcommand.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 init has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            init() {
                const editor = this.editor;
                const { editing, data, model } = editor;
        
                // Extend schema.
        Severity: Major
        Found in src/todolistediting.js - About 2 hrs to fix

          Function injectViewList has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function injectViewList( modelItem, injectedItem, conversionApi, model ) {
              const injectedList = injectedItem.parent;
              const mapper = conversionApi.mapper;
              const viewWriter = conversionApi.writer;
          
          
          Severity: Major
          Found in src/utils.js - About 2 hrs to fix

            Function modelIndentPasteFixer has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

            export function modelIndentPasteFixer( evt, [ content, selectable ] ) {
                // Check whether inserted content starts from a `listItem`. If it does not, it means that there are some other
                // elements before it and there is no need to fix indents, because even if we insert that content into a list,
                // that list will be broken.
                // Note: we also need to handle singular elements because inserting item with indent 0 into 0,1,[],2
            Severity: Minor
            Found in src/converters.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 execute has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                execute() {
                    const model = this.editor.model;
                    const document = model.document;
                    const blocks = Array.from( document.selection.getSelectedBlocks() )
                        .filter( block => checkCanBecomeListItem( block, model.schema ) );
            Severity: Minor
            Found in src/listcommand.js - About 1 hr to fix

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

              function viewToModelListItemChildrenConverter( listItemModel, viewChildren, conversionApi ) {
                  const { writer, schema } = conversionApi;
              
                  // A position after the last inserted `listItem`.
                  let nextPosition = writer.createPositionAfter( listItemModel );
              Severity: Minor
              Found in src/converters.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 dataModelViewInsertion has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function dataModelViewInsertion( model ) {
                  return ( evt, data, conversionApi ) => {
                      const consumable = conversionApi.consumable;
              
                      if ( !consumable.test( data.item, 'insert' ) ||
              Severity: Minor
              Found in src/todolistconverters.js - About 1 hr to fix

                Function modelViewSplitOnInsert has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function modelViewSplitOnInsert( evt, data, conversionApi ) {
                    if ( data.item.name != 'listItem' ) {
                        let viewPosition = conversionApi.mapper.toViewPosition( data.range.start );
                
                        const viewWriter = conversionApi.writer;
                Severity: Minor
                Found in src/converters.js - About 1 hr to fix

                  Function viewToModelPosition has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function viewToModelPosition( model ) {
                      return ( evt, data ) => {
                          const viewPos = data.viewPosition;
                          const viewParent = viewPos.parent;
                          const mapper = data.mapper;
                  Severity: Minor
                  Found in src/converters.js - About 1 hr to fix

                    Function hoistNestedLists has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function hoistNestedLists( nextIndent, modelRemoveStartPosition, viewRemoveStartPosition, viewRemovedItem, conversionApi, model ) {
                        // Find correct previous model list item element.
                        // The element has to have either same or smaller indent than given reference indent.
                        // This will be the model element which will get nested items (if it has smaller indent) or sibling items (if it has same indent).
                        // Keep in mind that such element might not be found, if removed item was the first item.
                    Severity: Minor
                    Found in src/converters.js - About 1 hr to fix

                      Function _checkEnabled has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          _checkEnabled() {
                              // Check whether any of position's ancestor is a list item.
                              const listItem = first( this.editor.model.document.selection.getSelectedBlocks() );
                      
                              // If selection is not in a list item, the command is disabled.
                      Severity: Minor
                      Found in src/indentcommand.js - About 55 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 viewModelConverter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function viewModelConverter( evt, data, conversionApi ) {
                          if ( conversionApi.consumable.consume( data.viewItem, { name: true } ) ) {
                              const writer = conversionApi.writer;
                      
                              // 1. Create `listItem` model element.
                      Severity: Minor
                      Found in src/converters.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 hoistNestedLists has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      function hoistNestedLists( nextIndent, modelRemoveStartPosition, viewRemoveStartPosition, viewRemovedItem, conversionApi, model ) {
                      Severity: Minor
                      Found in src/converters.js - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language