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

Sonar issues #417

Merged
merged 5 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class TokenProvider {
public TokenProvider(JHipsterProperties jHipsterProperties) {
byte[] keyBytes;
String secret = jHipsterProperties.getSecurity().getAuthentication().getJwt().getSecret();
if (!StringUtils.isEmpty(secret)) {
if (StringUtils.hasLength(secret)) {
log.warn(
"Warning: the JWT key used is not Base64-encoded. " +
"We recommend using the `jhipster.security.authentication.jwt.base64-secret` key for optimum security."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class PasswordStrengthBarComponent {
}

getColor(s: number): { idx: number; color: string } {
let idx = 0;
let idx = 4;
if (s <= 10) {
idx = 0;
} else if (s <= 20) {
Expand All @@ -76,8 +76,6 @@ export class PasswordStrengthBarComponent {
idx = 2;
} else if (s <= 40) {
idx = 3;
} else {
idx = 4;
}
return { idx: idx + 1, color: this.colors[idx] };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ export class ConfigurationComponent implements OnInit {
}

filterAndSortBeans(): void {
const beansAscendingSort = this.beansAscending ? -1 : 1;
this.beans = this.allBeans
.filter(bean => !this.beansFilter || bean.prefix.toLowerCase().includes(this.beansFilter.toLowerCase()))
.sort((a, b) => (a.prefix < b.prefix ? (this.beansAscending ? -1 : 1) : this.beansAscending ? 1 : -1));
.sort((a, b) => (a.prefix < b.prefix ? beansAscendingSort : beansAscendingSort * -1));
}
}
2 changes: 1 addition & 1 deletion src/main/webapp/app/blocks/interceptor/auth.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class AuthInterceptor implements HttpInterceptor {
constructor(private localStorage: LocalStorageService, private sessionStorage: SessionStorageService) {}

intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if (!request || !request.url || (request.url.startsWith('http') && !(SERVER_API_URL && request.url.startsWith(SERVER_API_URL)))) {
if (!request?.url || (request.url.startsWith('http') && !(SERVER_API_URL && request.url.startsWith(SERVER_API_URL)))) {
return next.handle(request);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/core/auth/account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class AccountService {
}

hasAnyAuthority(authorities: string[] | string): boolean {
if (!this.userIdentity || !this.userIdentity.authorities) {
if (!this.userIdentity?.authorities) {
return false;
}
if (!Array.isArray(authorities)) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/webapp/app/home/ci-cd/ci-cd.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ export class CiCdComponent implements OnInit {
ngOnInit(): void {
this.gitConfig = this.gitConfigurationService.gitConfig;
if (this.gitConfig) {
this.gitlabConfigured = this.gitConfig.gitlabConfigured || false;
this.githubConfigured = this.gitConfig.githubConfigured || false;
this.gitlabConfigured = this.gitConfig.gitlabConfigured ?? false;
this.githubConfigured = this.gitConfig.githubConfigured ?? false;
}

this.gitConfigurationService.sharedData.subscribe((gitConfig: GitConfigurationModel) => {
this.gitConfig = gitConfig;
this.gitlabConfigured = gitConfig.gitlabConfigured || false;
this.githubConfigured = gitConfig.githubConfigured || false;
this.gitlabConfigured = gitConfig.gitlabConfigured ?? false;
this.githubConfigured = gitConfig.githubConfigured ?? false;
});
}

Expand Down
14 changes: 7 additions & 7 deletions src/main/webapp/app/home/generator/generator.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ export class GeneratorComponent implements OnInit {
this.languageOptions = GeneratorComponent.getAllSupportedLanguageOptions();
this.gitConfig = this.gitConfigurationService.gitConfig;
if (this.gitConfig) {
this.gitlabConfigured = this.gitConfig.gitlabConfigured || false;
this.githubConfigured = this.gitConfig.githubConfigured || false;
this.gitlabConfigured = this.gitConfig.gitlabConfigured ?? false;
this.githubConfigured = this.gitConfig.githubConfigured ?? false;
}
this.gitConfigurationService.sharedData.subscribe((gitConfig: GitConfigurationModel) => {
if (gitConfig) {
this.gitlabConfigured = gitConfig.gitlabConfigured || false;
this.githubConfigured = gitConfig.githubConfigured || false;
this.gitlabConfigured = gitConfig.gitlabConfigured ?? false;
this.githubConfigured = gitConfig.githubConfigured ?? false;
}
});
}
Expand Down Expand Up @@ -273,8 +273,8 @@ export class GeneratorComponent implements OnInit {

changeDatabaseType(): void {
if (this.model.databaseType === 'sql') {
this.model.prodDatabaseType = AllProdDatabaseTypes.find(type => !this.isProdDatabaseOptionHidden('sql', type)) || 'mysql';
this.model.devDatabaseType = AllDevDatabaseTypes.find(type => !this.isDevDatabaseOptionHidden('sql', type)) || 'h2Disk';
this.model.prodDatabaseType = AllProdDatabaseTypes.find(type => !this.isProdDatabaseOptionHidden('sql', type)) ?? 'mysql';
this.model.devDatabaseType = AllDevDatabaseTypes.find(type => !this.isDevDatabaseOptionHidden('sql', type)) ?? 'h2Disk';
this.model.cacheProvider = 'ehcache';
this.model.enableHibernateCache = true;
} else if (this.model.databaseType === 'mongodb') {
Expand Down Expand Up @@ -310,7 +310,7 @@ export class GeneratorComponent implements OnInit {

if (this.model.databaseType === 'sql') {
// Find first allowed dev database type
this.model.devDatabaseType = AllDevDatabaseTypes.find(type => !this.isDevDatabaseOptionHidden('sql', type)) || 'h2Disk';
this.model.devDatabaseType = AllDevDatabaseTypes.find(type => !this.isDevDatabaseOptionHidden('sql', type)) ?? 'h2Disk';
} else if (this.model.prodDatabaseType === 'mongodb') {
this.model.devDatabaseType = 'mongodb';
this.model.cacheProvider = 'no';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export class JHipsterConfigurationModel {
constructor(data?: Partial<JHipsterConfigurationModel>) {
if (data) {
const dataCopy = { ...data };
dataCopy.testFrameworks = [...(data.testFrameworks || [])];
dataCopy.languages = [...(data.languages || [])];
dataCopy.testFrameworks = [...(data.testFrameworks ?? [])];
dataCopy.languages = [...(data.languages ?? [])];
Object.assign(this, data);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/webapp/app/home/git/git.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ export class GitComponent implements OnInit {
}

ngOnInit(): void {
this.gitlabConfigured = this.gitConfig.gitlabConfigured || false;
this.githubConfigured = this.gitConfig.githubConfigured || false;
this.gitlabConfigured = this.gitConfig.gitlabConfigured ?? false;
this.githubConfigured = this.gitConfig.githubConfigured ?? false;
this.gitConfigurationService.sharedData.subscribe((gitConfig: GitConfigurationModel) => {
this.gitConfig = gitConfig;
this.gitlabConfigured = gitConfig.gitlabConfigured || false;
this.githubConfigured = gitConfig.githubConfigured || false;
this.gitlabConfigured = gitConfig.gitlabConfigured ?? false;
this.githubConfigured = gitConfig.githubConfigured ?? false;
});

this.gitConfig.availableGitProviders.forEach((provider: any) => {
Expand Down
8 changes: 4 additions & 4 deletions src/main/webapp/app/home/jdl-metadata/jdl-studio.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ export class ApplyJdlStudioComponent implements OnInit, OnDestroy {
private jdlService: JdlService
) {
this.gitConfig = this.gitConfigurationService.gitConfig;
this.gitlabConfigured = this.gitConfig.gitlabConfigured || false;
this.githubConfigured = this.gitConfig.githubConfigured || false;
this.gitlabConfigured = this.gitConfig.gitlabConfigured ?? false;
this.githubConfigured = this.gitConfig.githubConfigured ?? false;
}

ngOnInit(): void {
this.gitConfigurationService.sharedData.subscribe((gitConfig: GitConfigurationModel) => {
this.gitConfig = gitConfig;
this.gitlabConfigured = gitConfig.gitlabConfigured || false;
this.githubConfigured = gitConfig.githubConfigured || false;
this.gitlabConfigured = gitConfig.gitlabConfigured ?? false;
this.githubConfigured = gitConfig.githubConfigured ?? false;
});

this.subscription = this.route.params.subscribe(params => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class JhiGitProviderComponent implements OnInit {
this.data.selectedGitProvider = 'GitHub';
}

this.refreshGitCompanyListByGitProvider(this.data.selectedGitProvider || '');
this.refreshGitCompanyListByGitProvider(this.data.selectedGitProvider ?? '');
}
refreshGitCompanyListByGitProvider(gitProvider: string): void {
if (gitProvider.length === 0) {
Expand Down
24 changes: 12 additions & 12 deletions src/main/webapp/app/shared/model/yo-rc.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ export class YoRC implements IYoRC {
public hasCucumber?: boolean,
public owner?: IGeneratorIdentity
) {
this.enableHibernateCache = this.enableHibernateCache || false;
this.websocket = this.websocket || false;
this.searchEngine = this.searchEngine || false;
this.messageBroker = this.messageBroker || false;
this.serviceDiscoveryType = this.serviceDiscoveryType || false;
this.enableSwaggerCodegen = this.enableSwaggerCodegen || false;
this.withAdminUi = this.withAdminUi || false;
this.useSass = this.useSass || false;
this.enableTranslation = this.enableTranslation || false;
this.hasProtractor = this.hasProtractor || false;
this.hasGatling = this.hasGatling || false;
this.hasCucumber = this.hasCucumber || false;
this.enableHibernateCache = this.enableHibernateCache ?? false;
this.websocket = this.websocket ?? false;
this.searchEngine = this.searchEngine ?? false;
this.messageBroker = this.messageBroker ?? false;
this.serviceDiscoveryType = this.serviceDiscoveryType ?? false;
this.enableSwaggerCodegen = this.enableSwaggerCodegen ?? false;
this.withAdminUi = this.withAdminUi ?? false;
this.useSass = this.useSass ?? false;
this.enableTranslation = this.enableTranslation ?? false;
this.hasProtractor = this.hasProtractor ?? false;
this.hasGatling = this.hasGatling ?? false;
this.hasCucumber = this.hasCucumber ?? false;
}
}