Function debounce
has 27 lines of code (exceeds 25 allowed). Consider refactoring.
export function debounce<F extends AnyToAnyFnSignature>(fn: F, wait = 10, thisArg?: object): Debounced<F> {
let timeout: number | null = null;
let deferred: Deferred<ReturnType<F>> | null = null;
function debouncedSubject(...args: any[]): void {
Function decorate
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
export function decorate<Args extends any[], Fn extends AnyToAnyFnSignature>(
decorator: (fn: Fn, ...params: Args) => Fn,
...args: Args
) {
return function (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<Fn>): TypedPropertyDescriptor<Fn> {
Function attr
has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
export const attr = <T = string>(config: AttrDescriptor<T> = {}): ESLAttributeDecorator => {
return (target: ESLDomElementTarget, propName: string): any => {
const attrName = buildAttrName(config.name || propName, !!config.dataAttr);
const inheritAttrName = typeof config.inherit === 'string' ? config.inherit : attrName;
Function loadScript
has 27 lines of code (exceeds 25 allowed). Consider refactoring.
export function loadScript(id: string, src: string, attrs: LoadScriptAttributes = {}): Promise<Event> {
return new Promise((resolve, reject) => {
const script: HTMLScriptElement =
(document.getElementById(id) || createScript(id, src, attrs)) as HTMLScriptElement;
const state = script.getAttribute('state');
Function parseKeysPath
has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
const parseKeysPath = (path: string): PathKeyDef[] => {
let start = 0;
const parts: PathKeyDef[] = [];
while (start < path.length) {
Function _onKeyDown
has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
@listen({event: 'keydown', target: document})
protected _onKeyDown(e: KeyboardEvent): void | boolean {
if (!this.current || e.key !== TAB) return;
if (this.current.a11y === 'none' || this.current.a11y === 'autofocus') return;
Identical blocks of code found in 2 locations. Consider refactoring.
public $$on<EType extends keyof ESLListenerEventMap>(
event: EType | ESLListenerDescriptor<EType>,
handler: ESLListenerHandler<ESLListenerEventMap[EType]>
): ESLEventListener[];
packages/esl/src/esl-base-element/core/esl-base-element.ts on lines 72..75 Identical blocks of code found in 2 locations. Consider refactoring.
public $$on<EType extends keyof ESLListenerEventMap>(
event: EType | ESLListenerDescriptor<EType>,
handler: ESLListenerHandler<ESLListenerEventMap[EType]>
): ESLEventListener[];
packages/esl/src/esl-mixin-element/ui/esl-mixin-element.ts on lines 61..64 Similar blocks of code found in 2 locations. Consider refactoring.
public static add(els: Element | Element[], cls: string | null | undefined, locker?: Element): void {
const tokens = CSSClassUtils.splitTokens(cls);
wrap(els).forEach((el) => tokens.forEach((className) => add(el, className, locker)));
}
Similar blocks of code found in 2 locations. Consider refactoring.
public static remove(els: Element | Element[], cls: string | null | undefined, locker?: Element): void {
const tokens = CSSClassUtils.splitTokens(cls);
wrap(els).forEach((el) => tokens.forEach((className) => remove(el, className, locker)));
}
Similar blocks of code found in 2 locations. Consider refactoring.
public async safePause(): Promise<void> {
await this.ready;
this._cmdMng.put(() => {
this._lastCmdType = 'pause';
this.pause();
packages/esl/src/esl-media/core/esl-media-provider.ts on lines 174..180 Similar blocks of code found in 2 locations. Consider refactoring.
public async safeStop(): Promise<void> {
await this.ready;
this._cmdMng.put(() => {
this._lastCmdType = 'pause';
this.stop();
packages/esl/src/esl-media/core/esl-media-provider.ts on lines 162..168 Similar blocks of code found in 2 locations. Consider refactoring.
public resolve(arg: T): Deferred<T> {
if (this._status === 'pending') {
this._value = arg;
this._status = 'resolved';
this._callbacks && this._callbacks[0](arg);
packages/esl/src/esl-utils/async/promise/defered.ts on lines 30..37 Similar blocks of code found in 2 locations. Consider refactoring.
public reject(arg?: any): Deferred<T> {
if (this._status === 'pending') {
this._value = arg;
this._status = 'rejected';
this._callbacks && this._callbacks[1](arg);
packages/esl/src/esl-utils/async/promise/defered.ts on lines 20..27 Similar blocks of code found in 2 locations. Consider refactoring.
public static register(this: any, action?: ESLShareActionType): void {
action = action || this;
if (action === ESLShareBaseAction) throw new Error('`ESLShareBaseAction` can\'t be registered.');
if (!(action?.prototype instanceof ESLShareBaseAction)) throw new Error('Action should be instanceof `ESLShareBaseAction`');
ESLShareActionRegistry.instance.register(action);
packages/esl/src/esl-media/core/esl-media-provider.ts on lines 193..198 Similar blocks of code found in 2 locations. Consider refactoring.
public static register(this: any, provider?: ProviderType): void {
provider = provider || this;
if (provider === BaseProvider) throw new Error('`BaseProvider` can\'t be registered.');
if (!(provider?.prototype instanceof BaseProvider)) throw new Error('Provider should be instanceof `BaseProvider`');
ESLMediaProviderRegistry.instance.register(provider);
packages/esl/src/esl-share/core/esl-share-action.ts on lines 16..21 Similar blocks of code found in 2 locations. Consider refactoring.
@listen({event: 'esl:show', target: window})
public _onContainerShow(e: Event): void {
this.releaseAll(e.target as Element);
}
packages/esl/src/esl-media/core/esl-media-manager.ts on lines 71..74 Similar blocks of code found in 2 locations. Consider refactoring.
@listen({event: 'esl:hide', target: window})
protected _onContainerHide(e: Event): void {
this.suspendAll(e.target as Element);
}
packages/esl/src/esl-media/core/esl-media-manager.ts on lines 62..65 Similar blocks of code found in 2 locations. Consider refactoring.
private static processElement(el: Element, [name, selString]: ProcessorDescriptor): Element[] {
const sel = unwrapParenthesis(selString || '');
if (!name || !(name in this.ELEMENT_PROCESSORS)) return [];
return wrap(this.ELEMENT_PROCESSORS[name](el, sel));
}
packages/esl/src/esl-traversing-query/core/esl-traversing-query.ts on lines 78..82 Similar blocks of code found in 2 locations. Consider refactoring.
private static processCollection(els: Element[], [name, selString]: ProcessorDescriptor): Element[] {
const sel = unwrapParenthesis(selString || '');
if (!name || !(name in this.COLLECTION_PROCESSORS)) return [];
return wrap(this.COLLECTION_PROCESSORS[name](els, sel));
}
packages/esl/src/esl-traversing-query/core/esl-traversing-query.ts on lines 73..77 Function debounce
has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Fixed
Function decorate
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Fixed
Function loadScript
has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Fixed
Function parseKeysPath
has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
Fixed
Function _onKeyDown
has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
Fixed
Identical blocks of code found in 2 locations. Consider refactoring.
Fixed
src/modules/esl-base-element/core/esl-base-element.ts on lines 72..75 Identical blocks of code found in 2 locations. Consider refactoring.
Fixed
src/modules/esl-mixin-element/ui/esl-mixin-element.ts on lines 61..64 Similar blocks of code found in 2 locations. Consider refactoring.
Fixed
Similar blocks of code found in 2 locations. Consider refactoring.
Fixed
Similar blocks of code found in 2 locations. Consider refactoring.
Fixed
Similar blocks of code found in 2 locations. Consider refactoring.
Fixed
src/modules/esl-traversing-query/core/esl-traversing-query.ts on lines 78..82 Similar blocks of code found in 2 locations. Consider refactoring.
Fixed
src/modules/esl-traversing-query/core/esl-traversing-query.ts on lines 73..77 There are no issues that match your filters.