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,
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) {
- Read upRead up
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();
- Read upRead up
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) {
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) {
- Read upRead up
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
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
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
- Read upRead up
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;
- Read upRead up
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);
Avoid too many return
statements within this function. Open
return elementPropertyAccessor;