ckeditor/ckeditor5-engine

View on GitHub
src/view/renderer.js

Summary

Maintainability
D
3 days
Test Coverage

File renderer.js has 469 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/view/renderer.js - About 7 hrs to fix

    Renderer has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class Renderer {
        /**
         * Creates a renderer instance.
         *
         * @param {module:engine/view/domconverter~DomConverter} domConverter Converter instance.
    Severity: Minor
    Found in src/view/renderer.js - About 2 hrs to fix

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

          render() {
              let inlineFillerPosition;
      
              // Refresh mappings.
              for ( const element of this.markedChildren ) {
      Severity: Minor
      Found in src/view/renderer.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 render has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          render() {
              let inlineFillerPosition;
      
              // Refresh mappings.
              for ( const element of this.markedChildren ) {
      Severity: Minor
      Found in src/view/renderer.js - About 1 hr to fix

        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 _updateChildren has 38 lines of code (exceeds 25 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

          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 markToSync has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              markToSync( type, node ) {
                  if ( type === 'text' ) {
                      if ( this.domConverter.mapViewToDom( node.parent ) ) {
                          this.markedTexts.add( node );
                      }
          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 _updateChildrenMappings has 27 lines of code (exceeds 25 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

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

                _updateText( viewText, options ) {
                    const domText = this.domConverter.findCorrespondingDomText( viewText );
                    const newDomText = this.domConverter.viewToDom( viewText, domText.ownerDocument );
            
                    const actualText = domText.data;
            Severity: Minor
            Found in src/view/renderer.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 _needsInlineFillerAtSelection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                _needsInlineFillerAtSelection() {
                    if ( this.selection.rangeCount != 1 || !this.selection.isCollapsed ) {
                        return false;
                    }
            
            
            Severity: Minor
            Found in src/view/renderer.js - About 35 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 _findReplaceActions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                _findReplaceActions( actions, actualDom, expectedDom ) {
                    // If there is no both 'insert' and 'delete' actions, no need to check for replaced elements.
                    if ( actions.indexOf( 'insert' ) === -1 || actions.indexOf( 'delete' ) === -1 ) {
                        return actions;
                    }
            Severity: Minor
            Found in src/view/renderer.js - About 35 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

            Avoid too many return statements within this function.
            Open

                        return false;
            Severity: Major
            Found in src/view/renderer.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return false;
              Severity: Major
              Found in src/view/renderer.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return true;
                Severity: Major
                Found in src/view/renderer.js - About 30 mins to fix

                  Function _markDescendantTextToSync has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      _markDescendantTextToSync( viewNode ) {
                          if ( !viewNode ) {
                              return;
                          }
                  
                  
                  Severity: Minor
                  Found in src/view/renderer.js - About 25 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 _removeDomSelection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      _removeDomSelection() {
                          for ( const doc of this.domDocuments ) {
                              const domSelection = doc.getSelection();
                  
                              if ( domSelection.rangeCount ) {
                  Severity: Minor
                  Found in src/view/renderer.js - About 25 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 addInlineFiller has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function addInlineFiller( domDocument, domParentOrArray, offset ) {
                      const childNodes = domParentOrArray instanceof Array ? domParentOrArray : domParentOrArray.childNodes;
                      const nodeAfterFiller = childNodes[ offset ];
                  
                      if ( isText( nodeAfterFiller ) ) {
                  Severity: Minor
                  Found in src/view/renderer.js - About 25 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

                  There are no issues that match your filters.

                  Category
                  Status