Fix SonarQube code smells:

1) String literals should not be duplicated.
2) Prefer using an optional chain expression instead, as it's more concise and easier to read.
3) Expected the Promise rejection reason to be an Error.
This commit is contained in:
Akshay Joshi
2024-06-10 18:04:32 +05:30
parent 2d2aa45ec5
commit 8857f0d179
57 changed files with 210 additions and 205 deletions

View File

@@ -19,7 +19,7 @@ import { isEmptyString } from 'sources/validators';
import PropTypes from 'prop-types';
import gettext from 'sources/gettext';
const StyledSchemaView= styled(SchemaView)(() =>
const StyledSchemaView= styled(SchemaView)(() =>
({
'& .aws-formClass': {
overflow: 'auto',
@@ -90,7 +90,7 @@ export function AwsInstanceDetails(props) {
resolve(data);
})
.catch((err)=>{
reject(err);
reject(new Error(err));
});
} else {
resolve(options);

View File

@@ -72,7 +72,7 @@ export function AzureCredentials(props) {
})
.catch((error)=>{
clearInterval(interval);
reject(error);
reject(new Error(error));
});
}, 1000);
});

View File

@@ -122,7 +122,7 @@ class AzureCredSchema extends BaseUISchema {
}));
})
.catch((err)=>{
reject(err);
reject(new Error(err));
});
}
});
@@ -152,7 +152,7 @@ class AzureCredSchema extends BaseUISchema {
});
})
.catch((err)=>{
reject(err);
reject(new Error(err));
});
}
});

View File

@@ -87,7 +87,7 @@ export function GoogleCredentials(props) {
})
.catch((error)=>{
clearInterval(interval);
reject(error);
reject(new Error(error));
});
countdown = countdown - 1;
}, 1000);

View File

@@ -68,13 +68,13 @@ class GoogleCredSchema extends BaseUISchema{
resolve();
})
.catch((err)=>{
reject(err);
reject(new Error(err));
});
}
});
})
.catch((err)=>{
reject(err);
reject(new Error(err));
});
}
});