Skip to content

Commit

Permalink
Resolve roslyn suggestions in the Build project
Browse files Browse the repository at this point in the history
  • Loading branch information
SonnyRR committed Oct 16, 2024
1 parent 4525132 commit 5921c9a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
18 changes: 8 additions & 10 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Build()
[GitRepository]
readonly GitRepository GitRepository;

[GitVersion(UpdateBuildNumber = true)]
[GitVersion(UpdateBuildNumber = true)]
readonly GitVersion GitVersion;

[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
Expand All @@ -47,13 +47,13 @@ public Build()
[Parameter("The GitHub user account that will be used to push the Docker image to the container registry")]
readonly string GitHubUsername;

[Parameter("The git author username, used for tagging release commits.")]
[Parameter("The git author username, used for tagging release commits.")]
readonly string GitAuthorUsername;

[Parameter("The git author email, used for tagging release commits.")]
[Parameter("The git author email, used for tagging release commits.")]
readonly string GitAuthorEmail;

[Parameter("The docker image name.")]
[Parameter("The docker image name.")]
readonly string ImageName = "magic-8-ball-api:dockerfile";

readonly AbsolutePath ApiProject = RootDirectory / "src" / ApiAssemblyName;
Expand Down Expand Up @@ -81,10 +81,9 @@ public Build()
.SetInformationalVersion(GitVersion.InformationalVersion)
.EnableNoRestore());

Log.Information("Current semver: {version}", GitVersion.MajorMinorPatch);
Log.Information("Current semver: {@Version}", GitVersion.MajorMinorPatch);
});


[SuppressMessage("ReSharper", "UnusedMember.Local")]
Target BuildApiImageWithBuiltInContainerSupport => _ => _
.DependsOn(Compile)
Expand All @@ -99,7 +98,6 @@ public Build()
.SetPublishProfile("DefaultContainer"));
});


[SuppressMessage("ReSharper", "UnusedMember.Local")]
Target BuildApiImageWithDockerfile => _ => _
.DependsOn(Compile)
Expand Down Expand Up @@ -128,8 +126,8 @@ public Build()
retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)),
(ex, _, retryCount, _) =>
{
Log.Warning($"Docker login exited with code: '{ex}'");
Log.Information($"Attempting to login into GitHub Docker image registry. Try #{retryCount}");
Log.Warning(ex, "Docker login was unsuccessful");
Log.Information("Attempting to login into GitHub Docker image registry. Try #{RetryCount}", retryCount);
})
.Execute(() => DockerLogin(settings => settings
.SetServer(GitHubImageRegistry)
Expand Down Expand Up @@ -167,6 +165,6 @@ public Build()
Git($"config user.name \"{GitAuthorUsername}\"");

Git($"tag -a {GitVersion.FullSemVer} -m \"Release: '{GitVersion.FullSemVer}'\"");
Git($"push --follow-tags");
Git("push --follow-tags");
});
}
11 changes: 3 additions & 8 deletions build/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
using System;
using System.ComponentModel;
using System.Linq;
using Nuke.Common.Tooling;

[TypeConverter(typeof(TypeConverter<Configuration>))]
public class Configuration : Enumeration
{
public static Configuration Debug = new Configuration { Value = nameof(Debug) };
public static Configuration Release = new Configuration { Value = nameof(Release) };
public static readonly Configuration Debug = new() { Value = nameof(Debug) };
public static readonly Configuration Release = new() { Value = nameof(Release) };

public static implicit operator string(Configuration configuration)
{
return configuration.Value;
}
public static implicit operator string(Configuration configuration) => configuration.Value;
}
10 changes: 10 additions & 0 deletions build/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("Roslynator", "RCS1110:Declare type inside namespace", Justification = "<Pending>", Scope = "module")]
[assembly: SuppressMessage("Major Bug", "S3903:Types should be defined in named namespaces", Justification = "<Pending>", Scope = "module")]
[assembly: SuppressMessage("Design", "CA1050:Declare types in namespaces", Justification = "<Pending>", Scope = "module")]

0 comments on commit 5921c9a

Please sign in to comment.