ckeditor/ckeditor5-list

View on GitHub

Showing 30 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

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

                        if ( !consumable.test( data.item, 'insert' ) ||
                            !consumable.test( data.item, 'attribute:listType' ) ||
                            !consumable.test( data.item, 'attribute:listIndent' )
                        ) {
                            return;
                Severity: Major
                Found in src/todolistconverters.js and 2 other locations - About 1 hr to fix
                src/converters.js on lines 33..38
                src/todolistconverters.js on lines 31..36

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

                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

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

                        if ( !consumable.test( data.item, 'insert' ) ||
                            !consumable.test( data.item, 'attribute:listType' ) ||
                            !consumable.test( data.item, 'attribute:listIndent' )
                        ) {
                            return;
                Severity: Major
                Found in src/converters.js and 2 other locations - About 1 hr to fix
                src/todolistconverters.js on lines 31..36
                src/todolistconverters.js on lines 75..80

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

                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

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

                        if ( !consumable.test( data.item, 'insert' ) ||
                            !consumable.test( data.item, 'attribute:listType' ) ||
                            !consumable.test( data.item, 'attribute:listIndent' )
                        ) {
                            return;
                Severity: Major
                Found in src/todolistconverters.js and 2 other locations - About 1 hr to fix
                src/converters.js on lines 33..38
                src/todolistconverters.js on lines 75..80

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

                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 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
                      Severity
                      Category
                      Status
                      Source
                      Language