Skip to content

Commit

Permalink
fix: code issues detected by sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryT-CG committed Jan 24, 2024
1 parent 2ac779e commit 8ab0686
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/app/shared/can-active-guard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const DEFAULT_LANG = 'en'
export class CanActivateGuard implements CanActivate {
constructor(private txService: TranslateService, private config: ConfigurationService) {}

/* eslint-disable @typescript-eslint/no-unused-vars */ /* TODO: is route and state needed */
/* eslint-disable @typescript-eslint/no-unused-vars */
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class ImageContainerComponent implements OnChanges {

// if image Url does not start with a http the api-prefix ...
// ...then it stored in the backend. So we need to put prefix in front
if (this.imageUrl && !this.imageUrl.match(/^(http|https)/g) && this.imageUrl.indexOf(this.apiPrefix) !== 0) {
if (this.imageUrl && !this.imageUrl.match(/^(http|https)/g) && !this.imageUrl.startsWith(this.apiPrefix)) {
this.imageUrl = this.apiPrefix + this.imageUrl
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/label.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Observable } from 'rxjs'
@Injectable()
export class LabelResolver implements Resolve<string> {
constructor(private translate: TranslateService) {}
/* eslint-disable @typescript-eslint/no-unused-vars */ /* TODO: is state needed */
/* eslint-disable @typescript-eslint/no-unused-vars */
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): string | Observable<string> | Promise<string> {
return route.data['breadcrumb'] ? this.translate.instant(route.data['breadcrumb']) : route.routeConfig?.path
}
Expand Down
8 changes: 3 additions & 5 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,16 @@ import { ImageContainerComponent } from './image-container/image-container.compo
import { ThemeColorBoxComponent } from './theme-color-box/theme-color-box.component'

export const basePathProvider = (mfeInfo: MfeInfo) => {
console.log(
'Base path provider: ' + (mfeInfo ? mfeInfo.remoteBaseUrl + '' + environment.apiPrefix : '' + environment.apiPrefix)
)
return mfeInfo ? mfeInfo.remoteBaseUrl + '' + environment.apiPrefix : '' + environment.apiPrefix
console.log('Base path provider: ' + (mfeInfo ? mfeInfo?.remoteBaseUrl : '') + environment.apiPrefix)
return (mfeInfo ? mfeInfo?.remoteBaseUrl : '') + environment.apiPrefix
}

export function HttpLoaderFactory(http: HttpClient, mfeInfo: MfeInfo) {
if (mfeInfo) {
console.log(`Configuring translation loader ${mfeInfo?.remoteBaseUrl}`)
}
// if running standalone then load the app assets directly from remote base URL
const appAssetPrefix = mfeInfo && mfeInfo.remoteBaseUrl ? mfeInfo.remoteBaseUrl : './'
const appAssetPrefix = mfeInfo?.remoteBaseUrl ? mfeInfo.remoteBaseUrl : './'
return new TranslateCombinedLoader(
new TranslateHttpLoader(http, appAssetPrefix + 'assets/i18n/', '.json'),
new TranslateHttpLoader(http, appAssetPrefix + 'onecx-portal-lib/assets/i18n/', '.json')
Expand Down
4 changes: 3 additions & 1 deletion src/app/test/mocks/auth-mock.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export class IAuthMockService implements IAuthService {
getCurrentUser(): UserProfile | null {
return null
}
logout(): void {}
logout(): void {
// logout
}
hasPermission(permissionKey: string): boolean {
return false
}
Expand Down
8 changes: 0 additions & 8 deletions src/app/theme/theme-designer/theme-designer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@
<label for="theme_detail_item_description">{{ 'THEME.DESCRIPTION' | translate }}</label>
</span>
</div>
<!--
<div class="field col-12 mb-4">
<span class="p-float-label" [title]="'THEME.TOOLTIPS.CSS_FILE' | translate">
<input pInputText type="text" id="theme_detail_item_cssFile" formControlName="cssFile" />
<label for="theme_detail_item_cssFile">{{'THEME.CSS_FILE' | translate}}</label>
</span>
</div>
-->
<!-- helper inputs because p-fileupload does not work inside inputgroup -->
<input
hidden
Expand Down
13 changes: 0 additions & 13 deletions src/app/theme/theme-detail/theme-detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,6 @@
></textarea>
<label for="theme_detail_item_description">{{ 'THEME.DESCRIPTION' | translate }}</label>
</span>
<!--
<span class="p-float-label" [title]="'THEME.TOOLTIPS.CSS_FILE' | translate">
<input
pInputText
type="text"
readonly
class="w-full"
id="theme_detail_item_cssFile"
[value]="theme?.cssFile"
/>
<label for="theme_detail_item_cssFile">{{'THEME.CSS_FILE' | translate}}</label>
</span>
-->
<div class="flex flex-wrap sm:flex-nowrap align-items-center pb-2 row-gap-2 column-gap-4">
<tm-image-container
[imageUrl]="headerImageUrl"
Expand Down
2 changes: 1 addition & 1 deletion src/app/theme/theme-detail/theme-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,6 @@ export class ThemeDetailComponent implements OnInit {

public prepareUsedInPortalList(): string {
const arr = this.usedInWorkspace?.map((workspace: Workspace) => workspace.workspaceName)
return arr?.sort(sortByLocale).join(', ') || ''
return arr?.sort(sortByLocale).join(', ') ?? ''
}
}
6 changes: 5 additions & 1 deletion src/assets/silent-check-sso.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Some relevant title</title>
</head>
<body>
<script>
parent.postMessage(location.href, location.origin)
Expand Down
9 changes: 0 additions & 9 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,3 @@ export const environment = {
skipRemoteConfigLoad: true,
apiPrefix: 'theme-bff'
}

/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.

0 comments on commit 8ab0686

Please sign in to comment.