Skip to content

Commit

Permalink
fix: codacy problems
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardSmit committed Jan 28, 2024
1 parent 0090722 commit d1797b7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace MangaMagnet.Api.Service;

public class BroadcastProgressService(ProgressService progressService, WebSocketService webSocketService, IOptions<JsonOptions> jsonOptions) : BackgroundService
{
/// <inheritdoc />
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
try
Expand Down
2 changes: 1 addition & 1 deletion backend/MangaMagnet.Api/Service/WebSocketService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void RemoveSocket(Guid id)
/// </summary>
/// <param name="memory">Message to send.</param>
/// <param name="stoppingToken">Cancellation token.</param>
public async Task SendToAllAsync(ReadOnlyMemory<byte> memory, CancellationToken stoppingToken = default)
public async Task SendToAllAsync(ReadOnlyMemory<byte> memory, CancellationToken stoppingToken)
{
foreach (var socket in _sockets.Values)
{
Expand Down
7 changes: 6 additions & 1 deletion backend/MangaMagnet.Core/Progress/Models/ProgressTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ private bool SetField<T>(ref T field, T value, [CallerMemberName] string? proper
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
field = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

if (PropertyChanged is not null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}

return true;
}

Expand Down
16 changes: 12 additions & 4 deletions backend/MangaMagnet.Core/Util/PooledArrayBufferWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ public sealed class PooledArrayBufferWriter<T> : IBufferWriter<T>, IDisposable
/// <summary>
/// Initializes a new instance of the <see cref="PooledArrayBufferWriter{T}"/> class.
/// </summary>
/// <param name="pool">The pool to use. Defaults to <see cref="ArrayPool{T}.Shared"/>.</param>
public PooledArrayBufferWriter(ArrayPool<T>? pool = null)
public PooledArrayBufferWriter()
: this(ArrayPool<T>.Shared)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="PooledArrayBufferWriter{T}"/> class.
/// </summary>
/// <param name="pool">The pool to use.</param>
public PooledArrayBufferWriter(ArrayPool<T> pool)
{
_pool = pool ?? ArrayPool<T>.Shared;
_buffer = _pool.Rent(InitialBufferSize);
Expand Down Expand Up @@ -50,7 +58,7 @@ public void Advance(int count)
}

/// <inheritdoc />
public Memory<T> GetMemory(int sizeHint = 0)
public Memory<T> GetMemory(int sizeHint)
{
if (_buffer.Length - _index < sizeHint)
{
Expand All @@ -61,7 +69,7 @@ public Memory<T> GetMemory(int sizeHint = 0)
}

/// <inheritdoc />
public Span<T> GetSpan(int sizeHint = 0)
public Span<T> GetSpan(int sizeHint)
{
return GetMemory(sizeHint).Span;
}
Expand Down

0 comments on commit d1797b7

Please sign in to comment.