ckeditor/ckeditor5-engine

View on GitHub

Showing 564 of 564 total issues

Function ConvertDivAttributes has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function ConvertDivAttributes( editor ) {
    // Allow <div> elements in the model.
    editor.model.schema.register( 'div', {
        allowWhere: '$block',
        allowContentOf: '$root'
Severity: Minor
Found in docs/_snippets/framework/extending-content-allow-div-attributes.js - About 1 hr to fix

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

            if ( backward ) {
                const step = backward.next();
    
                if ( !step.done ) {
                    done = false;
    Severity: Major
    Found in src/model/schema.js and 1 other location - About 1 hr to fix
    src/model/schema.js on lines 1607..1617

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

    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 ( forward ) {
                const step = forward.next();
    
                if ( !step.done ) {
                    done = false;
    Severity: Major
    Found in src/model/schema.js and 1 other location - About 1 hr to fix
    src/model/schema.js on lines 1595..1605

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

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

    export function parse( data, options = {} ) {
        const viewDocument = new ViewDocument( new StylesProcessor() );
    
        options.order = options.order || [];
        const rangeParser = new RangeParser( {
    Severity: Minor
    Found in src/dev-utils/view.js - About 1 hr to fix

      Function isSimilar has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          isSimilar( otherElement ) {
              if ( !( otherElement instanceof Element ) ) {
                  return false;
              }
      
      
      Severity: Minor
      Found in src/view/element.js - About 1 hr to fix

        Function createViewElementFromDefinition has 32 lines of code (exceeds 25 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

          Function _stringifyTextRanges has a Cognitive Complexity of 11 (exceeds 5 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

          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 11 (exceeds 5 allowed). Consider refactoring.
          Open

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

          Function parse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          export function parse( data, schema, options = {} ) {
              const mapper = new Mapper();
          
              // Replace not accepted by XML `$text` tag name by valid one `model-text-with-attributes`.
              data = data.replace( new RegExp( '\\$text', 'g' ), 'model-text-with-attributes' );
          Severity: Minor
          Found in src/dev-utils/model.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 _checkAndSplitToAllowedPosition has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              _checkAndSplitToAllowedPosition( node ) {
                  const allowedIn = this._getAllowedIn( node, this.position.parent );
          
                  if ( !allowedIn ) {
                      return false;
          Severity: Minor
          Found in src/model/utils/insertcontent.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 _set has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              _set( markerOrName, range, managedUsingOperations = false, affectsData = false ) {
                  const markerName = markerOrName instanceof Marker ? markerOrName.name : markerOrName;
                  const oldMarker = this._markers.get( markerName );
          
                  if ( oldMarker ) {
          Severity: Minor
          Found in src/model/markercollection.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 getSelectedBlocks has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              * getSelectedBlocks() {
                  const visited = new WeakSet();
          
                  for ( const range of this.getRanges() ) {
                      // Get start block of range in case of a collapsed range.
          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 modifySelection has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function modifySelection( model, selection, options = {} ) {
              const schema = model.schema;
              const isForward = options.direction != 'backward';
              const unit = options.unit ? options.unit : 'character';
          
          
          Severity: Minor
          Found in src/model/utils/modifyselection.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 checkAttributeInSelection has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              checkAttributeInSelection( selection, attribute ) {
                  if ( selection.isCollapsed ) {
                      const firstPosition = selection.getFirstPosition();
                      const context = [
                          ...firstPosition.getAncestors(),
          Severity: Minor
          Found in src/model/schema.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 combineWalkers has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function* combineWalkers( backward, forward ) {
              let done = false;
          
              while ( !done ) {
                  done = true;
          Severity: Minor
          Found in src/model/schema.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 getNearestSelectionRange has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              getNearestSelectionRange( position, direction = 'both' ) {
                  // Return collapsed range if provided position is valid.
                  if ( this.checkChild( position, '$text' ) ) {
                      return new Range( position );
                  }
          Severity: Minor
          Found in src/model/schema.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 _unwrapAttributeElement has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _unwrapAttributeElement( wrapper, toUnwrap ) {
                  if ( !canBeJoined( wrapper, toUnwrap ) ) {
                      return false;
                  }
          
          
          Severity: Minor
          Found in src/view/downcastwriter.js - About 1 hr to fix

            Function _getAttributesDiff has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _getAttributesDiff( range, oldAttributes, newAttributes ) {
                    // Results holder.
                    const diffs = [];
            
                    // Clone new attributes as we will be performing changes on this object.
            Severity: Minor
            Found in src/model/differ.js - About 1 hr to fix

              Function _createFromRanges has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  static _createFromRanges( ranges ) {
                      if ( ranges.length === 0 ) {
                          /**
                           * At least one range has to be passed to
                           * {@link module:engine/model/range~Range._createFromRanges `Range._createFromRanges()`}.
              Severity: Minor
              Found in src/model/range.js - About 1 hr to fix

                Function jumpOverUiElement has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function jumpOverUiElement( evt, data, domConverter ) {
                    if ( data.keyCode == keyCodes.arrowright ) {
                        const domSelection = data.domTarget.ownerDocument.defaultView.getSelection();
                        const domSelectionCollapsed = domSelection.rangeCount == 1 && domSelection.getRangeAt( 0 ).collapsed;
                
                
                Severity: Minor
                Found in src/view/uielement.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language