ckeditor/ckeditor5-engine

View on GitHub

Showing 564 of 564 total issues

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

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

            getNodeByPath( relativePath ) {
                let node = this; // eslint-disable-line consistent-this
        
                for ( const index of relativePath ) {
                    node = node.getChild( node.offsetToIndex( index ) );
        Severity: Major
        Found in src/model/documentfragment.js and 1 other location - About 1 hr to fix
        src/model/element.js on lines 202..210

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

        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

            getNodeByPath( relativePath ) {
                let node = this; // eslint-disable-line consistent-this
        
                for ( const index of relativePath ) {
                    node = node.getChild( node.offsetToIndex( index ) );
        Severity: Major
        Found in src/model/element.js and 1 other location - About 1 hr to fix
        src/model/documentfragment.js on lines 200..208

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

        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 _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

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

                          if ( a.splitPosition.hasSameParentAs( b.sourcePosition ) && a.splitPosition.offset <= b.sourcePosition.offset ) {
                              a.howMany -= b.howMany;
                          }
                  Severity: Major
                  Found in src/model/operation/transform.js and 2 other locations - About 1 hr to fix
                  src/model/operation/transform.js on lines 2127..2129
                  src/model/operation/transform.js on lines 2162..2164

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

                  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 3 locations. Consider refactoring.
                  Open

                          if ( a.splitPosition.hasSameParentAs( b.targetPosition ) && a.splitPosition.offset < b.targetPosition.offset ) {
                              a.howMany += b.howMany;
                          }
                  Severity: Major
                  Found in src/model/operation/transform.js and 2 other locations - About 1 hr to fix
                  src/model/operation/transform.js on lines 2158..2160
                  src/model/operation/transform.js on lines 2162..2164

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

                  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 3 locations. Consider refactoring.
                  Open

                          if ( a.splitPosition.hasSameParentAs( b.targetPosition ) && a.splitPosition.offset < b.targetPosition.offset ) {
                              a.howMany += b.howMany;
                          }
                  Severity: Major
                  Found in src/model/operation/transform.js and 2 other locations - About 1 hr to fix
                  src/model/operation/transform.js on lines 2127..2129
                  src/model/operation/transform.js on lines 2158..2160

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

                  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

                  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