ckeditor/ckeditor5-utils

View on GitHub

Showing 43 of 49 total issues

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

    set( name, value ) {
        // If the first parameter is an Object, iterate over its properties.
        if ( isObject( name ) ) {
            Object.keys( name ).forEach( property => {
                this.set( property, name[ property ] );
Severity: Minor
Found in src/observablemixin.js - About 1 hr to fix

    Function stopListening has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        stopListening( emitter, event, callback ) {
            const emitters = this[ _listeningTo ];
            let emitterId = emitter && _getEmitterId( emitter );
            const emitterInfo = emitters && emitterId && emitters[ emitterId ];
            const eventCallbacks = emitterInfo && event && emitterInfo.callbacks[ event ];
    Severity: Minor
    Found in src/emittermixin.js - About 1 hr to fix

      Function getCode has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      export function getCode( key ) {
          let keyCode;
      
          if ( typeof key == 'string' ) {
              keyCode = keyCodes[ key.toLowerCase() ];
      Severity: Minor
      Found in src/keyboard.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 scrollViewportToShowTarget has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      export function scrollViewportToShowTarget( { target, viewportOffset = 0 } ) {
          const targetWindow = getWindow( target );
          let currentWindow = targetWindow;
          let currentFrame = null;
      
      
      Severity: Minor
      Found in src/dom/scroll.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 getSubNodes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      function getSubNodes( head ) {
          const nodes = [ head ];
      
          // Nodes are stored to prevent infinite looping.
          const subNodes = new Set();
      Severity: Minor
      Found in src/areconnectedthroughproperties.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 bind has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          bind( ...bindProperties ) {
              if ( !bindProperties.length || !isStringArray( bindProperties ) ) {
                  /**
                   * All properties must be strings.
                   *
      Severity: Minor
      Found in src/observablemixin.js - About 1 hr to fix

        Function excludeScrollbarsAndBorders has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            excludeScrollbarsAndBorders() {
                const source = this._source;
                let scrollBarWidth, scrollBarHeight, direction;
        
                if ( isWindow( source ) ) {
        Severity: Minor
        Found in src/dom/rect.js - About 1 hr to fix

          Function generateKnownKeyCodes has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function generateKnownKeyCodes() {
              const keyCodes = {
                  arrowleft: 37,
                  arrowup: 38,
                  arrowright: 39,
          Severity: Minor
          Found in src/keyboard.js - About 1 hr to fix

            Function _setToTarget has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                _setToTarget( target, name, value, isDefine = false ) {
                    // In case of an object, iterate through it and call `_setToTarget` again for each property.
                    if ( isPlainObject( name ) ) {
                        this._setObjectToTarget( target, name, isDefine );
            
            
            Severity: Minor
            Found in src/config.js - About 55 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 createEventNamespace has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            function createEventNamespace( source, eventName ) {
                const events = getEvents( source );
            
                // First, check if the event we want to add to the structure already exists.
                if ( events[ eventName ] ) {
            Severity: Minor
            Found in src/emittermixin.js - About 55 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 getOptimalPosition has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            export function getOptimalPosition( { element, target, positions, limiter, fitInViewport } ) {
                // If the {@link module:utils/dom/position~Options#target} is a function, use what it returns.
                // https://github.com/ckeditor/ckeditor5-utils/issues/157
                if ( isFunction( target ) ) {
                    target = target();
            Severity: Minor
            Found in src/dom/position.js - About 55 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 set has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                set( name, value ) {
                    // If the first parameter is an Object, iterate over its properties.
                    if ( isObject( name ) ) {
                        Object.keys( name ).forEach( property => {
                            this.set( property, name[ property ] );
            Severity: Minor
            Found in src/observablemixin.js - About 55 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 _translate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export function _translate( language, message, quantity = 1 ) {
                if ( typeof quantity !== 'number' ) {
                    /**
                     * An incorrect value was passed to the translation function. This was probably caused
                     * by an incorrect message interpolation of a plural form. Note that for messages supporting plural forms
            Severity: Minor
            Found in src/translation-service.js - About 45 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 remove has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                remove( subject ) {
                    let index, id, item;
                    let itemDoesNotExist = false;
                    const idProperty = this._idProperty;
            
            
            Severity: Minor
            Found in src/collection.js - About 45 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 createElement has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export default function createElement( doc, name, attributes = {}, children = [] ) {
                const namespace = attributes && attributes.xmlns;
                const element = namespace ? doc.createElementNS( namespace, name ) : doc.createElement( name );
            
                for ( const key in attributes ) {
            Severity: Minor
            Found in src/dom/createelement.js - About 45 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 constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                constructor( source ) {
                    const isSourceRange = isRange( source );
            
                    /**
                     * The object this rect is for.
            Severity: Minor
            Found in src/dom/rect.js - About 45 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 scrollWindowToShowRect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            function scrollWindowToShowRect( window, rect, viewportOffset ) {
                const targetShiftedDownRect = rect.clone().moveBy( 0, viewportOffset );
                const targetShiftedUpRect = rect.clone().moveBy( 0, -viewportOffset );
                const viewportRect = new Rect( window ).excludeScrollbarsAndBorders();
            
            
            Severity: Minor
            Found in src/dom/scroll.js - About 35 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 getDomRangeRects has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                static getDomRangeRects( range ) {
                    const rects = [];
                    // Safari does not iterate over ClientRectList using for...of loop.
                    const clientRects = Array.from( range.getClientRects() );
            
            
            Severity: Minor
            Found in src/dom/rect.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 _getItemIdBeforeAdding has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                _getItemIdBeforeAdding( item ) {
                    const idProperty = this._idProperty;
                    let itemId;
            
                    if ( ( idProperty in item ) ) {
            Severity: Minor
            Found in src/collection.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 removeCallback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            function removeCallback( emitter, event, callback ) {
                const lists = getCallbacksListsForNamespace( emitter, event );
            
                for ( const callbacks of lists ) {
                    for ( let i = 0; i < callbacks.length; i++ ) {
            Severity: Minor
            Found in src/emittermixin.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