Skip to content

Commit d6226a8

Browse files
committed
- Fix lint issues
1 parent 47d431b commit d6226a8

31 files changed

Lines changed: 331 additions & 328 deletions

src/FeatureOne.File/Extensions/FeatureOneFileExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public static IServiceCollection AddFeatureOneWithFileStorage(this IServiceColle
2626
throw new ArgumentNullException("FileConfiguration is required.");
2727

2828
return services
29-
.AddFeatureOne(provider=>
29+
.AddFeatureOne(provider =>
3030
new FileStorageProvider(configuration,
3131
new FileReader(configuration),
32-
deserializer?? new ToggleDeserializer(new ConditionDeserializer()),
32+
deserializer ?? new ToggleDeserializer(new ConditionDeserializer()),
3333
cache ?? new FeatureCache()));
3434
}
3535
}

src/FeatureOne.File/StorageProvider/FileReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Text;
4-
using System.Threading;
53
using System.Security.Cryptography;
4+
using System.Text;
65
using System.Text.Json;
76
using System.Text.Json.Nodes;
7+
using System.Threading;
88

99
namespace FeatureOne.File.StorageProvider
1010
{

src/FeatureOne/Core/Toggles/Conditions/DateRangeCondition.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ public class DateRangeCondition : ICondition
1111
public bool Evaluate(IDictionary<string, string> claims)
1212
{
1313
var now = DateTime.Now.Date; // Use just the date part for comparison
14-
14+
1515
if (StartDate.HasValue && now < StartDate.Value.Date)
1616
return false;
17-
17+
1818
if (EndDate.HasValue && now > EndDate.Value.Date)
1919
return false;
20-
20+
2121
return true;
2222
}
2323
}

src/FeatureOne/DefaultLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public DefaultLogger(ILogger<IFeatureLogger> logger)
1111
{
1212
this.logger = logger;
1313
}
14+
1415
public void Info(string message)
1516
{
1617
logger?.LogInformation(message);
@@ -19,7 +20,6 @@ public void Info(string message)
1920
public void Debug(string message)
2021
{
2122
logger?.LogDebug(message);
22-
2323
}
2424

2525
public void Warn(string message)

src/FeatureOne/Extensions/FeatureOneServiceExtensions.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
using System;
12
using FeatureOne;
23
using FeatureOne.Core.Stores;
3-
using System;
44
using Microsoft.Extensions.Logging;
55

66
namespace Microsoft.Extensions.DependencyInjection
@@ -20,13 +20,12 @@ public static IServiceCollection AddFeatureOne(this IServiceCollection services,
2020
{
2121
if (storageProviderFactory == null)
2222
throw new ArgumentNullException(nameof(storageProviderFactory));
23-
2423

2524
return services
2625
.AddSingleton<IStorageProvider>(provider => storageProviderFactory(provider))
27-
.AddSingleton<IFeatureLogger, DefaultLogger>(provider=> new DefaultLogger(provider.GetService<ILogger<IFeatureLogger>>()))
26+
.AddSingleton<IFeatureLogger, DefaultLogger>(provider => new DefaultLogger(provider.GetService<ILogger<IFeatureLogger>>()))
2827
.AddSingleton<IFeatureStore>(provider => new FeatureStore(provider.GetRequiredService<IStorageProvider>(), provider.GetRequiredService<IFeatureLogger>()))
29-
.AddSingleton<IFeatures, Features>(provider => new Features(provider.GetRequiredService<IFeatureStore>(), provider.GetRequiredService<IFeatureLogger>()));
30-
}
28+
.AddSingleton<IFeatures, Features>(provider => new Features(provider.GetRequiredService<IFeatureStore>(), provider.GetRequiredService<IFeatureLogger>()));
29+
}
3130
}
3231
}

src/FeatureOne/IFeatures.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ namespace FeatureOne
66
public interface IFeatures
77
{
88
bool IsEnabled(string name);
9+
910
bool IsEnabled(string name, ClaimsPrincipal principal);
11+
1012
bool IsEnabled(string name, IDictionary<string, string> claims);
13+
1114
bool IsEnabled(string name, IEnumerable<Claim> claims);
1215
}
1316
}

src/FeatureOne/Json/ConditionDeserializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public ICondition CreateInstance(NamePostFix conditionName)
4141
// NamePostFix transforms both "Simple" and "SimpleCondition" to "SimpleCondition"
4242
// So we look up the processed name
4343
var processedName = conditionName.Name;
44-
44+
4545
if (SafeConditionTypes.TryGetValue(processedName, out Type type))
4646
{
4747
return (ICondition)Activator.CreateInstance(type, true);
4848
}
49-
49+
5050
// This shouldn't normally happen with correct inputs since NamePostFix standardizes the format
5151
throw new Exception($"Could not find a toggle type for: '{processedName}'. Only supported types are: {string.Join(", ", SafeConditionTypes.Keys)}");
5252
}

src/FeatureOne/Validation/ConfigurationValidator.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public ValidationResult ValidateCondition(ICondition condition)
3333
return ValidateRegexCondition(regexCondition);
3434
else if (condition is DateRangeCondition dateRangeCondition)
3535
return ValidateDateRangeCondition(dateRangeCondition);
36-
36+
3737
return new ValidationResult(true, null);
3838
}
3939

@@ -55,7 +55,7 @@ private ValidationResult ValidateRegexCondition(RegexCondition condition)
5555

5656
private ValidationResult ValidateDateRangeCondition(DateRangeCondition condition)
5757
{
58-
if (condition.StartDate.HasValue && condition.EndDate.HasValue &&
58+
if (condition.StartDate.HasValue && condition.EndDate.HasValue &&
5959
condition.StartDate.Value > condition.EndDate.Value)
6060
return new ValidationResult(false, "Start date cannot be after end date");
6161

@@ -124,7 +124,7 @@ private bool HasPotentiallyDangerousAlternation(string pattern)
124124
// If we can't parse it, be conservative
125125
return true;
126126
}
127-
127+
128128
return false;
129129
}
130130

@@ -137,12 +137,12 @@ private bool HasComplexNestedStructure(string pattern)
137137

138138
for (int i = 0; i < chars.Length; i++)
139139
{
140-
if (chars[i] == '(' && (i == 0 || chars[i-1] != '\\')) // Not escaped
140+
if (chars[i] == '(' && (i == 0 || chars[i - 1] != '\\')) // Not escaped
141141
{
142142
groupDepth++;
143143
maxDepth = Math.Max(maxDepth, groupDepth);
144144
}
145-
else if (chars[i] == ')' && (i == 0 || chars[i-1] != '\\')) // Not escaped
145+
else if (chars[i] == ')' && (i == 0 || chars[i - 1] != '\\')) // Not escaped
146146
{
147147
groupDepth--;
148148
}
@@ -167,7 +167,7 @@ private bool HasComplexNestedStructure(string pattern)
167167
private bool HasSpecificDangerousPatterns(string pattern)
168168
{
169169
// Check for specific patterns known to cause ReDoS
170-
170+
171171
// Look for nested quantifiers like ([^...]*.*)+ or (.*[^...]+)*
172172
if (Regex.IsMatch(pattern, @"\([^+*]*[\*\+][^+*]*\)[\*\+]", RegexOptions.IgnoreCase))
173173
{

test/FeatureOne.File.Tests/Extensions/FeatureOneFileExtensionsTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using Microsoft.Extensions.DependencyInjection;
2-
using FeatureOne.File.Extensions;
31
using FeatureOne.Cache;
2+
using FeatureOne.File.Extensions;
43
using FeatureOne.Json;
4+
using Microsoft.Extensions.DependencyInjection;
55
using Moq;
66

77
namespace FeatureOne.File.Tests.Extensions;
@@ -34,7 +34,7 @@ public void AddFeatureOneWithFileStorage_WithNullConfiguration_ThrowsArgumentNul
3434
// Act & Assert
3535
var exception = Assert.Throws<ArgumentNullException>(
3636
() => services.AddFeatureOneWithFileStorage(configuration));
37-
37+
3838
Assert.That(exception.Message, Does.Contain("FileConfiguration is required."));
3939
}
4040

test/FeatureOne.File.Tests/UnitTests/FileStorageProviderTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System.Runtime.Caching;
22
using FeatureOne.Cache;
33
using FeatureOne.File;
4-
using FeatureOne.Json;
54
using FeatureOne.File.StorageProvider;
5+
using FeatureOne.Json;
66
using Moq;
77

88
namespace FeatureOne.SQL.Tests.UnitTests

0 commit comments

Comments
 (0)