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/
|
||||
*.css.map
|
||||
# SixLabors license file
|
||||
/Lactose/sixlabors.lic
|
||||
/Lactose/sixlabors.lic
|
||||
.desloppify/
|
||||
.claude/
|
||||
scorecard.png
|
||||
@@ -39,7 +39,7 @@ public enum Settings {
|
||||
/// <summary>
|
||||
/// Provides extension methods for the <see cref="Settings"/> enum.
|
||||
/// </summary>
|
||||
public static class SettingsExtensions {
|
||||
public static class SettingsExtension {
|
||||
/// <summary>
|
||||
/// Converts a <see cref="Settings"/> value to its human-readable display string.
|
||||
/// </summary>
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Lactose.Controllers;
|
||||
Active = false
|
||||
};
|
||||
|
||||
folderRepository.Create(newFolder);
|
||||
folderRepository.Insert(newFolder);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace Lactose.Controllers;
|
||||
|
||||
if (accessLevel != EAccessLevel.Admin) { return Unauthorized(); }
|
||||
|
||||
folderRepository.Delete(id);
|
||||
folderRepository.Remove(id);
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Lactose.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Lactose.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Lactose.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Lactose.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Lactose.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Lactose.Context;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class FolderRepository(LactoseDbContext context) : IFolderRepository, IAs
|
||||
static void OnFolderRemoved(Folder e) => FolderRemoved?.Invoke(null, e);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Create(Folder folder) {
|
||||
public void Insert(Folder folder) {
|
||||
context.Folders.Add(folder);
|
||||
context.SaveChanges();
|
||||
if (folder.Active) OnFolderAdded(folder);
|
||||
@@ -48,7 +48,7 @@ public class FolderRepository(LactoseDbContext context) : IFolderRepository, IAs
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Delete(Guid id) {
|
||||
public void Remove(Guid id) {
|
||||
var folder = context.Folders.Find(id);
|
||||
|
||||
if (folder != null) {
|
||||
|
||||
@@ -10,7 +10,7 @@ public interface IFolderRepository : IDisposable {
|
||||
/// Creates a new folder.
|
||||
/// </summary>
|
||||
/// <param name="folder">The folder to create.</param>
|
||||
void Create(Folder folder);
|
||||
void Insert(Folder folder);
|
||||
|
||||
/// <summary>
|
||||
/// Updates an existing folder.
|
||||
@@ -20,10 +20,10 @@ public interface IFolderRepository : IDisposable {
|
||||
void Update(Guid id, Folder folder);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a folder by ID.
|
||||
/// Removes a folder by ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The ID of the folder to delete.</param>
|
||||
void Delete(Guid id);
|
||||
/// <param name="id">The ID of the folder to remove.</param>
|
||||
void Remove(Guid id);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a folder by ID.
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Lactose.Repositories;
|
||||
/// <summary>
|
||||
/// Interface for media repository to handle media data retrieval.
|
||||
/// </summary>
|
||||
public interface IMediaRepository {
|
||||
public interface IMediaRepository : IDisposable {
|
||||
/// <summary>
|
||||
/// Retrieves the original media data.
|
||||
/// </summary>
|
||||
|
||||
@@ -3,6 +3,8 @@ using Butter.Dtos.Person;
|
||||
using Butter.Types;
|
||||
using Lactose.Models;
|
||||
|
||||
namespace Lactose.Repositories;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for person repository operations.
|
||||
/// </summary>
|
||||
|
||||
@@ -52,7 +52,7 @@ public interface ITagRepository : IDisposable {
|
||||
/// Deletes a tag by the given <paramref name="id"/>
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
void Delete(Tag id);
|
||||
void Delete(Tag tag);
|
||||
|
||||
/// <summary>
|
||||
/// Insert a new Tag
|
||||
|
||||
@@ -131,8 +131,11 @@ public sealed class LoginService : ServiceBase {
|
||||
AuthInfo? auth = null;
|
||||
try {
|
||||
auth = await localStorage.GetItemAsync<AuthInfo>("auth");
|
||||
} catch {
|
||||
try { await localStorage.RemoveItemAsync("auth"); } catch { }
|
||||
} catch (Exception ex) {
|
||||
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)
|
||||
@@ -191,7 +194,9 @@ public sealed class LoginService : ServiceBase {
|
||||
var failureResult = await response.Content.ReadFromJsonAsync<AuthResultDto>();
|
||||
if (!string.IsNullOrEmpty(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);
|
||||
}
|
||||
@@ -253,7 +258,9 @@ public sealed class LoginService : ServiceBase {
|
||||
ForceLogout?.Invoke(error);
|
||||
return;
|
||||
}
|
||||
} catch { /* best-effort */ }
|
||||
} catch (Exception ex) {
|
||||
logger.LogWarning(ex, "Failed to parse refresh failure response");
|
||||
}
|
||||
|
||||
ForceLogoutReason = "Session expired. Please log in again.";
|
||||
await Logout();
|
||||
@@ -288,12 +295,16 @@ public sealed class LoginService : ServiceBase {
|
||||
logger.LogInformation("Logging out current user with ID: {AuthInfoUserId}", authInfo?.UserId);
|
||||
try {
|
||||
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;
|
||||
LoggedUser = null;
|
||||
try {
|
||||
await localStorage.RemoveItemAsync("auth");
|
||||
} catch { }
|
||||
} catch (Exception ex) {
|
||||
logger.LogWarning(ex, "Failed to clear auth from local storage");
|
||||
}
|
||||
logger.LogInformation("Logout completed");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user