ckeditor/ckeditor5-utils

View on GitHub
src/collection.js

Summary

Maintainability
C
1 day
Test Coverage

Function _setUpBindToBinding has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    _setUpBindToBinding( factory ) {
        const externalCollection = this._bindToCollection;

        // Adds the item to the collection once a change has been done to the external collection.
        //
Severity: Minor
Found in src/collection.js - About 4 hrs 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 _setUpBindToBinding has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _setUpBindToBinding( factory ) {
        const externalCollection = this._bindToCollection;

        // Adds the item to the collection once a change has been done to the external collection.
        //
Severity: Major
Found in src/collection.js - About 2 hrs to fix

    Function remove has 33 lines of code (exceeds 25 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 1 hr to fix

      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 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 _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

        There are no issues that match your filters.

        Category
        Status