ckeditor/ckeditor5-engine

View on GitHub

Showing 564 of 564 total issues

Avoid too many return statements within this function.
Open

            return [ new NoOperation( 0 ) ];
Severity: Major
Found in src/model/operation/transform.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return len;
    Severity: Major
    Found in src/conversion/mapper.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return [ new NoOperation( a.baseVersion ) ];
      Severity: Major
      Found in src/model/operation/transform.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return [ a ];
        Severity: Major
        Found in src/model/operation/transform.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return this._next();
          Severity: Major
          Found in src/model/treewalker.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

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

              Avoid too many return statements within this function.
              Open

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

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

                    toViewRange( modelRange ) {
                        return new ViewRange( this.toViewPosition( modelRange.start ), this.toViewPosition( modelRange.end ) );
                    }
                Severity: Minor
                Found in src/conversion/mapper.js and 1 other location - About 30 mins to fix
                src/conversion/mapper.js on lines 285..287

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

                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

                    toModelRange( viewRange ) {
                        return new ModelRange( this.toModelPosition( viewRange.start ), this.toModelPosition( viewRange.end ) );
                    }
                Severity: Minor
                Found in src/conversion/mapper.js and 1 other location - About 30 mins to fix
                src/conversion/mapper.js on lines 295..297

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

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

                    _stringifyElementType( element ) {
                        if ( this.showType ) {
                            for ( const type in allowedTypes ) {
                                if ( element instanceof allowedTypes[ type ] ) {
                                    return type;
                Severity: Minor
                Found in src/dev-utils/view.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 change has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    change( callback ) {
                        if ( this.isRenderingInProgress || this._postFixersInProgress ) {
                            /**
                             * Thrown when there is an attempt to make changes to the view tree when it is in incorrect state. This may
                             * cause some unexpected behaviour and inconsistency between the DOM and the view.
                Severity: Minor
                Found in src/view/view.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 getFillerOffset has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function getFillerOffset() {
                    // <b>foo</b> does not need filler.
                    if ( nonUiChildrenCount( this ) ) {
                        return null;
                    }
                Severity: Minor
                Found in src/view/attributeelement.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 match has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    match( ...element ) {
                        for ( const singleElement of element ) {
                            for ( const pattern of this._patterns ) {
                                const match = isElementMatching( singleElement, pattern );
                
                
                Severity: Minor
                Found in src/view/matcher.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 validateNodesToInsert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function validateNodesToInsert( nodes, errorContext ) {
                    for ( const node of nodes ) {
                        if ( !validNodesToInsert.some( ( validNode => node instanceof validNode ) ) ) { // eslint-disable-line no-use-before-define
                            /**
                             * Inserted nodes should be valid to insert. of {@link module:engine/view/attributeelement~AttributeElement AttributeElement},
                Severity: Minor
                Found in src/view/downcastwriter.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 _processDataFromDomText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    _processDataFromDomText( node ) {
                        let data = node.data;
                
                        if ( _hasDomParentOfType( node, this.preElements ) ) {
                            return getDataWithoutFiller( node );
                Severity: Minor
                Found in src/view/domconverter.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 _removeFromClonedElementsGroup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    _removeFromClonedElementsGroup( element ) {
                        // Traverse the element's children recursively to find other attribute elements that also got removed.
                        // The loop is at the beginning so we can make fast returns later in the code.
                        if ( element.is( 'element' ) ) {
                            for ( const child of element.getChildren() ) {
                Severity: Minor
                Found in src/view/downcastwriter.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 _callPostFixers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    _callPostFixers( writer ) {
                        let wasFixed = false;
                
                        do {
                            for ( const callback of this._postFixers ) {
                Severity: Minor
                Found in src/view/document.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 normalizeBorderShorthand has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function normalizeBorderShorthand( string ) {
                    const result = {};
                
                    const parts = getShorthandValues( string );
                
                
                Severity: Minor
                Found in src/view/styles/border.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 _removeAttribute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    _removeAttribute( key ) {
                        this._fireChange( 'attributes', this );
                
                        // Remove class attribute.
                        if ( key == 'class' ) {
                Severity: Minor
                Found in src/view/element.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 _callPostFixers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    _callPostFixers( writer ) {
                        let wasFixed = false;
                
                        do {
                            for ( const callback of this._postFixers ) {
                Severity: Minor
                Found in src/model/document.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

                Severity
                Category
                Status
                Source
                Language