Skip to content

Commit ba9dc59

Browse files
committed
Remove dead and redundant code
1 parent 894bcd8 commit ba9dc59

File tree

10 files changed

+8
-15
lines changed

10 files changed

+8
-15
lines changed

API.IntegrationTests/Tests/AccountTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public async Task CreateAccount_ShouldAdd_NewUserToDatabase()
3535

3636
var user = await db.Users.FirstOrDefaultAsync(u => u.Email == "bob@example.com");
3737

38-
await Assert.That(user is not null).IsTrue();
38+
await Assert.That(user).IsNotNull();
3939
}
4040

4141
[Test, DependsOn(nameof(CreateAccount_ShouldAdd_NewUserToDatabase))]

API/Controller/Shares/DeleteShareCode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public sealed partial class SharesController
2424
[MapToApiVersion("1")]
2525
public async Task<IActionResult> DeleteShareCode([FromRoute] Guid shareCodeId)
2626
{
27-
var affected = await Queryable
28-
.Where<ShockerShareCode>(_db.ShockerShareCodes, x => x.Id == shareCodeId)
27+
var affected = await _db.ShockerShareCodes
28+
.Where(x => x.Id == shareCodeId)
2929
.WhereIsUserOrPrivileged(x => x.Shocker.Device.Owner, CurrentUser)
3030
.ExecuteDeleteAsync();
3131
if (affected <= 0)

API/Controller/Shares/LinkShareCode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public async Task<IActionResult> LinkShareCode(
3131
[FromServices] IDeviceUpdateService deviceUpdateService
3232
)
3333
{
34-
var shareCode = await Queryable.Where<ShockerShareCode>(_db.ShockerShareCodes, x => x.Id == shareCodeId && x.Shocker.Device.Owner.UserDeactivation == null).Select(x => new
34+
var shareCode = await _db.ShockerShareCodes.Where(x => x.Id == shareCodeId && x.Shocker.Device.Owner.UserDeactivation == null).Select(x => new
3535
{
3636
Share = x, x.Shocker.Device.OwnerId, x.Shocker.DeviceId
3737
}).FirstOrDefaultAsync();
3838
if (shareCode is null) return Problem(ShareCodeError.ShareCodeNotFound);
3939
if (shareCode.OwnerId == CurrentUser.Id) return Problem(ShareCodeError.CantLinkOwnShareCode);
40-
if (await EntityFrameworkQueryableExtensions.AnyAsync<UserShare>(_db.UserShares, x => x.ShockerId == shareCode.Share.ShockerId && x.SharedWithUserId == CurrentUser.Id))
40+
if (await _db.UserShares.AnyAsync(x => x.ShockerId == shareCode.Share.ShockerId && x.SharedWithUserId == CurrentUser.Id))
4141
return Problem(ShareCodeError.ShockerAlreadyLinked);
4242

4343
_db.UserShares.Add(new UserShare

API/Controller/Shares/UserShares/Invites.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ public async Task<IActionResult> RedeemInvite([FromRoute] Guid inviteId, [FromSe
159159
}
160160

161161
_db.UserShareInvites.Remove(shareRequest);
162-
var a = _db.ChangeTracker.ToDebugString();
163162

164163
if (await _db.SaveChangesAsync() < 1) throw new Exception("Error while linking share code to your account");
165164

API/Services/Account/IAccountService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ public interface IAccountService
125125
Task<bool> TryVerifyEmailAsync(string token, CancellationToken cancellationToken = default);
126126
}
127127

128-
public sealed record CreateUserLoginSessionSuccess(User User, string Token);
129128
public readonly struct AccountIsOAuthOnly;
130129
public readonly struct AccountNotActivated;
131130
public readonly struct AccountDeactivated;

API/Services/Account/LoginContext.cs

Lines changed: 0 additions & 3 deletions
This file was deleted.

Common.Tests/Query/ExpressionBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public async Task Boolean_TrueMatches()
145145
var result = TestArray.AsQueryable().Where(expression).ToArray();
146146

147147
// Assert
148-
await Assert.That(result).ContainsOnly(x => x.IsActive == true);
148+
await Assert.That(result).ContainsOnly(x => x.IsActive);
149149
}
150150

151151
[Test]

Common/Services/Configuration/ConfigurationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private static bool IsValidValueFormat(ConfigurationValueType type, string value
5151
{
5252
return type switch
5353
{
54-
ConfigurationValueType.String => value is not null,
54+
ConfigurationValueType.String => true,
5555
ConfigurationValueType.Bool => bool.TryParse(value, out _),
5656
ConfigurationValueType.Int => int.TryParse(value, CultureInfo.InvariantCulture, out _),
5757
ConfigurationValueType.Float => float.TryParse(value, CultureInfo.InvariantCulture, out float f) && (float.IsNormal(f) || f == 0f),

Common/Utils/JsonWebSocketUtils.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ public static class JsonWebSocketUtils
2222
{
2323
ValueWebSocketReceiveResult result;
2424
await using var message = RecyclableMemory.GetStream();
25-
var bytes = 0;
2625
do
2726
{
2827
result = await socket.ReceiveAsync(new Memory<byte>(buffer), cancellationToken);
29-
bytes += result.Count;
3028
if (result.MessageType == WebSocketMessageType.Close)
3129
{
3230
return new WebsocketClosure();

LiveControlGateway/LifetimeManager/HubLifetime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private async Task DeviceMessage(DeviceMessage message)
208208
await OtaInstall(version);
209209
break;
210210
default:
211-
_logger.LogError("Got DeviceMessage with unknown payload type: {PayloadType}", message.Payload?.GetType().Name);
211+
_logger.LogError("Got DeviceMessage with unknown payload type: {PayloadType}", message.Payload.GetType().Name);
212212
break;
213213
}
214214
}

0 commit comments

Comments
 (0)