Skip to content

Commit

Permalink
Code quality improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasvajk committed Mar 22, 2024
1 parent 322fb6c commit fa7f437
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Semmle.Extraction.CSharp.Entities
{
internal class CompilerDiagnostic : FreshEntity
{
private static readonly int limit = EnvironmentVariables.TryGetExtractorOption<int>("COMPILER_DIAGNOSTIC_LIMIT") ?? 1000;
private static readonly int limit = EnvironmentVariables.TryGetExtractorNumberOption<int>("COMPILER_DIAGNOSTIC_LIMIT") ?? 1000;
private static readonly ConcurrentDictionary<string, int> messageCounts = new();

private readonly Microsoft.CodeAnalysis.Diagnostic diagnostic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Semmle.Extraction.Entities
{
internal class ExtractionMessage : FreshEntity
{
private static readonly int limit = EnvironmentVariables.TryGetExtractorOption<int>("MESSAGE_LIMIT") ?? 10000;
private static readonly int limit = EnvironmentVariables.TryGetExtractorNumberOption<int>("MESSAGE_LIMIT") ?? 10000;
private static int messageCount = 0;

private readonly Message msg;
Expand Down
2 changes: 1 addition & 1 deletion csharp/extractor/Semmle.Util/EnvironmentVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class EnvironmentVariables
public static string? GetExtractorOption(string name) =>
Environment.GetEnvironmentVariable($"CODEQL_EXTRACTOR_CSHARP_OPTION_{name.ToUpper()}");

public static T? TryGetExtractorOption<T>(string name) where T : struct, INumberBase<T>
public static T? TryGetExtractorNumberOption<T>(string name) where T : struct, INumberBase<T>
{
var value = GetExtractorOption(name);
if (T.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out var result))
Expand Down

0 comments on commit fa7f437

Please sign in to comment.