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

Sonar => Reduce code duplication

parent 92e13a3d
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ class SharedAssignmentHelper { ...@@ -20,7 +20,7 @@ class SharedAssignmentHelper {
} }
async isPublishable(repositoryId: number): Promise<{ isPublishable: boolean, lastPipeline: Gitlab.PipelineSchema | null, status?: { code: DojoStatusCode, message: string } }> { async isPublishable(repositoryId: number): Promise<{ isPublishable: boolean, lastPipeline: Gitlab.PipelineSchema | null, status?: { code: DojoStatusCode, message: string } }> {
const pipelines = await GlobalHelper.sharedGitlabManager.getRepositoryPipelines(repositoryId, 'main'); const pipelines = await GlobalHelper.gitlabManager.getRepositoryPipelines(repositoryId, 'main');
if ( pipelines.length > 0 ) { if ( pipelines.length > 0 ) {
const lastPipeline = pipelines[0]; const lastPipeline = pipelines[0];
if ( lastPipeline.status !== GitlabPipelineStatus.SUCCESS.valueOf() ) { if ( lastPipeline.status !== GitlabPipelineStatus.SUCCESS.valueOf() ) {
......
class SharedExerciseHelper {}
export default new SharedExerciseHelper();
\ No newline at end of file
...@@ -8,7 +8,7 @@ import { StatusCodes } from 'http-status-c ...@@ -8,7 +8,7 @@ import { StatusCodes } from 'http-status-c
class SharedGitlabManager { class SharedGitlabManager {
private api!: GitlabCore.Gitlab<false>; protected api!: GitlabCore.Gitlab<false>;
private readonly refreshTokenFunction?: () => Promise<string>; private readonly refreshTokenFunction?: () => Promise<string>;
setToken(token: string) { setToken(token: string) {
...@@ -23,7 +23,7 @@ class SharedGitlabManager { ...@@ -23,7 +23,7 @@ class SharedGitlabManager {
this.setToken(token); this.setToken(token);
} }
private async executeGitlabRequest<T>(request: () => Promise<T>, refreshTokenIfNeeded: boolean = true): Promise<T> { protected async executeGitlabRequest<T>(request: () => Promise<T>, refreshTokenIfNeeded: boolean = true): Promise<T> {
try { try {
return await request(); return await request();
} catch ( error ) { } catch ( error ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment