Skip to content

Commit 94fdcc2

Browse files
committed
fix sonar
1 parent 634eb6a commit 94fdcc2

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

libraries/src/AWS.Lambda.Powertools.EventHandler/Internal/LRUCache.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace AWS.Lambda.Powertools.EventHandler.Internal;
66
/// <summary>
77
/// Simple LRU cache implementation for caching route resolutions
88
/// </summary>
9-
internal class LRUCache<TKey, TValue> where TKey : notnull
9+
internal class LruCache<TKey, TValue> where TKey : notnull
1010
{
1111
private readonly int _capacity;
1212
private readonly Dictionary<TKey, LinkedListNode<CacheItem>> _cache;
@@ -24,7 +24,7 @@ public CacheItem(TKey key, TValue value)
2424
}
2525
}
2626

27-
public LRUCache(int capacity)
27+
public LruCache(int capacity)
2828
{
2929
_capacity = capacity;
3030
_cache = new Dictionary<TKey, LinkedListNode<CacheItem>>();

libraries/src/AWS.Lambda.Powertools.EventHandler/Internal/RouteHandlerRegistry.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal class RouteHandlerRegistry<TEvent, TResult>
1414
/// <summary>
1515
/// Cache for resolved routes to improve performance
1616
/// </summary>
17-
private readonly LRUCache<string, RouteHandlerOptions<TEvent, TResult>> _resolverCache;
17+
private readonly LruCache<string, RouteHandlerOptions<TEvent, TResult>> _resolverCache;
1818

1919
/// <summary>
2020
/// Set to track already logged warnings
@@ -27,7 +27,7 @@ internal class RouteHandlerRegistry<TEvent, TResult>
2727
/// <param name="cacheSize">Max size of LRU cache (default 100)</param>
2828
public RouteHandlerRegistry(int cacheSize = 100)
2929
{
30-
_resolverCache = new LRUCache<string, RouteHandlerOptions<TEvent, TResult>>(cacheSize);
30+
_resolverCache = new LruCache<string, RouteHandlerOptions<TEvent, TResult>>(cacheSize);
3131
}
3232

3333
/// <summary>
@@ -98,7 +98,7 @@ public IEnumerable<RouteHandlerOptions<TEvent, TResult>> GetAllHandlers()
9898
/// </summary>
9999
private static bool IsValidPath(string path)
100100
{
101-
if (string.IsNullOrWhiteSpace(path) || !path.StartsWith("/"))
101+
if (string.IsNullOrWhiteSpace(path) || !path.StartsWith('/'))
102102
return false;
103103

104104
// Check for invalid wildcard usage

libraries/tests/AWS.Lambda.Powertools.EventHandler.Tests/RouteHandlerRegistryTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public void ResolveFirst_ShouldUseCacheForRepeatedPaths()
179179
public void LRUCache_ShouldEvictOldestItemsWhenFull()
180180
{
181181
// Arrange - Create a cache with size 2
182-
var cache = new LRUCache<string, string>(2);
182+
var cache = new LruCache<string, string>(2);
183183

184184
// Act
185185
cache.Set("key1", "value1");

0 commit comments

Comments
 (0)