Skip to content

Commit

Permalink
fix: sonar code smells.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianareginalino committed Nov 29, 2023
1 parent 8fc3f14 commit b923e4b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Liquid.Adapter.AzureStorage/BlobClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class BlobClientFactory : IBlobClientFactory
/// </summary>
/// <param name="options">Configurations set.</param>
/// <exception cref="ArgumentNullException"></exception>
public BlobClientFactory(IOptions<StorageSettings> options)
public BlobClientFactory(IOptions<StorageSettings>? options)
{
_options = options?.Value ?? throw new ArgumentNullException(nameof(options));
}
Expand Down
9 changes: 5 additions & 4 deletions src/Liquid.Adapter.AzureStorage/BlobStorageAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public async Task DeleteByTags(IDictionary<string, string> tags, string containe

foreach (var tag in tags)
{
stringFilter = stringFilter + @$"""{tag.Key}"" = '{tag.Value}' AND ";
stringFilter += @$"""{tag.Key}"" = '{tag.Value}' AND ";

Check warning on line 36 in src/Liquid.Adapter.AzureStorage/BlobStorageAdapter.cs

View workflow job for this annotation

GitHub Actions / call-reusable-build-workflow / build

Use a StringBuilder instead.

Check warning on line 36 in src/Liquid.Adapter.AzureStorage/BlobStorageAdapter.cs

View workflow job for this annotation

GitHub Actions / call-reusable-build-workflow / build

Use a StringBuilder instead.
}

var filter = stringFilter.Substring(0, stringFilter.Length - 4);
stringFilter = stringFilter.Substring(0, stringFilter.Length - 4);

await foreach (TaggedBlobItem blobItem in client.FindBlobsByTagsAsync(filter))
await foreach (TaggedBlobItem blobItem in client.FindBlobsByTagsAsync(stringFilter))
{
var blockBlob = client.GetBlockBlobClient(blobItem.BlobName);

Expand Down Expand Up @@ -87,9 +87,10 @@ public async Task<List<LiquidBlob>> ReadBlobsByTags(IDictionary<string, string>
var stringFilter = string.Empty;
foreach (var tag in tags)
{
stringFilter = stringFilter + @$"""{tag.Key}"" = '{tag.Value}' AND ";
stringFilter += @$"""{tag.Key}"" = '{tag.Value}' AND ";

Check warning on line 90 in src/Liquid.Adapter.AzureStorage/BlobStorageAdapter.cs

View workflow job for this annotation

GitHub Actions / call-reusable-build-workflow / build

Use a StringBuilder instead.

Check warning on line 90 in src/Liquid.Adapter.AzureStorage/BlobStorageAdapter.cs

View workflow job for this annotation

GitHub Actions / call-reusable-build-workflow / build

Use a StringBuilder instead.
}
stringFilter = stringFilter.Substring(0, stringFilter.Length - 4);

var results = new List<LiquidBlob>();
await foreach (TaggedBlobItem blobItem in client.FindBlobsByTagsAsync(stringFilter))
{
Expand Down
6 changes: 6 additions & 0 deletions src/Liquid.Adapter.AzureStorage/ILiquidBlobStorageAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,44 @@ public interface ILiquidBlobStorageAdapter
/// </summary>
/// <param name="data">Blob content.</param>
/// <param name="name">Blob path.</param>
/// <param name="containerName">Blob container name.</param>
/// <param name="tags">Blob list of tags.</param>
Task UploadBlob(string data, string name, string containerName, IDictionary<string, string>? tags = null);

/// <summary>
/// Remove blob by id.
/// </summary>
/// <param name="id">blob name.</param>
/// <param name="containerName">Blob container name.</param>
Task Delete(string id, string containerName);

/// <summary>
/// Filter blob by tags and remove them.
/// </summary>
/// <param name="tags">Tags for filter.</param>
/// <param name="containerName">Blob container name.</param>
Task DeleteByTags(IDictionary<string, string> tags, string containerName);

/// <summary>
/// Get all blobs from a container.
/// </summary>
/// <param name="containerName">Blob container name.</param>
/// <returns>List of <see cref="LiquidBlob"/>.</returns>
Task<List<LiquidBlob>> GetAllBlobs(string containerName);

/// <summary>
/// Filter blobs by tags.
/// </summary>
/// <param name="tags">Tags for filter.</param>
/// <param name="containerName">Blob container name.</param>
/// <returns>List of <see cref="LiquidBlob"/>.</returns>
Task<List<LiquidBlob>> ReadBlobsByTags(IDictionary<string, string> tags, string containerName);

/// <summary>
/// Dowload a specific blob.
/// </summary>
/// <param name="blobName">Blob Id.</param>
/// <param name="containerName">Blob container name.</param>
/// <returns><see cref="LiquidBlob"/>.</returns>
Task<LiquidBlob> ReadBlobsByName(string blobName, string containerName);

Expand Down
5 changes: 4 additions & 1 deletion src/Liquid.Adapter.AzureStorage/LiquidBlob.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
namespace Liquid.Adapter.AzureStorage
using System.Diagnostics.CodeAnalysis;

namespace Liquid.Adapter.AzureStorage
{
/// <summary>
/// Set de propriedades referentes à um item do BlobStorage.
/// </summary>
[ExcludeFromCodeCoverage]
public class LiquidBlob
{
/// <summary>
Expand Down

0 comments on commit b923e4b

Please sign in to comment.