Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2229 A little refactoring, add new class for interpretting options #2273

Merged
merged 12 commits into from
Jan 29, 2021

Conversation

jameswinkler
Copy link
Collaborator

@jameswinkler jameswinkler commented Jan 27, 2021

Fixes #2229

Move analyzeTestOptions to same project as al other options. Add EnvironmentVariableGetter and OptionsInterpretter classes

…ronmentVariableGetter and OptionsInterpretter classes
{
if (environmentVariableGetter == null)
{
throw new ArgumentException("Required parameter", nameof(environmentVariableGetter));
Copy link
Collaborator

@eddynaka eddynaka Jan 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ArgumentException [](start = 26, length = 17)

Change to argumentNullException. With that, u can you just the nameof(xyz) #Resolved

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could also do this: _environmentVariableGetter = environmentVariableGetter ?? throw new ArgumentNullException(nameof(enviromentVariableGetter));


In reply to: 566070993 [](ancestors = 566070993)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


In reply to: 566071879 [](ancestors = 566071879,566070993)

analyzeOptionsBase.Level = analyzeOptionsBase.Level.Union(levelsFromEnv);
}

private IEnumerable<T> getOptionEnumFromEnvVar<T>(string propertyName)
Copy link
Collaborator

@eddynaka eddynaka Jan 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getOptionEnumFromEnvVar [](start = 31, length = 23)

GetOptionEnumFromEnvVar #Resolved

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


In reply to: 566072089 [](ancestors = 566072089)


private IEnumerable<T> getOptionEnumFromEnvVar<T>(string propertyName)
{
return _environmentVariableGetter.GetEnvironmentVariable(FormEnvironmentVariableName(propertyName))?.Split(';')?.Select(x => Enum.Parse(typeof(T), x, ignoreCase: true))?.ToList()?.Cast<T>();
Copy link
Collaborator

@eddynaka eddynaka Jan 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_environmentVariableGetter.GetEnvironmentVariable [](start = 19, length = 49)

lets wrap. too long to read in one line #Resolved

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


In reply to: 566072701 [](ancestors = 566072701)

IEnumerable<FailureLevel> levelsFromEnv = getOptionEnumFromEnvVar<FailureLevel>(nameof(analyzeOptionsBase.Level));

// Union in C# is distinct
analyzeOptionsBase.Kind = analyzeOptionsBase.Kind.Union(kindsFromEnv);
Copy link
Collaborator

@eddynaka eddynaka Jan 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Union(kindsFromEnv); [](start = 62, length = 20)

do we need to check for null? #Resolved

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


In reply to: 566073724 [](ancestors = 566073724)

@lgtm-com
Copy link

lgtm-com bot commented Jan 28, 2021

This pull request introduces 2 alerts when merging 5d1e28e into 689b73d - view on LGTM.com

new alerts:

  • 2 for Dereferenced variable may be null

@jameswinkler jameswinkler marked this pull request as ready for review January 28, 2021 21:25
@eddynaka eddynaka merged commit 81ffd65 into main Jan 29, 2021
@eddynaka eddynaka deleted the users/v-jwinkler/#2229_EnvironmentVariables branch January 29, 2021 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SARIF_LEVEL_OVERRIDE, SARIF_KIND_OVERRIDE
2 participants