exadel-inc/esl

View on GitHub

Showing 23 of 23 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

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)));
}
Severity: Major
Found in packages/esl/src/esl-utils/dom/class.ts and 1 other location - About 2 hrs to fix
packages/esl/src/esl-utils/dom/class.ts on lines 80..83

Similar blocks of code found in 2 locations. Consider refactoring.
Open

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)));
}
Severity: Major
Found in packages/esl/src/esl-utils/dom/class.ts and 1 other location - About 2 hrs to fix
packages/esl/src/esl-utils/dom/class.ts on lines 89..92

Function printFiles has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
Open

function printFiles(fileStat, basePath) {
let text = '';
for (const file of fileStat) {
text += `### ${file.filepath}\n`;
text += `<table>\n`;
Severity: Minor
Found in packages/snapshot-tests/src/reporters/printers.js - About 1 hr to fix

Identical blocks of code found in 2 locations. Consider refactoring.
Open

public $$on<EType extends keyof ESLListenerEventMap>(
event: EType | ESLListenerDescriptor<EType>,
handler: ESLListenerHandler<ESLListenerEventMap[EType]>
): ESLEventListener[];
Severity: Major
Found in packages/esl/src/esl-mixin-element/ui/esl-mixin-element.ts and 1 other location - About 1 hr to fix
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.
Open

public $$on<EType extends keyof ESLListenerEventMap>(
event: EType | ESLListenerDescriptor<EType>,
handler: ESLListenerHandler<ESLListenerEventMap[EType]>
): ESLEventListener[];
Severity: Major
Found in packages/esl/src/esl-base-element/core/esl-base-element.ts and 1 other location - About 1 hr to fix
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.
Open

public async safePause(): Promise<void> {
await this.ready;
this._cmdMng.put(() => {
this._lastCmdType = 'pause';
this.pause();
Severity: Major
Found in packages/esl/src/esl-media/core/esl-media-provider.ts and 1 other location - About 1 hr to fix
packages/esl/src/esl-media/core/esl-media-provider.ts on lines 174..180

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public async safeStop(): Promise<void> {
await this.ready;
this._cmdMng.put(() => {
this._lastCmdType = 'pause';
this.stop();
Severity: Major
Found in packages/esl/src/esl-media/core/esl-media-provider.ts and 1 other location - About 1 hr to fix
packages/esl/src/esl-media/core/esl-media-provider.ts on lines 162..168

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

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 {
Severity: Minor
Found in packages/esl/src/esl-utils/async/debounce.ts - About 1 hr to fix

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

    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');
    Severity: Minor
    Found in packages/esl/src/esl-utils/dom/script.ts - About 1 hr to fix

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

      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> {
      Severity: Minor
      Found in packages/esl/src/esl-utils/decorators/decorate.ts - About 1 hr to fix

        Function attr has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
        Open

        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;
         
         
        Severity: Minor
        Found in packages/esl/src/esl-utils/decorators/attr.ts - About 55 mins to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        public resolve(arg: T): Deferred<T> {
        if (this._status === 'pending') {
        this._value = arg;
        this._status = 'resolved';
        this._callbacks && this._callbacks[0](arg);
        Severity: Minor
        Found in packages/esl/src/esl-utils/async/promise/defered.ts and 1 other location - About 50 mins to fix
        packages/esl/src/esl-utils/async/promise/defered.ts on lines 30..37

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        public reject(arg?: any): Deferred<T> {
        if (this._status === 'pending') {
        this._value = arg;
        this._status = 'rejected';
        this._callbacks && this._callbacks[1](arg);
        Severity: Minor
        Found in packages/esl/src/esl-utils/async/promise/defered.ts and 1 other location - About 50 mins to fix
        packages/esl/src/esl-utils/async/promise/defered.ts on lines 20..27

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        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);
        Severity: Minor
        Found in packages/esl/src/esl-share/core/esl-share-action.ts and 1 other location - About 50 mins to fix
        packages/esl/src/esl-media/core/esl-media-provider.ts on lines 193..198

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        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);
        Severity: Minor
        Found in packages/esl/src/esl-media/core/esl-media-provider.ts and 1 other location - About 50 mins to fix
        packages/esl/src/esl-share/core/esl-share-action.ts on lines 16..21

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        cucumber.defineRule('hover element', async ({elements}: TestEnv) => {
        if (!elements.length) throw new Error('E2E: No elements found');
        await elements[0].hover();
        });
        packages/snapshot-tests/src/scenarios/element/scenarios.events.ts on lines 5..8

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        @listen({event: 'esl:show', target: window})
        public _onContainerShow(e: Event): void {
        this.releaseAll(e.target as Element);
        }
        Severity: Minor
        Found in packages/esl/src/esl-media/core/esl-media-manager.ts and 1 other location - About 40 mins to fix
        packages/esl/src/esl-media/core/esl-media-manager.ts on lines 71..74

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        cucumber.defineRule('click element', async ({elements}: TestEnv) => {
        if (!elements.length) throw new Error('E2E: No elements found');
        await elements[0].click();
        });
        packages/snapshot-tests/src/scenarios/element/scenarios.events.ts on lines 10..13

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        @listen({event: 'esl:hide', target: window})
        protected _onContainerHide(e: Event): void {
        this.suspendAll(e.target as Element);
        }
        Severity: Minor
        Found in packages/esl/src/esl-media/core/esl-media-manager.ts and 1 other location - About 40 mins to fix
        packages/esl/src/esl-media/core/esl-media-manager.ts on lines 62..65
        Severity
        Category
        Status
        Source
        Language