ckeditor/ckeditor5-utils

View on GitHub

Showing 49 of 49 total issues

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

function scrollAncestorsToShowRect( parent, getRect ) {
    const parentWindow = getWindow( parent );
    let parentRect, targetRect;

    while ( parent != parentWindow.document.body ) {
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 addItem has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        const addItem = ( evt, externalItem, index ) => {
            const isExternalBoundToThis = externalCollection._bindToCollection == this;
            const externalItemBound = externalCollection._bindToInternalToExternalMap.get( externalItem );

            // If an external collection is bound to this collection, which makes it a 2–way binding,
Severity: Minor
Found in src/collection.js - About 1 hr to fix

    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

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

              export function isHighSurrogateHalf( character ) {
                  return !!character && character.length == 1 && /[\ud800-\udbff]/.test( character );
              }
              Severity: Minor
              Found in src/unicode.js and 1 other location - About 35 mins to fix
              src/unicode.js on lines 44..46

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

              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

              export function isLowSurrogateHalf( character ) {
                  return !!character && character.length == 1 && /[\udc00-\udfff]/.test( character );
              }
              Severity: Minor
              Found in src/unicode.js and 1 other location - About 35 mins to fix
              src/unicode.js on lines 31..33

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

              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

              Severity
              Category
              Status
              Source
              Language