Sonarcloud issues fixes (#3499)

* Sonarcloud issues fixes

* Code smell fixes

* Refactoring to remove new code duplications

* Sonarcloud code smell fixes part I

* Sonarcloud code smell fixes part II

* Missing code smell fix

* Add new ESLint rules to cover fixed SonarCloud issues

* Add missing command

* Add missing is existing check
This commit is contained in:
MichalKinas
2023-11-03 11:43:06 +01:00
committed by GitHub
parent 968febffb0
commit 69c00fc403
72 changed files with 327 additions and 530 deletions

View File

@@ -52,7 +52,7 @@ export class ContextMenuItemComponent {
}
private hasClickAction(actionRef: ContentActionRef): boolean {
return !!(actionRef && actionRef.actions && actionRef.actions.click);
return !!actionRef?.actions?.click;
}
trackByActionId(_: number, obj: ContentActionRef): string {

View File

@@ -36,8 +36,6 @@ export class OutsideEventDirective implements OnInit, OnDestroy {
@Output()
clickOutside: EventEmitter<null> = new EventEmitter();
constructor() {}
ngOnInit() {
this.subscriptions = this.subscriptions.concat([
fromEvent(document.body, 'click')
@@ -54,11 +52,9 @@ export class OutsideEventDirective implements OnInit, OnDestroy {
private findAncestor(el: Element): boolean {
const className = 'aca-context-menu';
if (el.classList.contains(className)) {
return true;
while (el && !el.classList.contains(className)) {
el = el.parentElement;
}
// eslint-disable-next-line curly
while ((el = el.parentElement) && !el.classList.contains(className));
return !!el;
}
}

View File

@@ -68,11 +68,6 @@ export class ContextMenuService {
}
private createInjector(contextmenuOverlayRef: ContextMenuOverlayRef): Injector {
const injectionTokens = new WeakMap();
injectionTokens.set(ContextMenuOverlayRef, contextmenuOverlayRef);
injectionTokens.set(CONTEXT_MENU_DIRECTION, this.direction);
return Injector.create({
parent: this.injector,
providers: [