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

@@ -50,7 +50,7 @@ export class FileActionsApi {
});
}
async uploadFileWithRename(fileLocation: string, parentId: string = '-my-', newName: string, title: string = '', description: string = '') {
async uploadFileWithRename(fileLocation: string, newName: string, parentId: string = '-my-', title: string = '', description: string = '') {
const file = fs.createReadStream(fileLocation);
const nodeProps = {
properties: {
@@ -93,7 +93,7 @@ export class FileActionsApi {
async getNodeProperty(nodeId: string, property: string): Promise<string> {
try {
const node = await this.getNodeById(nodeId);
return (node.entry.properties && node.entry.properties[property]) || '';
return (node.entry.properties?.[property]) || '';
} catch (error) {
Logger.error(`${this.constructor.name} ${this.getNodeProperty.name}`, error);
return '';

View File

@@ -215,12 +215,11 @@ export class NodesApi {
}
private async getDataDictionaryId(): Promise<string> {
try {
return this.getNodeIdFromParent('Data Dictionary', '-root-');
} catch (error) {
logger.error('Admin Actions - getDataDictionaryId failed : ', error);
return '';
}
return this.getNodeIdFromParent('Data Dictionary', '-root-')
.catch((error) => {
logger.error('Admin Actions - getDataDictionaryId failed : ', error);
return '';
});
}
async setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string): Promise<NodeEntry | null> {

View File

@@ -22,9 +22,8 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { Page } from '@playwright/test';
import { Page, expect } from '@playwright/test';
import { BaseComponent } from '../base.component';
import { expect } from '@playwright/test';
export class MatMenuComponent extends BaseComponent {
private static rootElement = '.mat-menu-content';

View File

@@ -22,11 +22,10 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { Page } from '@playwright/test';
import { Page, expect } from '@playwright/test';
import { BaseComponent } from './base.component';
import { AcaHeader } from './aca-header.component';
import { timeouts } from '../../utils';
import { expect } from '@playwright/test';
export class ViewerComponent extends BaseComponent {
private static rootElement = 'adf-viewer';

View File

@@ -69,20 +69,17 @@ export abstract class BasePage extends PlaywrightBase {
await this.page.goto(actualOptions.remoteUrl, {
waitUntil: actualOptions.waitUntil
});
} else if (this.urlRequest && actualOptions.waitForRequest) {
await Promise.all([
this.page.goto(`./#/${this.pageUrl}${actualOptions.query}`, { waitUntil: 'load' }),
this.page.waitForResponse(this.urlRequest)
]);
} else {
if (this.urlRequest && actualOptions.waitForRequest) {
await Promise.all([
this.page.goto(`./#/${this.pageUrl}${actualOptions.query}`, { waitUntil: 'load' }),
this.page.waitForResponse(this.urlRequest)
]);
} else {
await this.page.goto(`./#/${this.pageUrl}${actualOptions.query}`, {
waitUntil: actualOptions.waitUntil,
timeout: 60000
});
}
await this.page.goto(`./#/${this.pageUrl}${actualOptions.query}`, {
waitUntil: actualOptions.waitUntil,
timeout: 60000
});
}
await this.spinner.waitForReload();
}