Skip to content

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.

Fixing sonar code quality recommendations

Andrew Song2d066ea36cff
diff --git a/API/Controllers/LibraryController.cs b/API/Controllers/LibraryController.cs
index 42fa27659..a20bc1cda 100644
--- a/API/Controllers/LibraryController.cs
+++ b/API/Controllers/LibraryController.cs
@@ -61,20 +61,7 @@ namespace API.Controllers
{
return Ok(await _libraryRepository.GetLibrariesAsync());
}
-
-
- // Do I need this method?
- // [HttpGet("library/{username}")]
- // public async Task<ActionResult<IEnumerable<LibraryDto>>> GetLibrariesForUser(string username)
- // {
- // _logger.LogDebug("Method hit");
- // var user = await _userRepository.GetUserByUsernameAsync(User.GetUsername());
- //
- // if (user == null) return BadRequest("Could not validate user");
- //
- // return Ok(await _libraryRepository.GetLibrariesForUserAsync(user));
- // }
-
+
[Authorize(Policy = "RequireAdminRole")]
[HttpPut("update-for")]
public async Task<ActionResult<MemberDto>> UpdateLibrary(UpdateLibraryDto updateLibraryDto)
diff --git a/API/Controllers/UsersController.cs b/API/Controllers/UsersController.cs
index 3b546b21f..28d1a3916 100644
--- a/API/Controllers/UsersController.cs
+++ b/API/Controllers/UsersController.cs
@@ -30,7 +30,6 @@ namespace API.Controllers
{
// NOTE: I think we should move this into library controller because it gets added to all admins
- //_logger.Log(LogLevel.Debug, "Creating a new " + createLibraryDto.Type + " library");
var user = await _userRepository.GetUserByUsernameAsync(User.GetUsername());
if (user == null) return BadRequest("Could not validate user");
diff --git a/API/Data/Seed.cs b/API/Data/Seed.cs
index c03407e95..cd90243c4 100644
--- a/API/Data/Seed.cs
+++ b/API/Data/Seed.cs
@@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Identity;
namespace API.Data
{
- public class Seed
+ public static class Seed
{
public static async Task SeedRoles(RoleManager<AppRole> roleManager)
{
diff --git a/API/Program.cs b/API/Program.cs
index 7ed8e7175..bafc68d4c 100644
--- a/API/Program.cs
+++ b/API/Program.cs
@@ -13,6 +13,10 @@ namespace API
{
public class Program
{
+ protected Program()
+ {
+ }
+
public static async Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
@@ -37,7 +41,7 @@ namespace API
await host.RunAsync();
}
- public static IHostBuilder CreateHostBuilder(string[] args) =>
+ private static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
diff --git a/API/Startup.cs b/API/Startup.cs
index b691a71a4..c98d4064d 100644
--- a/API/Startup.cs
+++ b/API/Startup.cs
@@ -39,7 +39,6 @@ namespace API
if (env.IsDevelopment())
{
- //app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "API v1"));
}