aurelia/aurelia

View on GitHub
packages/runtime-html/src/observation/observer-locator.ts

Summary

Maintainability
D
1 day
Test Coverage
B
85%

File observer-locator.ts has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { createImplementationRegister, createLookup, emptyObject, IServiceLocator, isString, resolve } from '@aurelia/kernel';
import {
  getObserverLookup,
  IDirtyChecker,
  INodeObserverLocator,
Severity: Minor
Found in packages/runtime-html/src/observation/observer-locator.ts - About 2 hrs to fix

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

      public getAccessor(obj: HTMLElement, key: PropertyKey, requestor: IObserverLocator): IAccessor | IObserver {
        if (key in this._globalOverrides || (key in (this._overrides[obj.tagName] ?? emptyObject))) {
          return this.getObserver(obj, key, requestor);
        }
        switch (key) {
    Severity: Minor
    Found in packages/runtime-html/src/observation/observer-locator.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 useConfig has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      public useConfig(nodeNameOrConfig: string | Record<string, Record<string, INodeObserverConfig>>, key?: PropertyKey, eventsConfig?: INodeObserverConfig): void {
        const lookup = this._events;
        let existingMapping: Record<string, INodeObserverConfig>;
        if (isString(nodeNameOrConfig)) {
          existingMapping = lookup[nodeNameOrConfig] ??= createLookup();
    Severity: Minor
    Found in packages/runtime-html/src/observation/observer-locator.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 getAccessor has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public getAccessor(obj: HTMLElement, key: PropertyKey, requestor: IObserverLocator): IAccessor | IObserver {
        if (key in this._globalOverrides || (key in (this._overrides[obj.tagName] ?? emptyObject))) {
          return this.getObserver(obj, key, requestor);
        }
        switch (key) {
    Severity: Minor
    Found in packages/runtime-html/src/observation/observer-locator.ts - About 1 hr to fix

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

        public useConfigGlobal(configOrKey: PropertyKey | Record<string, INodeObserverConfig>, eventsConfig?: INodeObserverConfig): void {
          const lookup = this._globalEvents;
          if (typeof configOrKey === 'object') {
            for (const key in configOrKey) {
              if (lookup[key] == null) {
      Severity: Minor
      Found in packages/runtime-html/src/observation/observer-locator.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 constructor has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public constructor() {
          // todo: atm, platform is required to be resolved too eagerly for the `.handles()` check
          // also a lot of tests assume default availability of observation
          // those 2 assumptions make it not the right time to extract the following line into a
          // default configuration for NodeObserverLocator yet
      Severity: Minor
      Found in packages/runtime-html/src/observation/observer-locator.ts - About 1 hr to fix

        Function getObserver has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public getObserver(el: HTMLElement, key: PropertyKey, requestor: IObserverLocator): IAccessor | IObserver {
            switch (key) {
              case 'class':
                // todo: invalid accessor returned for a get observer call
                //       for now it's a noop observer
        Severity: Minor
        Found in packages/runtime-html/src/observation/observer-locator.ts - About 1 hr to fix

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

            public getObserver(el: HTMLElement, key: PropertyKey, requestor: IObserverLocator): IAccessor | IObserver {
              switch (key) {
                case 'class':
                  // todo: invalid accessor returned for a get observer call
                  //       for now it's a noop observer
          Severity: Minor
          Found in packages/runtime-html/src/observation/observer-locator.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 overrideAccessor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            public overrideAccessor(tagNameOrOverrides: string | Record<string, string[]>, key?: PropertyKey): void {
              let existingTagOverride: Record<string, true> | undefined;
              if (isString(tagNameOrOverrides)) {
                existingTagOverride = this._overrides[tagNameOrOverrides] ??= createLookup();
                existingTagOverride[key as string] = true;
          Severity: Minor
          Found in packages/runtime-html/src/observation/observer-locator.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

          Avoid too many return statements within this function.
          Open

                return new SetterObserver(el as HTMLElement & IIndexable, key as string);
          Severity: Major
          Found in packages/runtime-html/src/observation/observer-locator.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return elementPropertyAccessor;
            Severity: Major
            Found in packages/runtime-html/src/observation/observer-locator.ts - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status