Skip to content

Commit bd8217d

Browse files
robertcoltheartarturcic
authored andcommitted
fix: fix sonarqube issues
1 parent 32b4f73 commit bd8217d

3 files changed

Lines changed: 8 additions & 14 deletions

File tree

global.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
"new-cli",
55
"src"
66
],
7-
"sdk": {
8-
"version": "10.0.301"
9-
},
107
"test": {
118
"runner": "Microsoft.Testing.Platform"
129
}

src/GitVersion.Core.Tests/Extensions/StringFormatWithExtensionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ public void FormatProperty_NullInteger_WithFallback()
317317
public void FormatProperty_NullObject_WithFallback_Quoted()
318318
{
319319
var propertyObject = new { Property = (object?)null };
320-
const string target = "{Property ?? \"fallback\"}";
320+
const string target = "{Property ?? \"literal\"}";
321321
var actual = target.FormatWith(propertyObject, this.environment);
322-
Assert.That(actual, Is.EqualTo("fallback"));
322+
Assert.That(actual, Is.EqualTo("literal"));
323323
}
324324

325325
[Test]

src/GitVersion.Core/Formatting/StringFormatWithExtension.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,17 @@ private static string EvaluateMatch(string input, Func<string, string?> memberEv
9999
? EvaluateEnvVar(token.Name, environment)
100100
: memberEvaluator(token.Name);
101101

102-
if (value is not null && !string.IsNullOrEmpty(token.Format))
102+
if (value is null)
103103
{
104-
if (ValueFormatter.Default.TryFormat(value, InputSanitizer.SanitizeFormat(token.Format), out var formatted))
105-
{
106-
return formatted;
107-
}
108-
109-
return value;
104+
continue;
110105
}
111106

112-
if (value is not null)
107+
if (!string.IsNullOrEmpty(token.Format) && ValueFormatter.Default.TryFormat(value, InputSanitizer.SanitizeFormat(token.Format), out var formatted))
113108
{
114-
return value;
109+
return formatted;
115110
}
111+
112+
return value;
116113
}
117114
catch (Exception e)
118115
{

0 commit comments

Comments
 (0)