ckeditor/ckeditor5-engine

View on GitHub

Showing 564 of 564 total issues

DomConverter has 35 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class DomConverter {
    /**
     * Creates DOM converter.
     *
     * @param {module:engine/view/document~Document} document The view document instance.
Severity: Minor
Found in src/view/domconverter.js - About 4 hrs to fix

    Range has 35 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class Range {
        /**
         * Creates a range spanning from `start` position to `end` position.
         *
         * @param {module:engine/model/position~Position} start Start position.
    Severity: Minor
    Found in src/model/range.js - About 4 hrs to fix

      Function viewToDom has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          viewToDom( viewNode, domDocument, options = {} ) {
              if ( viewNode.is( 'text' ) ) {
                  const textData = this._processDataFromViewText( viewNode );
      
                  return domDocument.createTextNode( textData );
      Severity: Minor
      Found in src/view/domconverter.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 _getSurroundingAttributes has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          _getSurroundingAttributes() {
              const position = this.getFirstPosition();
              const schema = this._model.schema;
      
              let attrs = null;
      Severity: Minor
      Found in src/model/documentselection.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

      File range.js has 348 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/range.js - About 4 hrs to fix

        DocumentSelection has 34 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export default class DocumentSelection {
            /**
             * 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.
        Severity: Minor
        Found in src/model/documentselection.js - About 4 hrs to fix

          Element has 34 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export default class Element extends Node {
              /**
               * Creates a view element.
               *
               * Attributes can be passed in various formats:
          Severity: Minor
          Found in src/view/element.js - About 4 hrs to fix

            Function bufferOperation has a Cognitive Complexity of 29 (exceeds 5 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: Minor
            Found in src/model/differ.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 tryFixingNonCollapsedRage has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

            function tryFixingNonCollapsedRage( range, schema ) {
                const start = range.start;
                const end = range.end;
            
                const isTextAllowedOnStart = schema.checkChild( start, '$text' );
            Severity: Minor
            Found in src/model/utils/selection-post-fixer.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 updateRelation has 102 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                updateRelation( opA, opB ) {
                    // The use of relations is described in a bigger detail in transformation functions.
                    //
                    // In brief, this function, for specified pairs of operation types, checks how positions defined in those operations relate.
                    // Then those relations are saved. For example, for two move operations, it is saved if one of those operations target
            Severity: Major
            Found in src/model/operation/transform.js - About 4 hrs to fix

              Function getChanges has 102 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  getChanges( options = { includeChangesInGraveyard: false } ) {
                      // If there are cached changes, just return them instead of calculating changes again.
                      if ( this._cachedChanges ) {
                          if ( options.includeChangesInGraveyard ) {
                              return this._cachedChangesWithGraveyard.slice();
              Severity: Major
              Found in src/model/differ.js - About 4 hrs to fix

                Consider simplifying this complex logical expression.
                Open

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

                  Function domPositionToView has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                  Open

                      domPositionToView( domParent, domOffset ) {
                          if ( this.isBlockFiller( domParent, this.blockFillerMode ) ) {
                              return this.domPositionToView( domParent.parentNode, indexOf( domParent ) );
                          }
                  
                  
                  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

                  Function handleBackwardMovement has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                  Open

                      handleBackwardMovement( position, data ) {
                          const attribute = this.attribute;
                  
                          // When the gravity is already overridden...
                          if ( this._isGravityOverridden ) {
                  Severity: Minor
                  Found in src/utils/bindtwostepcarettoattribute.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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                              if ( item.offsetInText === 0 ) {
                                  if ( this.direction == 'backward' && !( this.boundaries && this.boundaries.start.isEqual( this.position ) ) ) {
                                      nextPosition = Position._createBefore( item.textNode );
                                      // When we change nextPosition of returned value we need also update walker current position.
                                      this.position = nextPosition;
                  Severity: Major
                  Found in src/view/treewalker.js and 1 other location - About 3 hrs to fix
                  src/view/treewalker.js on lines 422..430

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

                  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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                              if ( item.offsetInText + item.data.length == item.textNode.data.length ) {
                                  if ( this.direction == 'forward' && !( this.boundaries && this.boundaries.end.isEqual( this.position ) ) ) {
                                      nextPosition = Position._createAfter( item.textNode );
                                      // When we change nextPosition of returned value we need also update walker current position.
                                      this.position = nextPosition;
                  Severity: Major
                  Found in src/view/treewalker.js and 1 other location - About 3 hrs to fix
                  src/view/treewalker.js on lines 433..441

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

                  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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  function isAtEndBoundary( position, attribute ) {
                      const { nodeBefore, nodeAfter } = position;
                      const isAttrBefore = nodeBefore ? nodeBefore.hasAttribute( attribute ) : false;
                      const isAttrAfter = nodeAfter ? nodeAfter.hasAttribute( attribute ) : false;
                  
                  
                  Severity: Major
                  Found in src/utils/bindtwostepcarettoattribute.js and 1 other location - About 3 hrs to fix
                  src/utils/bindtwostepcarettoattribute.js on lines 560..566

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

                  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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      getCommonAncestor( node, options = {} ) {
                          const ancestorsA = this.getAncestors( options );
                          const ancestorsB = node.getAncestors( options );
                  
                          let i = 0;
                  Severity: Major
                  Found in src/view/node.js and 1 other location - About 3 hrs to fix
                  src/model/node.js on lines 258..269

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

                  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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  function isAtStartBoundary( position, attribute ) {
                      const { nodeBefore, nodeAfter } = position;
                      const isAttrBefore = nodeBefore ? nodeBefore.hasAttribute( attribute ) : false;
                      const isAttrAfter = nodeAfter ? nodeAfter.hasAttribute( attribute ) : false;
                  
                  
                  Severity: Major
                  Found in src/utils/bindtwostepcarettoattribute.js and 1 other location - About 3 hrs to fix
                  src/utils/bindtwostepcarettoattribute.js on lines 570..576

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

                  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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      getCommonAncestor( node, options = {} ) {
                          const ancestorsA = this.getAncestors( options );
                          const ancestorsB = node.getAncestors( options );
                  
                          let i = 0;
                  Severity: Major
                  Found in src/model/node.js and 1 other location - About 3 hrs to fix
                  src/view/node.js on lines 189..200

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language