ckeditor/ckeditor5-engine

View on GitHub

Showing 564 of 564 total issues

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

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

        if ( a.splitPosition.hasSameParentAs( b.position ) && a.splitPosition.offset < b.position.offset ) {
            a.howMany += b.howMany;
        }
    Severity: Major
    Found in src/model/operation/transform.js and 1 other location - About 1 hr to fix
    src/model/operation/transform.js on lines 2299..2301

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

    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

                for ( let i = refIndex - 1; true; i++ ) {
                    if ( ranges[ i ].end.isEqual( result.start ) ) {
                        result.start = Position._createAt( ranges[ i ].start );
                    } else {
                        // If ranges are not starting/ending at the same position there is no point in looking further.
    Severity: Major
    Found in src/model/range.js and 1 other location - About 1 hr to fix
    src/model/range.js on lines 960..967

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

    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 ( a.splitPosition.hasSameParentAs( b.splitPosition ) && a.splitPosition.offset < b.splitPosition.offset ) {
            a.howMany -= b.howMany;
        }
    Severity: Major
    Found in src/model/operation/transform.js and 1 other location - About 1 hr to fix
    src/model/operation/transform.js on lines 1977..1979

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

    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

            for ( let i = refIndex + 1; i < ranges.length; i++ ) {
                if ( ranges[ i ].start.isEqual( result.end ) ) {
                    result.end = Position._createAt( ranges[ i ].end );
                } else {
                    // If ranges are not starting/ending at the same position there is no point in looking further.
    Severity: Major
    Found in src/model/range.js and 1 other location - About 1 hr to fix
    src/model/range.js on lines 948..955

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

    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 _wrapChildren has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        _wrapChildren( parent, startOffset, endOffset, wrapElement ) {
            let i = startOffset;
            const wrapPositions = [];
    
            while ( i < endOffset ) {
    Severity: Minor
    Found in src/view/downcastwriter.js - About 1 hr to fix

      Function setTo has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          setTo( selectable, placeOrOffset, options ) {
              if ( selectable === null ) {
                  this._setRanges( [] );
                  this._setFakeOptions( placeOrOffset );
              } else if ( selectable instanceof Selection || selectable instanceof DocumentSelection ) {
      Severity: Minor
      Found in src/view/selection.js - About 1 hr to fix

        Function constructor has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            constructor( doc ) {
                super();
        
                // List of selection markers.
                // Marker is a selection marker when selection range is inside the marker range.
        Severity: Minor
        Found in src/model/documentselection.js - About 1 hr to fix

          Function tryFixingNonCollapsedRage has 37 lines of code (exceeds 25 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 1 hr to fix

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

                        if ( newAttribute.key == 'class' ) {
                            const classes = Array.isArray( newAttribute.value ) ? newAttribute.value : [ newAttribute.value ];
            
                            for ( const className of classes ) {
                                viewWriter.addClass( className, viewElement );
            Severity: Major
            Found in src/conversion/downcasthelpers.js and 1 other location - About 1 hr to fix
            src/conversion/downcasthelpers.js on lines 849..863

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

            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 ( oldAttribute.key == 'class' ) {
                            const classes = Array.isArray( oldAttribute.value ) ? oldAttribute.value : [ oldAttribute.value ];
            
                            for ( const className of classes ) {
                                viewWriter.removeClass( className, viewElement );
            Severity: Major
            Found in src/conversion/downcasthelpers.js and 1 other location - About 1 hr to fix
            src/conversion/downcasthelpers.js on lines 868..882

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

            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 viewPositionToDom has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                viewPositionToDom( viewPosition ) {
                    const viewParent = viewPosition.parent;
            
                    if ( viewParent.is( 'text' ) ) {
                        const domParent = this.findCorrespondingDomText( viewParent );
            Severity: Minor
            Found in src/view/domconverter.js - About 1 hr to fix

              Function constructor has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  constructor( model, stylesProcessor ) {
                      /**
                       * Editor model.
                       *
                       * @readonly
              Severity: Minor
              Found in src/controller/editingcontroller.js - About 1 hr to fix

                Function attachDomRoot has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    attachDomRoot( domRoot, name = 'main' ) {
                        const viewRoot = this.document.getRoot( name );
                
                        // Set view root name the same as DOM root tag name.
                        viewRoot._name = domRoot.tagName.toLowerCase();
                Severity: Minor
                Found in src/view/view.js - About 1 hr to fix

                  Function isTouching has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      isTouching( otherPosition ) {
                          let left = null;
                          let right = null;
                          const compare = this.compareWith( otherPosition );
                  
                  
                  Severity: Minor
                  Found in src/model/position.js - About 1 hr to fix

                    Function insertContent has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export default function insertContent( model, content, selectable, placeOrOffset ) {
                        return model.change( writer => {
                            let selection;
                    
                            if ( !selectable ) {
                    Severity: Minor
                    Found in src/model/utils/insertcontent.js - About 1 hr to fix

                      Function prepareToElementConverter has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function prepareToElementConverter( config ) {
                          const matcher = config.view ? new Matcher( config.view ) : null;
                      
                          return ( evt, data, conversionApi ) => {
                              let match = {};
                      Severity: Minor
                      Found in src/conversion/upcasthelpers.js - About 1 hr to fix

                        Function isSimilar has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                            isSimilar( otherSelection ) {
                                if ( this.isBackward != otherSelection.isBackward ) {
                                    return false;
                                }
                        
                        
                        Severity: Minor
                        Found in src/view/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 _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 constructor has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                            constructor( options = {} ) {
                                if ( !options.boundaries && !options.startPosition ) {
                                    /**
                                     * Neither boundaries nor starting position of a `TreeWalker` have been defined.
                                     *
                        Severity: Minor
                        Found in src/model/treewalker.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

                        Severity
                        Category
                        Status
                        Source
                        Language