Skip to content
Snippets Groups Projects
Commit d99e0364 authored by michael.minelli's avatar michael.minelli
Browse files

Sonar => Remove code smells

parent 3e86a9ea
Branches
No related tags found
No related merge requests found
...@@ -21,5 +21,6 @@ export default tseslint.config({ ...@@ -21,5 +21,6 @@ export default tseslint.config({
'@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/require-await': 'off', '@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-template-expressions': 'off', '@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-floating-promises': 'off',
} }
}); });
\ No newline at end of file
...@@ -15,6 +15,8 @@ import GitlabPipelineStatus from '../shared/types/Gitlab/GitlabPipelineStatus.j ...@@ -15,6 +15,8 @@ import GitlabPipelineStatus from '../shared/types/Gitlab/GitlabPipelineStatus.j
class DojoBackendManager { class DojoBackendManager {
private handleApiError(error: unknown, spinner: ora.Ora, verbose: boolean, defaultErrorMessage?: string, otherErrorHandler?: (error: AxiosError, spinner: ora.Ora, verbose: boolean) => void) { private handleApiError(error: unknown, spinner: ora.Ora, verbose: boolean, defaultErrorMessage?: string, otherErrorHandler?: (error: AxiosError, spinner: ora.Ora, verbose: boolean) => void) {
const unknownErrorMessage: string = 'unknown error';
if ( verbose ) { if ( verbose ) {
if ( error instanceof AxiosError ) { if ( error instanceof AxiosError ) {
switch ( error.response?.data?.code ) { switch ( error.response?.data?.code ) {
...@@ -37,19 +39,19 @@ class DojoBackendManager { ...@@ -37,19 +39,19 @@ class DojoBackendManager {
spinner.fail(`Assignment creation error: The assignment name already exists. Please choose another name.`); spinner.fail(`Assignment creation error: The assignment name already exists. Please choose another name.`);
break; break;
case DojoStatusCode.ASSIGNMENT_CREATION_GITLAB_ERROR: case DojoStatusCode.ASSIGNMENT_CREATION_GITLAB_ERROR:
spinner.fail(`Assignment creation error: An unknown error occurred while creating the assignment on GitLab (internal error message: ${ error.response?.data?.description ?? 'unknown error' }). Please try again later or contact an administrator.`); spinner.fail(`Assignment creation error: An unknown error occurred while creating the assignment on GitLab (internal error message: ${ error.response?.data?.description ?? unknownErrorMessage }). Please try again later or contact an administrator.`);
break; break;
case DojoStatusCode.ASSIGNMENT_CREATION_INTERNAL_ERROR: case DojoStatusCode.ASSIGNMENT_CREATION_INTERNAL_ERROR:
spinner.fail(`Assignment creation error: An unknown error occurred while creating the assignment (internal error message: ${ error.response?.data?.description ?? 'unknown error' }). Please try again later or contact an administrator.`); spinner.fail(`Assignment creation error: An unknown error occurred while creating the assignment (internal error message: ${ error.response?.data?.description ?? unknownErrorMessage }). Please try again later or contact an administrator.`);
break; break;
case DojoStatusCode.MAX_EXERCISE_PER_ASSIGNMENT_REACHED: case DojoStatusCode.MAX_EXERCISE_PER_ASSIGNMENT_REACHED:
spinner.fail(`The following users have reached the maximum number of exercise of this assignment : ${ ((error.response.data as DojoBackendResponse<Array<Gitlab.UserSchema>>).data).map(user => user.name).join(', ') }.`); spinner.fail(`The following users have reached the maximum number of exercise of this assignment : ${ ((error.response.data as DojoBackendResponse<Array<Gitlab.UserSchema>>).data).map(user => user.name).join(', ') }.`);
break; break;
case DojoStatusCode.EXERCISE_CREATION_INTERNAL_ERROR: case DojoStatusCode.EXERCISE_CREATION_INTERNAL_ERROR:
spinner.fail(`Exercise creation error: An unknown error occurred while creating the exercise (internal error message: ${ error.response?.data?.description ?? 'unknown error' }). Please try again later or contact an administrator.`); spinner.fail(`Exercise creation error: An unknown error occurred while creating the exercise (internal error message: ${ error.response?.data?.description ?? unknownErrorMessage }). Please try again later or contact an administrator.`);
break; break;
case DojoStatusCode.EXERCISE_CREATION_GITLAB_ERROR: case DojoStatusCode.EXERCISE_CREATION_GITLAB_ERROR:
spinner.fail(`Exercise creation error: An unknown error occurred while creating the exercise on GitLab (internal error message: ${ error.response?.data?.description ?? 'unknown error' }). Please try again later or contact an administrator.`); spinner.fail(`Exercise creation error: An unknown error occurred while creating the exercise on GitLab (internal error message: ${ error.response?.data?.description ?? unknownErrorMessage }). Please try again later or contact an administrator.`);
break; break;
case DojoStatusCode.GITLAB_TEMPLATE_NOT_FOUND: case DojoStatusCode.GITLAB_TEMPLATE_NOT_FOUND:
spinner.fail(`Template not found or access denied. Please check the template ID or url. Also, please check that the template have public/internal visibility or that your and Dojo account (${ ClientsSharedConfig.gitlab.dojoAccount.username }) have at least reporter role to the template (if private).`); spinner.fail(`Template not found or access denied. Please check the template ID or url. Also, please check that the template have public/internal visibility or that your and Dojo account (${ ClientsSharedConfig.gitlab.dojoAccount.username }) have at least reporter role to the template (if private).`);
......
...@@ -156,7 +156,7 @@ class SessionManager { ...@@ -156,7 +156,7 @@ class SessionManager {
text : `Waiting for user to authorize the application in his web browser. If the browser does not open automatically, please go to : ${ Config.login.gitlab.url.code }`, text : `Waiting for user to authorize the application in his web browser. If the browser does not open automatically, please go to : ${ Config.login.gitlab.url.code }`,
indent: 4 indent: 4
}).start(); }).start();
void open(Config.login.gitlab.url.code).then(); open(Config.login.gitlab.url.code).then();
}); });
loginServer.events.on('error', (error: string) => { loginServer.events.on('error', (error: string) => {
currentSpinner.fail(`Login server error: ${ error }`); currentSpinner.fail(`Login server error: ${ error }`);
......
Subproject commit 771f8cd079b39ec4050c5ece024dc4d70f342529 Subproject commit c2afa861bf6306ddec79ffd465a4c7b0edcd3453
Subproject commit 8514d5ef589a8aa34e4d2260c618781d81368c22 Subproject commit 4256114048734c2708436cc8505abecdf62fe6df
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment