make lambdas static where possible

This commit is contained in:
Marcello 2024-11-10 10:53:23 +01:00
parent e09cfbffdd
commit 328cf7bf3c
Signed by: m-lamonaca
SSH key fingerprint: SHA256:8db8uii6Gweq7TbKixFBioW2T8CbgtyFETyYL3cr3zk
2 changed files with 8 additions and 11 deletions

View file

@ -2,9 +2,6 @@ using ScriptLauncher;
using Spectre.Console.Cli;
var app = new CommandApp<RootCommand>();
app.Configure(x =>
{
x.SetApplicationName("scrl");
});
app.Configure(static x => x.SetApplicationName("scrl"));
return app.Run(args);

View file

@ -10,7 +10,7 @@ internal readonly struct ScriptFinder
public ScriptFinder(IEnumerable<string> extensions, string directory, int depth)
{
Extensions = extensions.ToHashSet().Select(x => $".{x.TrimStart('.')}");
Extensions = extensions.ToHashSet().Select(static x => $".{x.TrimStart('.')}");
Depth = depth;
RootDirectory = directory;
@ -28,7 +28,7 @@ internal readonly struct ScriptFinder
try
{
var filenames = Directory.GetFiles(RootDirectory, $"*{extension}", _options);
return filenames.Select(x => new FileInfo(x));
return filenames.Select(static x => new FileInfo(x));
}
catch (UnauthorizedAccessException)
{
@ -37,13 +37,13 @@ internal readonly struct ScriptFinder
}
public FileInfo[] GetScripts() =>
Extensions.Select(GetScriptFilesWithExtension).SelectMany(x => x).ToArray();
Extensions.Select(GetScriptFilesWithExtension).SelectMany(static x => x).ToArray();
public IDictionary<DirectoryInfo, FileInfo[]> GetScriptsByDirectory() =>
Extensions
.Select(GetScriptFilesWithExtension)
.SelectMany(x => x)
.GroupBy(x => x.DirectoryName!)
.OrderBy(x => x.Key)
.ToDictionary(x => new DirectoryInfo(x.Key), x => x.ToArray());
.SelectMany(static x => x)
.GroupBy(static x => x.DirectoryName!)
.OrderBy(static x => x.Key)
.ToDictionary(static x => new DirectoryInfo(x.Key), static x => x.ToArray());
}