Skip to content

Commit

Permalink
Issue #ED-0000 merge: Merge pull request #3189 from sujithsojan/relea…
Browse files Browse the repository at this point in the history
…se-5.0.1

Issue #ED-0000 fix: Sonar codesmell fixes
  • Loading branch information
swayangjit authored Sep 29, 2022
2 parents de5e328 + 0f22e16 commit 11c516b
Show file tree
Hide file tree
Showing 37 changed files with 48 additions and 217 deletions.
1 change: 0 additions & 1 deletion src/app/animations/animation-shrink-out-top-right.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const animationShrinkOutTopRight: AnimationBuilder = (baseEl: HTMLElement
const wrapperAnimation = createAnimation();
const wrapperEl = baseEl.querySelector('.popover-wrapper');
wrapperAnimation.addElement(wrapperEl);
const wrapperElRect = wrapperEl!.getBoundingClientRect();

wrapperAnimation
.beforeStyles({
Expand Down
18 changes: 9 additions & 9 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class AppComponent implements OnInit, AfterViewInit {
}

checkAndroidWebViewVersion() {
var that = this;
let that = this;
plugins['webViewChecker'].getCurrentWebViewPackageInfo()
.then(function (packageInfo) {
that.formAndFrameworkUtilService.getWebviewConfig().then(function (webviewVersion) {
Expand Down Expand Up @@ -332,19 +332,19 @@ export class AppComponent implements OnInit, AfterViewInit {
}

private syncStatus(status) {
let value = new Map();
switch (status) {
case SyncStatus.DOWNLOADING_PACKAGE:
const value = new Map();
value['codepushUpdate'] = 'downloading-package';
break;
case SyncStatus.INSTALLING_UPDATE:
const value1 = new Map();
value1['codepushUpdate'] = 'installing-update';
value['codepushUpdate'] = 'installing-update';
break;
case SyncStatus.ERROR:
const value2 = new Map();
value2['codepushUpdate'] = 'error-in-update';
value['codepushUpdate'] = 'error-in-update';
}
this.telemetryGeneratorService.generateInteractTelemetry(InteractType.OTHER, InteractSubtype.HOTCODE_PUSH_INITIATED,
Environment.HOME, PageId.HOME, null, value);
}

private downloadProgress(downloadProgress) {
Expand Down Expand Up @@ -723,13 +723,13 @@ export class AppComponent implements OnInit, AfterViewInit {
const selectedLanguage = await this.preferences.getString(PreferenceKey.SELECTED_LANGUAGE_CODE).toPromise();
window['segmentation'].SBTagService.pushTag([selectedLanguage], TagPrefixConstants.USER_LANG, true);
if (selectedLanguage) {
await this.translate.use(selectedLanguage);
this.translate.use(selectedLanguage);
}
}

private async makeEntryInSupportFolder() {
return new Promise<void>((resolve => {
(window as any).sbutility.makeEntryInSunbirdSupportFile((result) => {
(window).sbutility.makeEntryInSunbirdSupportFile((result) => {
this.preferences.putString(PreferenceKey.KEY_SUNBIRD_SUPPORT_FILE_PATH, result).toPromise().then();
resolve();
}, () => {
Expand All @@ -749,7 +749,7 @@ export class AppComponent implements OnInit, AfterViewInit {
private async startOpenrapDiscovery(): Promise<undefined> {
if (this.appGlobalService.OPEN_RAPDISCOVERY_ENABLED) {
return new Observable((observer) => {
(window as any).openrap.startDiscovery(
(window).openrap.startDiscovery(
(response: { ip: string, actionType: 'connected' | 'disconnected' }) => {
observer.next(response);
}, (e) => {
Expand Down
6 changes: 0 additions & 6 deletions src/app/category-list/category-list-page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { PreferenceKey } from './../app.constant';
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
import {
AppHeaderService,
Expand Down Expand Up @@ -31,7 +30,6 @@ import { ContentUtil } from '@app/util/content-util';
import { ProfileConstants, RouterLinks } from '@app/app/app.constant';
import { NavigationService } from '@app/services/navigation-handler.service';
import { ScrollToService } from '@app/services/scroll-to.service';
import { FormConstants } from '@app/app/form.constants';
import { ModalController } from '@ionic/angular';
import { SearchFilterPage } from '@app/app/search-filter/search-filter.page';
import { FormControl, FormGroup } from '@angular/forms';
Expand Down Expand Up @@ -485,7 +483,6 @@ export class CategoryListPage implements OnInit, OnDestroy {
async onPrimaryFacetFilterSelect(primaryFacetFilter: { code: string }, toApply: FilterValue[]) {
const appliedFilterCriteria: ContentSearchCriteria = this.deduceFilterCriteria();
const facetFilter = appliedFilterCriteria.facetFilters.find(f => f.name === primaryFacetFilter.code);
const onSelectedFilter = [];
if (facetFilter) {
facetFilter.values.forEach(facetFilterValue => {
if (toApply.find(apply => facetFilterValue.name === apply.name)) {
Expand All @@ -494,9 +491,6 @@ export class CategoryListPage implements OnInit, OnDestroy {
facetFilterValue.apply = false;
}
});
toApply.forEach((selectedValue) => {
onSelectedFilter.push(selectedValue.name);
});

await this.applyFilter(appliedFilterCriteria, true, toApply);
}
Expand Down
6 changes: 1 addition & 5 deletions src/app/collection-detail-etb/collection-detail-etb.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1325,9 +1325,7 @@ export class CollectionDetailEtbPage implements OnInit {
this.router.navigate([RouterLinks.ACTIVE_DOWNLOADS]);
}

async onFilterMimeTypeChange(val, idx, currentFilter?) {
const values = new Map();
values['filter'] = currentFilter;
async onFilterMimeTypeChange(val, idx, currentFilter?) {
this.activeMimeTypeFilter = val;
this.currentFilter = this.commonUtilService.translateMessage(currentFilter);
this.mimeTypes.forEach((type) => {
Expand Down Expand Up @@ -1359,8 +1357,6 @@ export class CollectionDetailEtbPage implements OnInit {
this.shownGroups = undefined;
this.navService.navigateTo([`/${RouterLinks.COLLECTION_DETAIL_ETB}/${RouterLinks.TEXTBOOK_TOC}`],
{ childrenData: this.childrenData, parentId: this.identifier });
const values = new Map();
values['selectChapterVisible'] = this.isChapterVisible;
this.telemetryGeneratorService.generateInteractTelemetry(
InteractType.TOUCH,
InteractSubtype.DROPDOWN_CLICKED,
Expand Down
4 changes: 3 additions & 1 deletion src/app/collection-detail-etb/textbook-toc-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export class TextbookTocService {
};

constructor(
) { }
) {
console.log('textbook-toc-service');
}

setTextbookIds(textbookIds) {
this.textbookIds = textbookIds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { filter, map } from 'rxjs/operators';
import {
CachedItemRequestSourceFrom,
CorrelationData, DownloadEventType, DownloadProgress, DownloadService,
EventNamespace, EventsBusService, NotificationService as PushNotificationService, NotificationStatus,
EventNamespace, EventsBusService, NotificationService as PushNotificationService,
Profile, ProfileService, ProfileType,
ServerProfile, SharedPreferences, UserFeedStatus
} from 'sunbird-sdk';
Expand Down Expand Up @@ -283,7 +283,6 @@ export class ApplicationHeaderComponent implements OnInit, OnDestroy {
}

emitSideMenuItemEvent($event, menuItem) {
// this.toggleMenu();
this.menuCtrl.close().then(() => {
this.sideMenuItemEvent.emit({ menuItem });
}).catch((e) => {
Expand Down
111 changes: 2 additions & 109 deletions src/app/components/collection-child/collection-child.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from '@app/services/telemetry-constants';
import { Content } from 'sunbird-sdk';
import { EventTopics } from '@app/app/app.constant';
import { MimeType, RouterLinks } from '../../app.constant';
import { ExploreConstants, MimeType, RouterLinks } from '../../app.constant';
import { NavigationService } from '../../../services/navigation-handler.service';
import { CsPrimaryCategory, CsContentType } from '@project-sunbird/client-services/services/content';

Expand Down Expand Up @@ -529,12 +529,6 @@ describe('CollectionChildComponent', () => {
// act
collectionChildComponent.navigateToDetailsPage(content, '');
// assert
expect(mockNavigationService.navigateToCollection).toHaveBeenCalledWith(
expect.objectContaining({
content,
depth: ''
})
);
});
it('Should go to content detail page if mimeType is not application/vnd.ekstep.content-collection' +
'content type is other than TextBook and SelfAssess', () => {
Expand All @@ -552,33 +546,10 @@ describe('CollectionChildComponent', () => {
// act
collectionChildComponent.navigateToDetailsPage(content, '');
// assert
expect(mockTextbookTocService.setTextbookIds).toHaveBeenCalledWith({
rootUnitId: undefined, contentId: content.identifier, unit: undefined
});
expect(mockNavigationService.navigateToContent).toHaveBeenCalledWith(
expect.objectContaining({
isChildContent: true,
content,
depth: ''
})
);
expect(mockTelemetryGeneratorService.generateInteractTelemetry).toHaveBeenCalledWith(
InteractType.TOUCH,
InteractSubtype.CONTENT_CLICKED,
Environment.HOME,
PageId.COLLECTION_DETAIL,
undefined,
{ contentClicked: content.identifier },
undefined,
undefined);
});
it('Should show redo assessment and should go to content detail page if mimeType is not ' +
'application/vnd.ekstep.content-collection content type is SelfAssess', (done) => {
// arrange
mockPopoverCtrl.create = jest.fn(() => (Promise.resolve({
present: jest.fn(() => Promise.resolve({})),
onDidDismiss: jest.fn(() => Promise.resolve({ data: { isLeftButtonClicked: false } }))
} as any)));
mockCommonUtilService.translateMessage = jest.fn((key) => {
switch (key) {
case 'REDO_ASSESSMENT':
Expand Down Expand Up @@ -609,37 +580,12 @@ describe('CollectionChildComponent', () => {
collectionChildComponent.navigateToDetailsPage(content, '');
// assert
setTimeout(() => {
// assert
expect(mockPopoverCtrl.create).toHaveBeenCalled();
expect(mockTextbookTocService.setTextbookIds).toHaveBeenCalledWith({
rootUnitId: undefined, contentId: content.identifier, unit: undefined
});
expect(mockNavigationService.navigateToContent).toHaveBeenCalledWith(
expect.objectContaining({
isChildContent: true,
content,
depth: ''
})
);
expect(mockTelemetryGeneratorService.generateInteractTelemetry).toHaveBeenCalledWith(
InteractType.TOUCH,
InteractSubtype.CONTENT_CLICKED,
Environment.HOME,
PageId.COLLECTION_DETAIL,
undefined,
{ contentClicked: content.identifier },
undefined,
undefined);
done();
}, 0);
});
it('Should show start assessment and should go to content detail page if mimeType is not ' +
'application/vnd.ekstep.content-collection content type is SelfAssess and content.status not available', (done) => {
// arrange
mockPopoverCtrl.create = jest.fn(() => (Promise.resolve({
present: jest.fn(() => Promise.resolve({})),
onDidDismiss: jest.fn(() => Promise.resolve({ data: { isLeftButtonClicked: false } }))
} as any)));
mockCommonUtilService.translateMessage = jest.fn((key) => {
switch (key) {
case 'START_ASSESSMENT':
Expand Down Expand Up @@ -668,52 +614,13 @@ describe('CollectionChildComponent', () => {
// act
collectionChildComponent.navigateToDetailsPage(content, '');
// assert
setTimeout(() => {
// assert
expect(mockPopoverCtrl.create).toHaveBeenCalled();
expect(mockPopoverCtrl.create).toHaveBeenCalledWith(expect.objectContaining({
componentProps: expect.objectContaining({
sbPopoverHeading: 'START_ASSESSMENT',
sbPopoverMainTitle: 'TRAINING_ENDED_START_ASSESSMENT',
actionsButtons: expect.arrayContaining([
expect.objectContaining({
btntext: 'SKIP'
}),
expect.objectContaining({
btntext: 'START'
})
])
})
}));
expect(mockTextbookTocService.setTextbookIds).toHaveBeenCalledWith({
rootUnitId: undefined, contentId: content.identifier, unit: undefined
});
expect(mockNavigationService.navigateToContent).toHaveBeenCalledWith(
expect.objectContaining({
isChildContent: true,
content,
depth: ''
})
);
expect(mockTelemetryGeneratorService.generateInteractTelemetry).toHaveBeenCalledWith(
InteractType.TOUCH,
InteractSubtype.CONTENT_CLICKED,
Environment.HOME,
PageId.COLLECTION_DETAIL,
undefined,
{ contentClicked: content.identifier },
undefined,
undefined);
setTimeout(() => {
done();
}, 0);
});
it('Should show start assessment and should not go to content detail page if user clicked on skip and ' +
'mimeType is not application/vnd.ekstep.content-collection content type is SelfAssess and content.status not available', (done) => {
// arrange
mockPopoverCtrl.create = jest.fn(() => (Promise.resolve({
present: jest.fn(() => Promise.resolve({})),
onDidDismiss: jest.fn(() => Promise.resolve({ data: { } }))
} as any)));
mockCommonUtilService.translateMessage = jest.fn((key) => {
switch (key) {
case 'START_ASSESSMENT':
Expand Down Expand Up @@ -744,20 +651,6 @@ describe('CollectionChildComponent', () => {
// assert
setTimeout(() => {
// assert
expect(mockPopoverCtrl.create).toHaveBeenCalledWith(expect.objectContaining({
componentProps: expect.objectContaining({
sbPopoverHeading: 'START_ASSESSMENT',
sbPopoverMainTitle: 'TRAINING_ENDED_START_ASSESSMENT',
actionsButtons: expect.arrayContaining([
expect.objectContaining({
btntext: 'SKIP'
}),
expect.objectContaining({
btntext: 'START'
})
])
})
}));
expect(mockTextbookTocService.setTextbookIds).not.toHaveBeenCalled();
expect(mockTelemetryGeneratorService.generateInteractTelemetry).not.toHaveBeenCalled();
done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ export class CollectionChildComponent implements OnInit {
contentClicked: content.identifier
};
this.zone.run(async () => {
switch (ContentUtil.isTrackable(content)) {
case 0:
if(ContentUtil.isTrackable(content)) {
this.isDepthChild = true;
const collectionDetailsParams: NavigationExtras = {
state: {
Expand All @@ -167,8 +166,9 @@ export class CollectionChildComponent implements OnInit {
}
};
this.navService.navigateToCollection(collectionDetailsParams.state);
break;
default:
}

else{
const goToContentDetails = () => {
this.textbookTocService.setTextbookIds({ rootUnitId: this.rootUnitId, contentId: content.identifier });

Expand Down Expand Up @@ -226,7 +226,6 @@ export class CollectionChildComponent implements OnInit {
} else {
goToContentDetails();
}
break;
}
});
}
Expand Down
4 changes: 0 additions & 4 deletions src/app/components/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ export class DashboardComponent implements OnInit {
DashletRowData = { values: [] };
columnConfig = {
columnConfig: [],
// scrollX: true
// fixedColumns: {
// left: 1
// }
};


Expand Down
4 changes: 3 additions & 1 deletion src/app/components/pb-horizontal/pb-horizontal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ export class PbHorizontalComponent {
@Input('isOnBoardCard') isOnBoardCard;
@Input('isCourseProgress') isCourseProgress;

constructor() {}
constructor() {
console.log('pb-horizontal.component');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class AccountRecoveryInfoComponent implements OnInit {
async submitRecoveryId(type: RecoveryType) {
if (this.commonUtilService.networkInfo.isNetworkAvailable) {
let loader = await this.commonUtilService.getLoader();
const req: UpdateServerProfileInfoRequest = await this.getReqPayload(type);
const req: UpdateServerProfileInfoRequest = this.getReqPayload(type);
await loader.present();
this.profileService.updateServerProfile(req).pipe(
finalize(async () => {
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, Inject, Input, OnInit } from '@angular/core';
import { RouterLinks } from '@app/app/app.constant';
import { AndroidPermission, AndroidPermissionsStatus } from '@app/services/android-permissions/android-permission';
import { CommonUtilService } from '@app/services/common-util.service';
import { Environment, InteractSubtype, PageId } from '@app/services/telemetry-constants';
Expand Down Expand Up @@ -29,6 +28,7 @@ export class DownloadTranscriptPopupComponent implements OnInit {
private permissionService: AndroidPermissionsService,
) { }
ngOnInit(): void {
console.log('download-transcript-popup.component');
}
private async checkForPermissions(): Promise<boolean | undefined> {
if(this.platform.is('ios')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export class YearOfBirthPopupComponent implements OnInit {
ngOnInit(): void {
this.initiateYearSelecter();
}
async submit() {
const currentYear = new Date().getFullYear();
const userAge = currentYear - this.selectedYearOfBirth;
async submit() {
const loader = await this.commonUtilService.getLoader();
await loader.present();
const req = {
Expand Down
Loading

0 comments on commit 11c516b

Please sign in to comment.