Code Smells from Service
continuous-integration/drone/push Build is passing Details

master
tomivt 2 months ago
parent 2018e18e10
commit 0bead3de61

@ -37,7 +37,7 @@ namespace WF_WebAdmin.Service
}
public async Task<int> getNbLogs()
public Task<int> getNbLogs()
{
throw new NotImplementedException();
}
@ -45,9 +45,9 @@ namespace WF_WebAdmin.Service
public async Task<List<Logs>> getSomeLogs(int nb, int page)
{
var logs = await getAllLogs();
if ((page - 1) * nb + nb > logs.Count())
if ((page - 1) * nb + nb > logs.Count)
{
return logs.GetRange(logs.Count() - nb, nb);
return logs.GetRange(logs.Count - nb, nb);
}
return logs.GetRange((page - 1) * nb, nb);

@ -134,7 +134,7 @@ public class QuizServiceStub: IQuizService
public async Task<List<Quiz>> getQuizzesToValidate()
{
var quizzes = await getQuizzes();
return quizzes.Where(quiz => quiz.IsValid == false).ToList();
return quizzes.Where(quiz => !quiz.IsValid).ToList();
}
@ -151,11 +151,11 @@ public class QuizServiceStub: IQuizService
{
var data = await getQuizzes();
var q = data.FirstOrDefault(p => p.Id == id);
if (q != null)
if (q == null)
{
return q;
throw new KeyNotFoundException($"Quiz with ID {id} not found.");
}
return null;
return q;
}
/// <summary>
@ -173,13 +173,13 @@ public class QuizServiceStub: IQuizService
public async Task<List<Quiz>> getSommeQuiz(int nb, int page)
{
var data = await getQuizzes();
if ((page - 1) * nb + nb > data.Count())
if ((page - 1) * nb + nb > data.Count)
{
if (nb > data.Count())
if (nb > data.Count)
{
return data.GetRange(0, data.Count() - 1);
return data.GetRange(0, data.Count - 1);
}
return data.GetRange(data.Count() - nb, nb);
return data.GetRange(data.Count - nb, nb);
}
return data.GetRange((page - 1) * nb, nb);
}

@ -38,7 +38,7 @@ namespace WF_WebAdmin.Service
/*
// Ajouter des paramètres à la commande
Ajouter des paramètres à la commande
command.Parameters.AddWithValue("@content", quote.Content);
command.Parameters.AddWithValue("@langue", quote.Langue);
command.Parameters.AddWithValue("@reason", "À vérifier"); // Vous pouvez changer ça si nécessaire
@ -110,10 +110,10 @@ namespace WF_WebAdmin.Service
public Task validQuote(Quote quote)
{
QuoteExtension extension = new QuoteExtension();
QuoteDto quoteDTO = extension.QuoteToDTO(quote);
QuoteDto quoteDto = extension.QuoteToDTO(quote);
// Return the DTO as the result of this asynchronous operation (though no validation logic is currently implemented)
return Task.FromResult(quoteDTO);
return Task.FromResult(quoteDto);
}

@ -71,7 +71,7 @@ namespace WF_WebAdmin.Service;
}
public async Task validQuote(Quote quote)
public Task validQuote(Quote quote)
{
throw new NotImplementedException();
}
@ -170,15 +170,15 @@ namespace WF_WebAdmin.Service;
{
var data = await getAllQuote();
var q = data.FirstOrDefault(p => p.Id == id);
if (q != null)
if (q == null)
{
return q;
throw new KeyNotFoundException($"Quote with ID {id} not found.");
}
return null;
return q;
}
public async Task<List<Quote>> reserchQuote(string reserch, List<string> argument)
public Task<List<Quote>> reserchQuote(string reserch, List<string> argument)
{
throw new NotImplementedException();
}
@ -196,7 +196,7 @@ namespace WF_WebAdmin.Service;
public async Task<List<Quote>> getAllQuoteInvalid()
{
var quotes = await getAllQuote();
quotes = quotes.Where(q => q.IsValid == false).ToList();
quotes = quotes.Where(q => !q.IsValid).ToList();
return quotes;
}
@ -218,13 +218,13 @@ namespace WF_WebAdmin.Service;
public async Task<List<Quote>> getSomeQuoteInvalid(int nb, int page)
{
var quotes = await getAllQuoteInvalid();
if ((page - 1) * nb + nb > quotes.Count())
if ((page - 1) * nb + nb > quotes.Count)
{
if (nb > quotes.Count())
if (nb > quotes.Count)
{
return quotes.GetRange(0, quotes.Count());
return quotes.GetRange(0, quotes.Count);
}
return quotes.GetRange(quotes.Count() - nb, nb);
return quotes.GetRange(quotes.Count - nb, nb);
}
return quotes.GetRange((page - 1) * nb, nb);
}

@ -116,9 +116,9 @@ public class UserServiceStub : IUserService
public async Task<List<User>> getSomeUser(int nb, int page)
{
var users = await getAllUser();
if ((page - 1) * nb + nb > users.Count())
if ((page - 1) * nb + nb > users.Count)
{
return users.GetRange(users.Count() - nb, nb);
return users.GetRange(users.Count - nb, nb);
}
return users.GetRange((page - 1) * nb, nb);
}
@ -137,12 +137,14 @@ public class UserServiceStub : IUserService
public async Task<User> getOneUser(int id)
{
var data = await getAllUser();
var u = data.FirstOrDefault(p => p.Id == id);
if (u != null)
var user = data.FirstOrDefault(p => p.Id == id);
if (user == null)
{
return u;
throw new KeyNotFoundException($"User with ID {id} not found.");
}
return null;
return user;
}

Loading…
Cancel
Save