C#: Fix quality issues

This commit is contained in:
Tamas Vajk
2024-06-28 11:09:40 +02:00
parent 1cf5e89b96
commit 199a9688af
47 changed files with 79 additions and 85 deletions

View File

@@ -99,7 +99,7 @@ namespace Semmle.Autobuild.CSharp
{
if (!match.Groups.TryGetValue("projectFile", out var projectFile))
throw new ArgumentException("Expected regular expression match to contain projectFile");
if (!match.Groups.TryGetValue("location", out var location))
if (!match.Groups.TryGetValue("location", out _))
throw new ArgumentException("Expected regular expression match to contain location");
var result = classifier.Results.OfType<Result>().FirstOrDefault();

View File

@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Semmle.Util;
using Semmle.Util.Logging;
using Semmle.Autobuild.Shared;
using Semmle.Extraction.CSharp.DependencyFetching;
@@ -15,14 +13,14 @@ namespace Semmle.Autobuild.CSharp
/// </summary>
internal class DotNetRule : IBuildRule<CSharpAutobuildOptions>
{
public readonly List<IProjectOrSolution> FailedProjectsOrSolutions = new();
public List<IProjectOrSolution> FailedProjectsOrSolutions { get; } = [];
/// <summary>
/// A list of projects which are incompatible with DotNet.
/// </summary>
public IEnumerable<Project<CSharpAutobuildOptions>> NotDotNetProjects { get; private set; }
public DotNetRule() => NotDotNetProjects = new List<Project<CSharpAutobuildOptions>>();
public DotNetRule() => NotDotNetProjects = [];
public BuildScript Analyse(IAutobuilder<CSharpAutobuildOptions> builder, bool auto)
{

View File

@@ -18,7 +18,7 @@ namespace Semmle.Autobuild.Shared
Path = path;
ToolsVersion = version;
}
};
}
/// <summary>
/// Collection of available Visual Studio build tools.

View File

@@ -60,7 +60,7 @@ namespace Semmle.Autobuild.Shared
public class DiagnosticClassifier
{
private readonly List<DiagnosticRule> rules;
public readonly List<IDiagnosticsResult> Results;
public List<IDiagnosticsResult> Results { get; }
public DiagnosticClassifier()
{

View File

@@ -32,7 +32,7 @@ namespace Semmle.Autobuild.Shared
/// <summary>
/// A list of solutions or projects which failed to build.
/// </summary>
public readonly List<IProjectOrSolution> FailedProjectsOrSolutions = new();
public List<IProjectOrSolution> FailedProjectsOrSolutions { get; } = [];
public BuildScript Analyse(IAutobuilder<AutobuildOptionsShared> builder, bool auto)
{
@@ -60,7 +60,7 @@ namespace Semmle.Autobuild.Shared
// Use `nuget.exe` from source code repo, if present, otherwise first attempt with global
// `nuget` command, and if that fails, attempt to download `nuget.exe` from nuget.org
var nuget = builder.GetFilename("nuget.exe").Select(t => t.Item1).FirstOrDefault() ?? "nuget";
var nugetDownloadPath = builder.Actions.PathCombine(FileUtils.GetTemporaryWorkingDirectory(builder.Actions.GetEnvironmentVariable, builder.Options.Language.UpperCaseName, out var _), ".nuget", "nuget.exe");
var nugetDownloadPath = builder.Actions.PathCombine(FileUtils.GetTemporaryWorkingDirectory(builder.Actions.GetEnvironmentVariable, builder.Options.Language.UpperCaseName, out _), ".nuget", "nuget.exe");
var nugetDownloaded = false;
var ret = BuildScript.Success;
@@ -126,7 +126,7 @@ namespace Semmle.Autobuild.Shared
var platform = projectOrSolution is ISolution s1 ? s1.DefaultPlatformName : null;
var configuration = projectOrSolution is ISolution s2 ? s2.DefaultConfigurationName : null;
command.Argument("/t:" + target);
command.Argument($"/t:{target}");
if (platform is not null)
command.Argument($"/p:Platform=\"{platform}\"");
if (configuration is not null)