<commit_before>#addin "nuget:http://localhost:8081/repository/hm?package=CodeFileSanity&version=1.0.10"
#addin "nuget:?package=JetBrains.ReSharper.CommandLineTools"
#tool "nuget:?package=NVika.MSBuild"
#tool "nuget:?package=NuGet.CommandLine"

///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////

var target = Argument("target", "Build");
var framework = Argument("framework", "netcoreapp2.1");
var configuration = Argument("configuration", "Release");

var osuDesktop = new FilePath("./osu.Desktop/osu.Desktop.csproj");
var osuSolution = new FilePath("./osu.sln");
var testProjects = GetFiles("**/*.Tests.csproj");

///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////

Task("Compile")
.Does(() => {
    DotNetCoreBuild(osuDesktop.FullPath, new DotNetCoreBuildSettings {
        Framework = framework,
        Configuration = configuration
    });
});

Task("Test")
.ContinueOnError()
.DoesForEach(testProjects, testProject => {
    DotNetCoreTest(testProject.FullPath, new DotNetCoreTestSettings {
        Framework = framework,
        Configuration = configuration,
        Logger = $"trx;LogFileName={testProject.GetFilename()}.trx",
        ResultsDirectory = "./TestResults/"
    });
});

Task("InspectCode")
.IsDependentOn("Compile")
.Does(() => {
    var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First();
    var nugetToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First();

    if (!IsRunningOnWindows()) {
        RunInpectCodeInMono(nugetToolPath, nVikaToolPath);
        return;
    }

    StartProcess(nugetToolPath, $"restore {osuSolution}");

    InspectCode(osuSolution, new InspectCodeSettings {
        CachesHome = "inspectcode",
        OutputFile = "inspectcodereport.xml",
    });

    StartProcess(nVikaToolPath, @"parsereport ""inspectcodereport.xml"" --treatwarningsaserrors");
});

void RunInpectCodeInMono(FilePath nugetToolPath, FilePath nVikaToolPath) {
    var inspectcodeToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First();

    var testMonoArguments = new ProcessArgumentBuilder();
    testMonoArguments.AppendSwitch("--version", "");

    if (StartProcess("mono", new ProcessSettings { 
        Silent = true, Arguments = testMonoArguments }
    ) != 0) {
        Information("Running on an os other than windows and mono is not installed. Skipping InpectCode.");
        return;
    }

    StartProcess("mono", $"{nugetToolPath} restore {osuSolution}");

    StartProcess("mono", $@"{inspectcodeToolPath} --o=""inspectcodereport.xml"" --caches-home=""inspectcode"" ");

    StartProcess("mono", $@"{nVikaToolPath} parsereport ""inspectcodereport.xml"" --treatwarningsaserrors");
}

Task("CodeFileSanity")
.Does(() => {<commit_msg>adjust the path to the commandline tools<commit_after>#addin "nuget:http://localhost:8081/repository/hm?package=CodeFileSanity&version=1.0.10"
#addin "nuget:?package=JetBrains.ReSharper.CommandLineTools"
#tool "nuget:?package=NVika.MSBuild"
#tool "nuget:?package=NuGet.CommandLine"

///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////

var target = Argument("target", "Build");
var framework = Argument("framework", "netcoreapp2.1");
var configuration = Argument("configuration", "Release");

var osuDesktop = new FilePath("./osu.Desktop/osu.Desktop.csproj");
var osuSolution = new FilePath("./osu.sln");
var testProjects = GetFiles("**/*.Tests.csproj");

///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////

Task("Compile")
.Does(() => {
    DotNetCoreBuild(osuDesktop.FullPath, new DotNetCoreBuildSettings {
        Framework = framework,
        Configuration = configuration
    });
});

Task("Test")
.ContinueOnError()
.DoesForEach(testProjects, testProject => {
    DotNetCoreTest(testProject.FullPath, new DotNetCoreTestSettings {
        Framework = framework,
        Configuration = configuration,
        Logger = $"trx;LogFileName={testProject.GetFilename()}.trx",
        ResultsDirectory = "./TestResults/"
    });
});

Task("InspectCode")
.IsDependentOn("Compile")
.Does(() => {
    var nVikaToolPath = GetFiles("./tools/NVika.MSBuild.*/tools/NVika.exe").First();
    var nugetToolPath = GetFiles("./tools/NuGet.CommandLine.*/tools/NuGet.exe").First();

    if (!IsRunningOnWindows()) {
        RunInpectCodeInMono(nugetToolPath, nVikaToolPath);
        return;
    }

    StartProcess(nugetToolPath, $"restore {osuSolution}");

    InspectCode(osuSolution, new InspectCodeSettings {
        CachesHome = "inspectcode",
        OutputFile = "inspectcodereport.xml",
    });

    StartProcess(nVikaToolPath, @"parsereport ""inspectcodereport.xml"" --treatwarningsaserrors");
});

void RunInpectCodeInMono(FilePath nugetToolPath, FilePath nVikaToolPath) {
    var inspectcodeToolPath = GetFiles("./tools/Addins/JetBrains.Resharper.CommandLineTools.*/**/inspectcode.exe").First();

    var testMonoArguments = new ProcessArgumentBuilder();
    testMonoArguments.AppendSwitch("--version", "");

    if (StartProcess("mono", new ProcessSettings { 
        Silent = true, Arguments = testMonoArguments }
    ) != 0) {
        Information("Running on an os other than windows and mono is not installed. Skipping InpectCode.");
        return;
    }

    StartProcess("mono", $"{nugetToolPath} restore {osuSolution}");

    StartProcess("mono", $@"{inspectcodeToolPath} --o=""inspectcodereport.xml"" --caches-home=""inspectcode"" ");

    StartProcess("mono", $@"{nVikaToolPath} parsereport ""inspectcodereport.xml"" --treatwarningsaserrors");
}

Task("CodeFileSanity")
.Does(() => {
{'fraction_non_alphanumeric': 0.244, 'fraction_numerical': 0.0036666666666666666, 'mean_word_length': 2.734287492221531, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3888060', 'n_tokens_mistral': 1796, 'n_tokens_neox': 1688, 'n_words': 280}