cyclejs/cycle-core

View on GitHub
dom/src/EventDelegator.ts

Summary

Maintainability
D
2 days
Test Coverage

File EventDelegator.ts has 530 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import xs, {Stream, Subscription} from 'xstream';
import {ScopeChecker} from './ScopeChecker';
import {IsolateModule} from './IsolateModule';
import {getSelectors, isEqualNamespace} from './utils';
import {ElementFinder} from './ElementFinder';
Severity: Major
Found in dom/src/EventDelegator.ts - About 1 day to fix

    Function onEvent has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private onEvent(
        eventType: string,
        event: Event,
        passive: boolean,
        bubbles = true
    Severity: Major
    Found in dom/src/EventDelegator.ts - About 2 hrs to fix

      Function addEventListener has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public addEventListener(
          eventType: string,
          namespace: Array<Scope>,
          options: EventsFnOptions,
          bubbles?: boolean
      Severity: Major
      Found in dom/src/EventDelegator.ts - About 2 hrs to fix

        Function addEventListener has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          public addEventListener(
            eventType: string,
            namespace: Array<Scope>,
            options: EventsFnOptions,
            bubbles?: boolean
        Severity: Minor
        Found in dom/src/EventDelegator.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 bubble has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private bubble(
            eventType: string,
            elm: Element,
            rootElement: Element | undefined,
            event: CycleDOMEvent,
        Severity: Minor
        Found in dom/src/EventDelegator.ts - About 1 hr to fix

          Function setupNonBubblingListener has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private setupNonBubblingListener(
              input: NonBubblingMeta
            ): void {
              const [_, eventType, elementFinder, destination] = input;
              if (!this.origin) {
          Severity: Minor
          Found in dom/src/EventDelegator.ts - About 1 hr to fix

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

              public removeElement(element: Element, namespace?: Array<Scope>): void {
                if (namespace !== undefined) {
                  this.virtualListeners.delete(namespace);
                }
                const toRemove: Array<[string, Element]> = [];
            Severity: Minor
            Found in dom/src/EventDelegator.ts - About 1 hr to fix

              Function bubble has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                private bubble(
                  eventType: string,
                  elm: Element,
                  rootElement: Element | undefined,
                  event: CycleDOMEvent,
              Severity: Minor
              Found in dom/src/EventDelegator.ts - 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 getVirtualListeners has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                private getVirtualListeners(
                  eventType: string,
                  namespace: Array<Scope>,
                  exact = false,
                  max?: number
              Severity: Minor
              Found in dom/src/EventDelegator.ts - 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

              Consider simplifying this complex logical expression.
              Open

                      if (
                        !event.propagationHasBeenStopped &&
                        dest.scopeChecker.isDirectlyInScope(elm) &&
                        ((sel !== '' && elm.matches(sel)) ||
                          (sel === '' && elm === rootElement))
              Severity: Major
              Found in dom/src/EventDelegator.ts - About 40 mins to fix

                Function removeElement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  public removeElement(element: Element, namespace?: Array<Scope>): void {
                    if (namespace !== undefined) {
                      this.virtualListeners.delete(namespace);
                    }
                    const toRemove: Array<[string, Element]> = [];
                Severity: Minor
                Found in dom/src/EventDelegator.ts - 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

                There are no issues that match your filters.

                Category
                Status