Skip to content

Commit 1cd902e

Browse files
committed
(maint) Updated according to sonarlint recommendations
1 parent 50c2192 commit 1cd902e

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

Source/GitReleaseManager.Cli/Program.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ namespace GitReleaseManager.Cli
2323
public static class Program
2424
{
2525
private static FileSystem _fileSystem;
26-
private static Config _configuration;
2726
private static IMapper _mapper;
2827
private static IVcsProvider _vcsProvider;
2928

@@ -75,7 +74,7 @@ private static void CreateFiglet(BaseSubOptions options)
7574
}
7675

7776
var version = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
78-
if (version.IndexOf('+') > 0)
77+
if (version.IndexOf('+') >= 0)
7978
{
8079
version = version.Substring(0, version.IndexOf('+'));
8180
}
@@ -223,10 +222,10 @@ private static async Task<int> CreateLabelsAsync(LabelSubOptions subOptions)
223222

224223
private static IVcsProvider GetVcsProvider(BaseVcsOptions subOptions)
225224
{
226-
_configuration = ConfigurationProvider.Provide(subOptions.TargetDirectory ?? Environment.CurrentDirectory, _fileSystem);
225+
var configuration = ConfigurationProvider.Provide(subOptions.TargetDirectory ?? Environment.CurrentDirectory, _fileSystem);
227226

228227
Log.Information("Using {Provider} as VCS Provider", "GitHub");
229-
return new GitHubProvider(_mapper, _configuration, subOptions.UserName, subOptions.Password, subOptions.Token);
228+
return new GitHubProvider(_mapper, configuration, subOptions.UserName, subOptions.Password, subOptions.Token);
230229
}
231230

232231
private static void LogOptions(BaseSubOptions options)

Source/GitReleaseManager/GitHubProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public async Task AddAssets(string owner, string repository, string tagName, ILi
236236

237237
var assetFileName = Path.GetFileName(asset);
238238

239-
var existingAsset = release.Assets.Where(a => a.Name == assetFileName).FirstOrDefault();
239+
var existingAsset = release.Assets.FirstOrDefault(a => a.Name == assetFileName);
240240
if (existingAsset != null)
241241
{
242242
_logger.Warning("Requested asset to be uploaded already exists on draft release, replacing with new file: {AssetPath}", asset);

Source/GitReleaseManager/ReleaseNotesBuilder.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private Milestone GetPreviousMilestone()
165165
var currentVersion = _targetMilestone.Version;
166166
return _milestones
167167
.OrderByDescending(m => m.Version)
168-
.Distinct().ToList()
168+
.Distinct()
169169
.SkipWhile(x => x.Version >= currentVersion)
170170
.FirstOrDefault();
171171
}
@@ -176,16 +176,14 @@ private void AddFooter(StringBuilder stringBuilder)
176176

177177
var footerContent = _configuration.Create.FooterContent;
178178

179-
if (_configuration.Create.FooterIncludesMilestone)
179+
if (_configuration.Create.FooterIncludesMilestone
180+
&& !string.IsNullOrEmpty(_configuration.Create.MilestoneReplaceText))
180181
{
181-
if (!string.IsNullOrEmpty(_configuration.Create.MilestoneReplaceText))
182-
{
183-
var replaceValues = new Dictionary<string, object>
182+
var replaceValues = new Dictionary<string, object>
184183
{
185184
{ _configuration.Create.MilestoneReplaceText.Trim('{', '}'), _milestoneTitle },
186185
};
187-
footerContent = footerContent.ReplaceTemplate(replaceValues);
188-
}
186+
footerContent = footerContent.ReplaceTemplate(replaceValues);
189187
}
190188

191189
stringBuilder.Append(footerContent);

0 commit comments

Comments
 (0)