ckeditor/ckeditor5-engine

View on GitHub

Showing 564 of 564 total issues

Function transformSets has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function transformSets( operationsA, operationsB, options ) {
    // Create new arrays so the originally passed arguments are not changed.
    // No need to clone operations, they are cloned as they are transformed.
    operationsA = operationsA.slice();
    operationsB = operationsB.slice();
Severity: Minor
Found in src/model/operation/transform.js - About 1 hr to fix

    Function matchClasses has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    function matchClasses( patterns, element ) {
        const match = [];
    
        for ( const pattern of patterns ) {
            if ( pattern instanceof RegExp ) {
    Severity: Minor
    Found in src/view/matcher.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 matchAttributes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    function matchAttributes( patterns, element ) {
        const match = [];
    
        for ( const name in patterns ) {
            const pattern = patterns[ name ];
    Severity: Minor
    Found in src/view/matcher.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 _breakAttributes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        _breakAttributes( position, forceSplitText = false ) {
            const positionOffset = position.offset;
            const positionParent = position.parent;
    
            // If position is placed inside EmptyElement - throw an exception as we cannot break inside.
    Severity: Minor
    Found in src/view/downcastwriter.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 isEqual has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        isEqual( otherSelection ) {
            if ( this.isFake != otherSelection.isFake ) {
                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 _normalizeNodes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    export function _normalizeNodes( nodes ) {
        const normalized = [];
    
        if ( !( nodes instanceof Array ) ) {
            nodes = [ nodes ];
    Severity: Minor
    Found in src/model/operation/utils.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 _getTransformedByDeletion has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        _getTransformedByDeletion( deletePosition, howMany ) {
            const transformed = Position._createAt( this );
    
            // This position can't be affected if deletion was in a different root.
            if ( this.root != deletePosition.root ) {
    Severity: Minor
    Found in src/model/position.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 createViewElementFromDefinition has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    function createViewElementFromDefinition( viewElementDefinition, viewWriter, viewElementType ) {
        if ( typeof viewElementDefinition == 'string' ) {
            // If `viewElementDefinition` is given as a `String`, normalize it to an object with `name` property.
            viewElementDefinition = { name: viewElementDefinition };
        }
    Severity: Minor
    Found in src/conversion/downcasthelpers.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

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

                } else {
                    if ( data.item.is( 'selection' ) ) {
                        viewWriter.wrap( viewSelection.getFirstRange(), viewElement );
                    } else {
                        viewWriter.wrap( conversionApi.mapper.toViewRange( data.range ), viewElement );
    docs/_snippets/framework/extending-content-add-unsafe-link-class.js on lines 17..23

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

    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

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

                if ( data.attributeNewValue.match( /http:\/\// ) ) {
                    if ( data.item.is( 'selection' ) ) {
                        viewWriter.wrap( viewSelection.getFirstRange(), viewElement );
                    } else {
                        viewWriter.wrap( conversionApi.mapper.toViewRange( data.range ), viewElement );
    docs/_snippets/framework/extending-content-add-external-link-target.js on lines 23..29

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

    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

        toJSON() {
            const json = super.toJSON();
    
            json.sourcePosition = this.sourcePosition.toJSON();
            json.targetPosition = this.targetPosition.toJSON();
    Severity: Major
    Found in src/model/operation/moveoperation.js and 1 other location - About 1 hr to fix
    src/model/operation/insertoperation.js on lines 141..148

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

    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

        * getItems( options = {} ) {
            options.boundaries = this;
            options.ignoreElementEnd = true;
    
            const treeWalker = new TreeWalker( options );
    Severity: Major
    Found in src/model/range.js and 1 other location - About 1 hr to fix
    src/view/range.js on lines 400..409

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

    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

        toJSON() {
            const json = super.toJSON();
    
            json.position = this.position.toJSON();
            json.nodes = this.nodes.toJSON();
    Severity: Major
    Found in src/model/operation/insertoperation.js and 1 other location - About 1 hr to fix
    src/model/operation/moveoperation.js on lines 174..181

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

    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

        * getItems( options = {} ) {
            options.boundaries = this;
            options.ignoreElementEnd = true;
    
            const treeWalker = new TreeWalker( options );
    Severity: Major
    Found in src/view/range.js and 1 other location - About 1 hr to fix
    src/model/range.js on lines 393..402

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

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

        _mergeSiblingsOf( node, context ) {
            if ( !( node instanceof Element ) ) {
                return;
            }
    
    
    Severity: Minor
    Found in src/model/utils/insertcontent.js - About 1 hr to fix

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

          isAfter( node ) {
              // Given node is not before this node if they are same.
              if ( this == node ) {
                  return false;
              }
      Severity: Major
      Found in src/model/node.js and 1 other location - About 1 hr to fix
      src/view/node.js on lines 244..257

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

      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

          isAfter( node ) {
              // Given node is not before this node if they are same.
              if ( this == node ) {
                  return false;
              }
      Severity: Major
      Found in src/view/node.js and 1 other location - About 1 hr to fix
      src/model/node.js on lines 313..326

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

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

          _unwrapChildren( parent, startOffset, endOffset, unwrapElement ) {
              let i = startOffset;
              const unwrapPositions = [];
      
              // Iterate over each element between provided offsets inside parent.
      Severity: Minor
      Found in src/view/downcastwriter.js - About 1 hr to fix

        Function insert has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            insert( item, itemOrPosition, offset = 0 ) {
                this._assertWriterUsedCorrectly();
        
                if ( item instanceof Text && item.data == '' ) {
                    return;
        Severity: Minor
        Found in src/model/writer.js - About 1 hr to fix

          Function _getTransformedByMove has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _getTransformedByMove( sourcePosition, targetPosition, howMany, spread = false ) {
                  // Special case for transforming a collapsed range. Just transform it like a position.
                  if ( this.isCollapsed ) {
                      const newPos = this.start._getTransformedByMove( sourcePosition, targetPosition, howMany );
          
          
          Severity: Minor
          Found in src/model/range.js - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language