Skip to content

Misleading conditional in ConfigProvider #19029

@omajid

Description

@omajid

if (outputBasePath.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
outputBasePath = Path.GetDirectoryName(outputBasePath);
newConfig.AddProperty("OutputPath", Path.Combine(outputBasePath, configName) + Path.DirectorySeparatorChar.ToString());

A code quality tool flagged that the indentation here, suggesting that newConfig.AddProperty... is only executed when the codition is true, doesn't match the actual semantics. There's no {, } immediately following the condition, so the first statement will only be executed when the condition is true, but newConfig.AddProperty(...) will be executed no matter what.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions