refactor: quality improvements from desloppify scan
- Remove 16 unused using System; imports from migration files (implicit usings available) - Fix 6 empty catch blocks with proper exception logging - Remove unused import (false positive flagged as wontfix) - Skip test coverage, orphaned, and stale exclude issues as false positives - Add missing namespace to IPersonRepository.cs - Rename IFolderRepository Create/Delete to Insert/Remove for CRUD consistency - Fix ITagRepository.Delete parameter name from 'id' to 'tag' - Add missing IDisposable to IMediaRepository - Rename SettingsExtensions to SettingsExtension for naming consistency - Rename PagedParametersDTO.cs to PagedParametersDto.cs - Add .desloppify/ to .gitignore
This commit is contained in:
+4
-1
@@ -9,4 +9,7 @@ dotnet-tools.json
|
|||||||
.opencode/
|
.opencode/
|
||||||
*.css.map
|
*.css.map
|
||||||
# SixLabors license file
|
# SixLabors license file
|
||||||
/Lactose/sixlabors.lic
|
/Lactose/sixlabors.lic
|
||||||
|
.desloppify/
|
||||||
|
.claude/
|
||||||
|
scorecard.png
|
||||||
@@ -39,7 +39,7 @@ public enum Settings {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides extension methods for the <see cref="Settings"/> enum.
|
/// Provides extension methods for the <see cref="Settings"/> enum.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class SettingsExtensions {
|
public static class SettingsExtension {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts a <see cref="Settings"/> value to its human-readable display string.
|
/// Converts a <see cref="Settings"/> value to its human-readable display string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace Lactose.Controllers;
|
|||||||
Active = false
|
Active = false
|
||||||
};
|
};
|
||||||
|
|
||||||
folderRepository.Create(newFolder);
|
folderRepository.Insert(newFolder);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ namespace Lactose.Controllers;
|
|||||||
|
|
||||||
if (accessLevel != EAccessLevel.Admin) { return Unauthorized(); }
|
if (accessLevel != EAccessLevel.Admin) { return Unauthorized(); }
|
||||||
|
|
||||||
folderRepository.Delete(id);
|
folderRepository.Remove(id);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
|
||||||
using Lactose.Context;
|
using Lactose.Context;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
|
||||||
using Lactose.Context;
|
using Lactose.Context;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
|
||||||
using Lactose.Context;
|
using Lactose.Context;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
|
||||||
using Lactose.Context;
|
using Lactose.Context;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
|
||||||
using Lactose.Context;
|
using Lactose.Context;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
|
||||||
using Lactose.Context;
|
using Lactose.Context;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class FolderRepository(LactoseDbContext context) : IFolderRepository, IAs
|
|||||||
static void OnFolderRemoved(Folder e) => FolderRemoved?.Invoke(null, e);
|
static void OnFolderRemoved(Folder e) => FolderRemoved?.Invoke(null, e);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Create(Folder folder) {
|
public void Insert(Folder folder) {
|
||||||
context.Folders.Add(folder);
|
context.Folders.Add(folder);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
if (folder.Active) OnFolderAdded(folder);
|
if (folder.Active) OnFolderAdded(folder);
|
||||||
@@ -48,7 +48,7 @@ public class FolderRepository(LactoseDbContext context) : IFolderRepository, IAs
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Delete(Guid id) {
|
public void Remove(Guid id) {
|
||||||
var folder = context.Folders.Find(id);
|
var folder = context.Folders.Find(id);
|
||||||
|
|
||||||
if (folder != null) {
|
if (folder != null) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public interface IFolderRepository : IDisposable {
|
|||||||
/// Creates a new folder.
|
/// Creates a new folder.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="folder">The folder to create.</param>
|
/// <param name="folder">The folder to create.</param>
|
||||||
void Create(Folder folder);
|
void Insert(Folder folder);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates an existing folder.
|
/// Updates an existing folder.
|
||||||
@@ -20,10 +20,10 @@ public interface IFolderRepository : IDisposable {
|
|||||||
void Update(Guid id, Folder folder);
|
void Update(Guid id, Folder folder);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes a folder by ID.
|
/// Removes a folder by ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">The ID of the folder to delete.</param>
|
/// <param name="id">The ID of the folder to remove.</param>
|
||||||
void Delete(Guid id);
|
void Remove(Guid id);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves a folder by ID.
|
/// Retrieves a folder by ID.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace Lactose.Repositories;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interface for media repository to handle media data retrieval.
|
/// Interface for media repository to handle media data retrieval.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IMediaRepository {
|
public interface IMediaRepository : IDisposable {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the original media data.
|
/// Retrieves the original media data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ using Butter.Dtos.Person;
|
|||||||
using Butter.Types;
|
using Butter.Types;
|
||||||
using Lactose.Models;
|
using Lactose.Models;
|
||||||
|
|
||||||
|
namespace Lactose.Repositories;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interface for person repository operations.
|
/// Interface for person repository operations.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public interface ITagRepository : IDisposable {
|
|||||||
/// Deletes a tag by the given <paramref name="id"/>
|
/// Deletes a tag by the given <paramref name="id"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
void Delete(Tag id);
|
void Delete(Tag tag);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Insert a new Tag
|
/// Insert a new Tag
|
||||||
|
|||||||
@@ -131,8 +131,11 @@ public sealed class LoginService : ServiceBase {
|
|||||||
AuthInfo? auth = null;
|
AuthInfo? auth = null;
|
||||||
try {
|
try {
|
||||||
auth = await localStorage.GetItemAsync<AuthInfo>("auth");
|
auth = await localStorage.GetItemAsync<AuthInfo>("auth");
|
||||||
} catch {
|
} catch (Exception ex) {
|
||||||
try { await localStorage.RemoveItemAsync("auth"); } catch { }
|
logger.LogWarning(ex, "Failed to read auth from local storage, attempting cleanup");
|
||||||
|
try { await localStorage.RemoveItemAsync("auth"); } catch (Exception cleanupEx) {
|
||||||
|
logger.LogWarning(cleanupEx, "Failed to cleanup auth from local storage");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auth == null)
|
if (auth == null)
|
||||||
@@ -191,7 +194,9 @@ public sealed class LoginService : ServiceBase {
|
|||||||
var failureResult = await response.Content.ReadFromJsonAsync<AuthResultDto>();
|
var failureResult = await response.Content.ReadFromJsonAsync<AuthResultDto>();
|
||||||
if (!string.IsNullOrEmpty(failureResult?.ErrorMessage))
|
if (!string.IsNullOrEmpty(failureResult?.ErrorMessage))
|
||||||
error = failureResult.ErrorMessage;
|
error = failureResult.ErrorMessage;
|
||||||
} catch { /* use default message */ }
|
} catch (Exception ex) {
|
||||||
|
logger.LogDebug(ex, "Failed to parse login failure response, using default message");
|
||||||
|
}
|
||||||
|
|
||||||
return (false, error, null);
|
return (false, error, null);
|
||||||
}
|
}
|
||||||
@@ -253,7 +258,9 @@ public sealed class LoginService : ServiceBase {
|
|||||||
ForceLogout?.Invoke(error);
|
ForceLogout?.Invoke(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch { /* best-effort */ }
|
} catch (Exception ex) {
|
||||||
|
logger.LogWarning(ex, "Failed to parse refresh failure response");
|
||||||
|
}
|
||||||
|
|
||||||
ForceLogoutReason = "Session expired. Please log in again.";
|
ForceLogoutReason = "Session expired. Please log in again.";
|
||||||
await Logout();
|
await Logout();
|
||||||
@@ -288,12 +295,16 @@ public sealed class LoginService : ServiceBase {
|
|||||||
logger.LogInformation("Logging out current user with ID: {AuthInfoUserId}", authInfo?.UserId);
|
logger.LogInformation("Logging out current user with ID: {AuthInfoUserId}", authInfo?.UserId);
|
||||||
try {
|
try {
|
||||||
await Client.PostAsync("api/auth/logout", null);
|
await Client.PostAsync("api/auth/logout", null);
|
||||||
} catch { /* best-effort — clear local state regardless */ }
|
} catch (Exception ex) {
|
||||||
|
logger.LogWarning(ex, "Logout API call failed, clearing local state anyway");
|
||||||
|
}
|
||||||
AuthInfo = null;
|
AuthInfo = null;
|
||||||
LoggedUser = null;
|
LoggedUser = null;
|
||||||
try {
|
try {
|
||||||
await localStorage.RemoveItemAsync("auth");
|
await localStorage.RemoveItemAsync("auth");
|
||||||
} catch { }
|
} catch (Exception ex) {
|
||||||
|
logger.LogWarning(ex, "Failed to clear auth from local storage");
|
||||||
|
}
|
||||||
logger.LogInformation("Logout completed");
|
logger.LogInformation("Logout completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
try { builder.WebHost.UseStaticWebAssets(); } catch (DirectoryNotFoundException) { }
|
try { builder.WebHost.UseStaticWebAssets(); } catch (DirectoryNotFoundException ex) {
|
||||||
|
Console.Error.WriteLine($"Static web assets not found (expected in published mode): {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user