From 523365bf7b6b6bb23659ec09c8a89f3746b0a2f0 Mon Sep 17 00:00:00 2001
From: Rocket Understudy <33589210+rsg-bot@users.noreply.github.com>
Date: Mon, 9 Sep 2024 23:00:07 -0400
Subject: [PATCH] Automatically linting code
---
.config/dotnet-tools.json | 114 ++++++++----------
Directory.Packages.props | 8 +-
...ntinuousIntegrationConventionsAttribute.cs | 67 +++++-----
src/Nuke/ICanLint.cs | 2 +-
src/Nuke/LocalBuildConventionsAttribute.cs | 2 +-
src/Nuke/SolutionUpdater.cs | 22 ++--
6 files changed, 96 insertions(+), 119 deletions(-)
diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index 097a51fb5..8da7f4418 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -1,69 +1,51 @@
{
- "version": 1,
- "isRoot": true,
- "tools": {
- "gitversion.tool": {
- "version": "6.0.2",
- "commands": [
- "dotnet-gitversion"
- ],
- "rollForward": false
- },
- "dotnet-reportgenerator-globaltool": {
- "version": "5.3.9",
- "commands": [
- "reportgenerator"
- ],
- "rollForward": false
- },
- "nuke.globaltool": {
- "version": "8.1.0",
- "commands": [
- "nuke"
- ],
- "rollForward": false
- },
- "codecov.tool": {
- "version": "1.13.0",
- "commands": [
- "codecov"
- ],
- "rollForward": false
- },
- "jetbrains.resharper.globaltools": {
- "version": "2024.2.4",
- "commands": [
- "jb"
- ],
- "rollForward": false
- },
- "nukeeper": {
- "version": "0.35.0",
- "commands": [
- "nukeeper"
- ],
- "rollForward": false
- },
- "dotnet-outdated-tool": {
- "version": "4.6.4",
- "commands": [
- "dotnet-outdated"
- ],
- "rollForward": false
- },
- "husky": {
- "version": "0.7.1",
- "commands": [
- "husky"
- ],
- "rollForward": false
- },
- "liquidtestreports.cli": {
- "version": "2.0.0-beta.2",
- "commands": [
- "liquid"
- ],
- "rollForward": false
+ "version": 1,
+ "isRoot": true,
+ "tools": {
+ "gitversion.tool": {
+ "version": "6.0.2",
+ "commands": ["dotnet-gitversion"],
+ "rollForward": false
+ },
+ "dotnet-reportgenerator-globaltool": {
+ "version": "5.3.9",
+ "commands": ["reportgenerator"],
+ "rollForward": false
+ },
+ "nuke.globaltool": {
+ "version": "8.1.0",
+ "commands": ["nuke"],
+ "rollForward": false
+ },
+ "codecov.tool": {
+ "version": "1.13.0",
+ "commands": ["codecov"],
+ "rollForward": false
+ },
+ "jetbrains.resharper.globaltools": {
+ "version": "2024.2.4",
+ "commands": ["jb"],
+ "rollForward": false
+ },
+ "nukeeper": {
+ "version": "0.35.0",
+ "commands": ["nukeeper"],
+ "rollForward": false
+ },
+ "dotnet-outdated-tool": {
+ "version": "4.6.4",
+ "commands": ["dotnet-outdated"],
+ "rollForward": false
+ },
+ "husky": {
+ "version": "0.7.1",
+ "commands": ["husky"],
+ "rollForward": false
+ },
+ "liquidtestreports.cli": {
+ "version": "2.0.0-beta.2",
+ "commands": ["liquid"],
+ "rollForward": false
+ }
}
- }
}
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 38e1fe527..75c034e38 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -1,4 +1,5 @@
-
+
+
true
@@ -55,6 +56,5 @@
-
+ Condition="Exists('$(MSBuildThisFileDirectory)/Directory.Packages.support.props')" />
+
\ No newline at end of file
diff --git a/src/Nuke/ContinuousIntegration/ContinuousIntegrationConventionsAttribute.cs b/src/Nuke/ContinuousIntegration/ContinuousIntegrationConventionsAttribute.cs
index 68a69ce1e..d488d7275 100644
--- a/src/Nuke/ContinuousIntegration/ContinuousIntegrationConventionsAttribute.cs
+++ b/src/Nuke/ContinuousIntegration/ContinuousIntegrationConventionsAttribute.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.Execution;
using Nuke.Common.IO;
@@ -12,42 +13,12 @@ namespace Rocket.Surgery.Nuke.ContinuousIntegration;
[PublicAPI]
#pragma warning disable CA1813
[AttributeUsage(AttributeTargets.Class)]
-[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")]
+[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class ContinuousIntegrationConventionsAttribute : BuildExtensionAttributeBase, IOnBuildFinished
#pragma warning restore CA1813
{
- [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
- private string DebuggerDisplay
- {
- get
- {
- return ToString();
- }
- }
-
- ///
- public void OnBuildFinished()
- {
- if (Build is not IHaveArtifacts nukeBuild)
- {
- return;
- }
-
- switch (nukeBuild.Host)
- {
- case GitHubActions:
- {
- EmitTestSummaryMarkdown(Build, GitHubActions.Instance.StepSummaryFile);
- break;
- }
-
- default:
- {
- EmitTestSummaryMarkdown(Build, nukeBuild.ArtifactsDirectory / "github" / "summary.md");
- break;
- }
- }
- }
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private string DebuggerDisplay => ToString();
private void EmitTestSummaryMarkdown(INukeBuild build, AbsolutePath summary)
{
@@ -55,7 +26,7 @@ private void EmitTestSummaryMarkdown(INukeBuild build, AbsolutePath summary)
if (build.ExecutionPlan.Any(z => z.Name == nameof(IHaveTestTarget.Test))
&& build is IHaveTestArtifacts testResultReports
&& testResultReports.TestResultsDirectory.GlobFiles("**/*.trx") is
- { Count: > 0, } results)
+ { Count: > 0, } results)
{
// summary.TouchFile();
// var reporter = new LiquidReporter(results.Select(z => z.ToString()), Log.Logger);
@@ -67,7 +38,7 @@ private void EmitTestSummaryMarkdown(INukeBuild build, AbsolutePath summary)
.Add("--inputs {0}", results.Select(z => $"File={z}"), ' ', quoteMultiple: true)
.Add("--output-file {0}", summary)
.RenderForExecution(),
- workingDirectory: build.RootDirectory,
+ build.RootDirectory,
logOutput: false
);
}
@@ -87,4 +58,28 @@ private void EmitTestSummaryMarkdown(INukeBuild build, AbsolutePath summary)
_ = summary.WriteAllText(coverageSummary + summary.ReadAllText().TrimStart());
}
}
-}
+
+ ///
+ public void OnBuildFinished()
+ {
+ if (Build is not IHaveArtifacts nukeBuild)
+ {
+ return;
+ }
+
+ switch (nukeBuild.Host)
+ {
+ case GitHubActions:
+ {
+ EmitTestSummaryMarkdown(Build, GitHubActions.Instance.StepSummaryFile);
+ break;
+ }
+
+ default:
+ {
+ EmitTestSummaryMarkdown(Build, nukeBuild.ArtifactsDirectory / "github" / "summary.md");
+ break;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Nuke/ICanLint.cs b/src/Nuke/ICanLint.cs
index 13e15dad4..9b246d84f 100644
--- a/src/Nuke/ICanLint.cs
+++ b/src/Nuke/ICanLint.cs
@@ -224,4 +224,4 @@ private LintPaths ResolveLintPathsImpl()
? new(LintMatcher, trigger, message, files)
: new(LintMatcher, trigger, message, [] /*GitTasks.Git("ls-files", logOutput: false, logInvocation: false).Select(z => z.Text)*/);
}
-}
+}
\ No newline at end of file
diff --git a/src/Nuke/LocalBuildConventionsAttribute.cs b/src/Nuke/LocalBuildConventionsAttribute.cs
index 984246a79..147e0db47 100644
--- a/src/Nuke/LocalBuildConventionsAttribute.cs
+++ b/src/Nuke/LocalBuildConventionsAttribute.cs
@@ -36,4 +36,4 @@ public void OnBuildInitialized(IReadOnlyCollection executableT
// if (Build is not (INukeBuild nukeBuild and IHaveSolution haveSolution)) return;
// if (nukeBuild.IsServerBuild) return;
}
-}
+}
\ No newline at end of file
diff --git a/src/Nuke/SolutionUpdater.cs b/src/Nuke/SolutionUpdater.cs
index e6fa21c71..cb7da9480 100644
--- a/src/Nuke/SolutionUpdater.cs
+++ b/src/Nuke/SolutionUpdater.cs
@@ -72,30 +72,30 @@ private static void AddNukeBuilds(Solution solution, SolutionFolder configFolder
.Where(z => z.Configurations.Count > 0)
.SelectMany(
project => project.Configurations.Where(z => z.Key.Contains(".Build.", StringComparison.OrdinalIgnoreCase)),
- (project, pair) => ( Project: project, Key: pair.Key )
+ (project, pair) => ( Project: project, pair.Key )
)
.ToArray();
- foreach (var (project, key) in projects)
+ foreach (( var project, var key ) in projects)
{
Log.Logger.Information("Removing {Key} from {Project} configuration", key, project.Name);
project.Configurations.Remove(key);
}
var itemsToRemove = solution
- .AllSolutionFolders
- .SelectMany(z => z.Items, (folder, pair) => (Folder: folder, ItemPath: pair.Key, FilePath: pair.Value ))
- .Where(z => !AbsolutePath.Create(z.FilePath).FileExists())
- .ToArray();
- foreach (var (folder, itemPath, _) in itemsToRemove)
+ .AllSolutionFolders
+ .SelectMany(z => z.Items, (folder, pair) => ( Folder: folder, ItemPath: pair.Key, FilePath: pair.Value ))
+ .Where(z => !AbsolutePath.Create(z.FilePath).FileExists())
+ .ToArray();
+ foreach (( var folder, var itemPath, _ ) in itemsToRemove)
{
Log.Logger.Information("Removing {ItemPath} from {Folder}", itemPath, folder.Name);
folder.Items.Remove(itemPath);
}
var emptyFoldersToRemove = solution
- .AllSolutionFolders
- .Where(z => z.Items.Count == 0 && z.Projects.Count == 0)
- .ToArray();
+ .AllSolutionFolders
+ .Where(z => z.Items.Count == 0 && z.Projects.Count == 0)
+ .ToArray();
foreach (var folder in emptyFoldersToRemove)
{
Log.Logger.Information("Removing {Folder}", folder.Name);
@@ -186,4 +186,4 @@ private static void AddSolutionItemToFolder(SolutionFolder folder, UnixRelativeP
Log.Logger.Information("Adding {Path} to {Folder}", path, folder.Name);
folder.Items.Add(path, path);
}
-}
+}
\ No newline at end of file