Skip to content

Commit 83e3129

Browse files
committed
Sonar cleanup
1 parent c9ea440 commit 83e3129

File tree

13 files changed

+23
-27
lines changed

13 files changed

+23
-27
lines changed

electron/app/js/helmUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ function getHelmEnv(httpsProxyUrl, bypassProxyHosts, helmOptions) {
212212
env['NO_PROXY'] = bypassProxyHosts;
213213
}
214214
env['PATH'] = process.env.PATH;
215-
if (helmOptions && helmOptions.extraPathDirectories &&
215+
if (helmOptions?.extraPathDirectories &&
216216
Array.isArray(helmOptions.extraPathDirectories) && helmOptions.extraPathDirectories.length > 0) {
217217
const extraPathDirectories = helmOptions.extraPathDirectories.join(path.delimiter);
218218
getLogger().debug('extraPathDirectories = %s', extraPathDirectories);

electron/app/js/imageBuilderUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ function getDockerEnv(httpsProxyUrl, bypassProxyHosts, imageBuilderOptions) {
202202
env['no_proxy'] = bypassProxyHosts;
203203
}
204204

205-
if (imageBuilderOptions && imageBuilderOptions.extraEnvironmentVariables) {
205+
if (imageBuilderOptions?.extraEnvironmentVariables) {
206206
const extraEnvironmentVariables =
207207
osUtils.removeProtectedEnvironmentVariables(imageBuilderOptions.extraEnvironmentVariables);
208208
env = Object.assign(env, extraEnvironmentVariables);

electron/app/js/kubectlUtils.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ function getKubectlEnvironment(options, httpsProxyUrl, bypassProxyHosts) {
764764
env['PROGRAMDATA'] = process.env.PROGRAMDATA;
765765
}
766766

767-
if (options && options.extraEnvironmentVariables) {
767+
if (options?.extraEnvironmentVariables) {
768768
const extraEnvironmentVariables =
769769
osUtils.removeProtectedEnvironmentVariables(options.extraEnvironmentVariables);
770770
env = Object.assign(env, extraEnvironmentVariables);
@@ -774,10 +774,7 @@ function getKubectlEnvironment(options, httpsProxyUrl, bypassProxyHosts) {
774774

775775
function getOperatorImageTag(operatorDeployment) {
776776
let imageTag;
777-
if (operatorDeployment.spec
778-
&& operatorDeployment.spec.template
779-
&& operatorDeployment.spec.template.spec
780-
&& operatorDeployment.spec.template.spec.containers) {
777+
if (operatorDeployment.spec?.template?.spec?.containers) {
781778
const containers = operatorDeployment.spec.template.spec.containers;
782779

783780
for (const container of containers) {
@@ -886,7 +883,7 @@ async function isVerrazzanoInstalled(kubectlExe, options) {
886883
result.name = vzObject.metadata?.name;
887884

888885
let statusVersion = vzObject.status?.version;
889-
if (statusVersion && statusVersion.startsWith('v')) {
886+
if (statusVersion?.startsWith('v')) {
890887
statusVersion = statusVersion.slice(1);
891888
}
892889
result.version = statusVersion;

electron/app/js/modelArchive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ async function _removePathFromArchive(archiveFile, zip, zipPath) {
364364
try {
365365
if (zip.file(zipPath)) {
366366
zip.remove(zipPath);
367-
} else if (zipPath && zipPath.endsWith('/')) {
367+
} else if (zipPath?.endsWith('/')) {
368368
// Remove the trailing slash so the target folder is also removed, not just its contents...
369369
zip.remove(zipPath.slice(0, -1));
370370
}

electron/app/js/prompt/about.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function promptRegister() {
5959
window.addEventListener('error', error => {
6060
if (promptId) {
6161
const text = error.message ? error.message : error;
62-
promptError('An error has occurred on the about window: \n' + text);
62+
promptError('An error has occurred on the about window: \n' + JSON.stringify(text));
6363
}
6464
});
6565

electron/app/js/prompt/credential-passphrase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function promptRegister() {
6969
window.addEventListener('error', error => {
7070
if (promptId) {
7171
const text = error.message ? error.message : error;
72-
promptError('An error has occurred on the prompt window: \n' + text);
72+
promptError('An error has occurred on the prompt window: \n' + JSON.stringify(text));
7373
}
7474
});
7575

electron/app/js/wktLogging.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function logRendererMessage(windowId, level, message, ...args) {
6666
}
6767

6868
function getDefaultLogDirectory(wktMode) {
69-
if (wktMode && wktMode.isExecutableMode()) {
69+
if (wktMode?.isExecutableMode()) {
7070
return _getDefaultLogDir();
7171
}
7272
return process.cwd();

electron/app/js/wktTools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function isWitErrorExitCode(exitCode) {
6868

6969
async function isWdtVersionCompatible(minimumVersion) {
7070
const wdtVersionFileName = path.join(getWdtDirectory(), 'VERSION.txt');
71-
const versionRegex = /^WebLogic Deploy Tooling (?<version>[\d]+.[\d]+.[\d]+(-SNAPSHOT)?)$/;
71+
const versionRegex = /^WebLogic Deploy Tooling (?<version>\d+.\d+.\d+(-SNAPSHOT)?)$/;
7272
const result = {
7373
isSuccess: true
7474
};

electron/app/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class Main {
225225
};
226226

227227
// This should never be null by the time it gets to this point but check anyway...
228-
if (this._appUpdatePromise) {
228+
if (this._appUpdatePromise !== null) {
229229
this._appUpdatePromise.then(updateResult => {
230230
if (updateResult) {
231231
startupInformation.update = updateResult;

electron/build/notarize.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function findPackageJsonPath() {
2626
function getAppId(context) {
2727
// Try to get the appId from the packager
2828
const config = context.packager.info._configuration;
29-
if (config && config.appId) {
29+
if (config?.appId) {
3030
console.log('Found appId in packager');
3131
return config.appId;
3232
}
@@ -47,7 +47,7 @@ function getAppId(context) {
4747
if (packageJsonFilePath) {
4848
try {
4949
const packageJson = require(packageJsonFilePath);
50-
if (packageJson['build'] && packageJson['build']['appId']) {
50+
if (packageJson['build']?.['appId']) {
5151
console.log('Found appId in %s', packageJsonFilePath);
5252
return packageJson['build']['appId'];
5353
}

0 commit comments

Comments
 (0)