Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various code quality fixes #5792

Merged
merged 3 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo-shell/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var server = http.createServer(function (req, res) {
req.on('end', function() {
if (req.url === '/') {
log('Received message: ' + body);
} else if (req.url = '/scheduled') {
} else if (req.url === '/scheduled') {
log('Received task ' + req.headers['x-aws-sqsd-taskname'] + ' scheduled at ' + req.headers['x-aws-sqsd-scheduled-at']);
}

Expand Down
5 changes: 1 addition & 4 deletions demo-shell/src/app/components/files/files.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,10 +582,7 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
}

isCustomActionDisabled(node: MinimalNodeEntity): boolean {
if (node && node.entry && node.entry.name === 'custom') {
return false;
}
return true;
return !(node && node.entry && node.entry.name === 'custom');
}

runCustomAction(event: any) {
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/working-with-data-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ To develop the enhancement, edit the `src/app/mydatatable/mydatatable.component.
```ts
onExecuteRowAction(event: DataRowActionEvent) {

if (event.value.action.title = "Greetings") {
if (event.value.action.title === "Greetings") {

this.apiService.getInstance().webScript.executeWebScript(
'GET',
Expand Down
5 changes: 2 additions & 3 deletions e2e/content-services/upload/upload-dialog.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ describe('Upload component', () => {
afterEach(async () => {
const nbResults = await contentServicesPage.numberOfResultsDisplayed();
if (nbResults > 1) {
const nodesPromise = await contentServicesPage.getElementsDisplayedId();
for (const node of nodesPromise) {
const nodeId = await node;
const nodeIds = await contentServicesPage.getElementsDisplayedId();
for (const nodeId of nodeIds) {
await uploadActions.deleteFileOrFolder(nodeId);
}
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/process-services/comment-component-processes.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('Comment component for Processes', () => {
const taskId = taskQuery.data[0].id;

const taskComments = await apiService.getInstance().activiti.commentsApi.getTaskComments(taskId, { 'latestFirst': true });
await expect(await taskComments.total).toEqual(0);
await expect(taskComments.total).toEqual(0);
});

it('[C260466] Should be able to display comments from Task on the related Process', async () => {
Expand Down
6 changes: 3 additions & 3 deletions lib/cli/scripts/init-aae-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,21 +302,21 @@ async function checkIfAppIsReleased(absentApps: any []) {
async function checkDescriptorExist(name: string) {
logger.info(`Check descriptor ${name} exist in the list `);
const descriptorList = await getDescriptors();
descriptorList.list.entries.forEach(async (descriptor: any) => {
for (const descriptor of descriptorList.list.entries) {
if (descriptor.entry.name === name) {
if (descriptor.entry.deployed === false) {
await deleteDescriptor(descriptor.entry.name);
}
}
});
}
return false;
}

async function importProjectAndRelease(app: any) {
await getFileFromRemote(app.file_location, app.name);
logger.warn('Project imported ' + app.name);
const projectRelease = await importAndReleaseProject(`${app.name}.zip`);
deleteLocalFile(`${app.name}`);
await deleteLocalFile(`${app.name}`);
return projectRelease;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
}

hasPreviousNodes(): boolean {
return this.previousNodes ? true : false;
return !!this.previousNodes;
}

parseRoute(node: Node): PathElementEntity[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('NodeSharedDirective', () => {
});

it('should have share button disabled when selection is empty', async () => {
fixture.whenStable();
await fixture.whenStable();
fixture.detectChanges();
expect(shareButtonElement.disabled).toBe(true);
});
Expand All @@ -96,7 +96,7 @@ describe('NodeSharedDirective', () => {
component.documentList.selection = [selection];
fixture.detectChanges();

fixture.whenStable();
await fixture.whenStable();
fixture.detectChanges();
expect(shareButtonElement.disabled).toBe(false);
});
Expand All @@ -106,7 +106,7 @@ describe('NodeSharedDirective', () => {
component.documentList.selection = [selection];
fixture.detectChanges();

fixture.whenStable();
await fixture.whenStable();
fixture.detectChanges();
expect(shareButtonElement.disabled).toBe(true);
});
Expand All @@ -115,7 +115,7 @@ describe('NodeSharedDirective', () => {
component.documentList.selection = [selection];
fixture.detectChanges();

fixture.whenStable();
await fixture.whenStable();
fixture.detectChanges();
expect(shareButtonElement.title).toBe('Not Shared');
});
Expand All @@ -124,7 +124,7 @@ describe('NodeSharedDirective', () => {
selection.entry.properties['qshare:sharedId'] = 'someId';
component.documentList.selection = [selection];
fixture.detectChanges();
fixture.whenStable();
await fixture.whenStable();

fixture.detectChanges();
expect(shareButtonElement.title).toBe('Shared');
Expand All @@ -135,7 +135,7 @@ describe('NodeSharedDirective', () => {
component.documentList.selection = [selection];
fixture.detectChanges();

fixture.whenStable();
await fixture.whenStable();
fixture.detectChanges();

shareButtonElement.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class SearchControlComponent implements OnDestroy {
) {}

isNoSearchTemplatePresent(): boolean {
return this.emptySearchTemplate ? true : false;
return !!this.emptySearchTemplate;
}

ngOnDestroy(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export abstract class UploadBase implements OnInit, OnDestroy {
/**
* Upload a list of file in the specified path
* @param files
* @param path
*/
uploadFiles(files: File[]): void {
const filteredFiles: FileModel[] = files
Expand Down Expand Up @@ -152,17 +151,16 @@ export abstract class UploadBase implements OnInit, OnDestroy {
.split(',')
.map((ext) => ext.trim().replace(/^\./, ''));

if (allowedExtensions.indexOf(file.extension) !== -1) {
return true;
}

return false;
return allowedExtensions.indexOf(file.extension) !== -1;
}

/**
* Creates FileModel from File
*
* @param file
* @param parentId
* @param path
* @param id
*/
protected createFileModel(file: File, parentId: string, path: string, id?: string): FileModel {
return new FileModel(file, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class VersionUploadComponent {
}

isMajorVersion(): boolean {
return this.semanticVersion === 'minor' ? false : true;
return this.semanticVersion !== 'minor';
}

cancelUpload() {
Expand Down
6 changes: 1 addition & 5 deletions lib/core/buttons-menu/buttons-menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ export class ButtonsMenuComponent implements AfterContentInit {
isMenuEmpty: boolean;

ngAfterContentInit() {
if (this.buttons.length > 0) {
this.isMenuEmpty = false;
} else {
this.isMenuEmpty = true;
}
this.isMenuEmpty = this.buttons.length <= 0;
}

isMobile(): boolean {
Expand Down
6 changes: 3 additions & 3 deletions lib/core/comments/comments.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ export class CommentsComponent implements OnChanges {
}

isATask(): boolean {
return this.taskId ? true : false;
return !!this.taskId;
}

isANode(): boolean {
return this.nodeId ? true : false;
return !!this.nodeId;
}

private sanitize(input: string) {
private sanitize(input: string): string {
return input.replace(/<[^>]+>/g, '')
.replace(/^\s+|\s+$|\s+(?=\s)/g, '')
.replace(/\r?\n/g, '<br/>');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
}

isPropertyChanged(property: SimpleChange): boolean {
return property && property.currentValue ? true : false;
return !!(property && property.currentValue);
}

convertToRowsData(rows: any []): ObjectDataRow[] {
Expand Down Expand Up @@ -375,7 +375,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
this.rowMenuCache = {};
}

isTableEmpty() {
isTableEmpty(): boolean {
return this.data === undefined || this.data === null;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/core/dialogs/edit-json/edit-json.dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class EditJsonDialogComponent implements OnInit {

ngOnInit() {
if (this.settings) {
this.editable = this.settings.editable ? true : false;
this.editable = this.settings.editable;
this.value = this.settings.value || '';
this.title = this.settings.title || 'JSON';
}
Expand Down
2 changes: 1 addition & 1 deletion lib/core/form/components/form-base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export abstract class FormBaseComponent {
}

hasForm(): boolean {
return this.form ? true : false;
return !!this.form;
}

isTitleEnabled(): boolean {
Expand Down
8 changes: 4 additions & 4 deletions lib/core/form/components/widgets/core/content-link.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@
}

hasPreviewStatus(): boolean {
return this.previewStatus === 'supported' ? true : false;
return this.previewStatus === 'supported';
}

isTypeImage(): boolean {
return this.simpleType === 'image' ? true : false;
return this.simpleType === 'image';
}

isTypePdf(): boolean {
return this.simpleType === 'pdf' ? true : false;
return this.simpleType === 'pdf';
}

isTypeDoc(): boolean {
return this.simpleType === 'word' || this.simpleType === 'content' ? true : false;
return this.simpleType === 'word' || this.simpleType === 'content';
}

isThumbnailReady(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export class ErrorMessageModel {
this.attributes = new Map();
}

isActive() {
return this.message ? true : false;
isActive(): boolean {
return !!this.message;
}

getAttributesAsJsonObj() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class RequiredFieldValidator implements FormFieldValidator {
}

if (field.type === FormFieldTypes.BOOLEAN) {
return field.value ? true : false;
return !!field.value;
}

if (field.value === null || field.value === undefined || field.value === '') {
Expand Down
8 changes: 2 additions & 6 deletions lib/core/form/components/widgets/core/form-field.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class FormFieldModel extends FormWidgetModel {
}

private isTypeaheadFieldType(type: string): boolean {
return type === 'typeahead' ? true : false;
return type === 'typeahead';
}

private getFieldNameWithLabel(name: string): string {
Expand Down Expand Up @@ -419,11 +419,7 @@ export class FormFieldModel extends FormWidgetModel {
* @param type
*/
isInvalidFieldType(type: string) {
if (type === 'container') {
return true;
} else {
return false;
}
return type === 'container';
}

getOptionName(): string {
Expand Down
2 changes: 1 addition & 1 deletion lib/core/form/components/widgets/core/form.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class FormModel {
}
}

this.isValid = errorsField.length > 0 ? false : true;
this.isValid = errorsField.length <= 0;

if (this.formService) {
validateFormEvent.isValid = this.isValid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class DropdownWidgetComponent extends WidgetComponent implements OnInit {
}

isReadOnlyType(): boolean {
return this.field.type === 'readonly' ? true : false;
return this.field.type === 'readonly';
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class DynamicTableModel extends FormWidgetModel {
}

if (column.type === 'Boolean') {
return rowValue ? true : false;
return !!rowValue;
}

if (column.type === 'Date') {
Expand Down
6 changes: 3 additions & 3 deletions lib/core/form/components/widgets/widget.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export class WidgetComponent implements AfterViewInit {
constructor(public formService?: FormService) {
}

hasField() {
return this.field ? true : false;
hasField(): boolean {
return !!this.field;
}

// Note for developers:
Expand All @@ -73,7 +73,7 @@ export class WidgetComponent implements AfterViewInit {
}

isValid(): boolean {
return this.field.validationSummary ? true : false;
return !!this.field.validationSummary;
}

hasValue(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ describe('HeaderLayoutComponent', () => {

const logo = fixture.nativeElement.querySelector('.adf-app-logo');
const src = logo.getAttribute('src');
expect(logo === null).toBeFalsy();
expect(src).toEqual('logo.png');
});

Expand Down