Skip to content

Commit 22ba9d3

Browse files
committed
Fix naming convention and reduce duplication
1 parent 6fb9701 commit 22ba9d3

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/NuGet.Core/NuGet.Protocol/Utility/PackageIdValidator.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ internal static class PackageIdValidator
1414
{
1515
private const string DisableValidationEnvVar = "NUGET_DISABLE_PACKAGEID_VALIDATION";
1616

17-
private static readonly Lazy<bool> _isValidationDisabled = new Lazy<bool>(() =>
18-
string.Equals(
19-
EnvironmentVariableWrapper.Instance.GetEnvironmentVariable(DisableValidationEnvVar),
20-
"true",
21-
StringComparison.OrdinalIgnoreCase));
17+
private static readonly Lazy<bool> IsValidationDisabled = new Lazy<bool>(() =>
18+
IsPackageIdValidationDisabled(EnvironmentVariableWrapper.Instance));
2219

2320
/// <summary>
2421
/// Validates the package ID content.
@@ -30,8 +27,8 @@ internal static class PackageIdValidator
3027
internal static void Validate(string packageId, IEnvironmentVariableReader env = null)
3128
{
3229
bool isDisabled = env == null
33-
? _isValidationDisabled.Value
34-
: string.Equals(env.GetEnvironmentVariable(DisableValidationEnvVar), "true", StringComparison.OrdinalIgnoreCase);
30+
? IsValidationDisabled.Value
31+
: IsPackageIdValidationDisabled(env);
3532

3633
if (!isDisabled)
3734
{
@@ -41,5 +38,8 @@ internal static void Validate(string packageId, IEnvironmentVariableReader env =
4138
}
4239
}
4340
}
41+
42+
private static bool IsPackageIdValidationDisabled(IEnvironmentVariableReader env) =>
43+
string.Equals(env.GetEnvironmentVariable(DisableValidationEnvVar), "true", StringComparison.OrdinalIgnoreCase);
4444
}
4545
}

0 commit comments

Comments
 (0)