BookStackApp/BookStack

View on GitHub
resources/js/wysiwyg/ui/framework/manager.ts

Summary

Maintainability
B
7 hrs
Test Coverage

EditorUIManager has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

export class EditorUIManager {

    protected modalDefinitionsByKey: Record<string, EditorFormModalDefinition> = {};
    protected activeModalsByKey: Record<string, EditorFormModal> = {};
    protected decoratorConstructorsByType: Record<string, typeof EditorDecorator> = {};
Severity: Minor
Found in resources/js/wysiwyg/ui/framework/manager.ts - About 2 hrs to fix

    Function updateContextToolbars has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        protected updateContextToolbars(update: EditorUiStateUpdate): void {
            for (let i = this.activeContextToolbars.length - 1; i >= 0; i--) {
                const toolbar = this.activeContextToolbars[i];
                toolbar.destroy();
                this.activeContextToolbars.splice(i, 1);
    Severity: Minor
    Found in resources/js/wysiwyg/ui/framework/manager.ts - 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 updateContextToolbars has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected updateContextToolbars(update: EditorUiStateUpdate): void {
            for (let i = this.activeContextToolbars.length - 1; i >= 0; i--) {
                const toolbar = this.activeContextToolbars[i];
                toolbar.destroy();
                this.activeContextToolbars.splice(i, 1);
    Severity: Minor
    Found in resources/js/wysiwyg/ui/framework/manager.ts - About 1 hr to fix

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

          protected setupEditor(editor: LexicalEditor) {
              // Register our DOM decorate listener with the editor
              const domDecorateListener: DecoratorListener<EditorDecoratorAdapter> = (decorators: Record<NodeKey, EditorDecoratorAdapter>) => {
                  editor.getEditorState().read(() => {
                      const keys = Object.keys(decorators);
      Severity: Minor
      Found in resources/js/wysiwyg/ui/framework/manager.ts - 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

      There are no issues that match your filters.

      Category
      Status