From 5a95da04d5c753477d9c201b07c16421921445ac Mon Sep 17 00:00:00 2001 From: Rouke Broersma Date: Fri, 22 Nov 2024 18:32:32 +0100 Subject: [PATCH] Remove unnecesary changes --- .../Reporters/Json/JsonReporterTests.cs | 10 ++-- .../Initialisation/InputFileResolver.cs | 56 +++++++++---------- .../MutationTest/MutationTestProcess.cs | 10 ++-- 3 files changed, 37 insertions(+), 39 deletions(-) diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/Reporters/Json/JsonReporterTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/Reporters/Json/JsonReporterTests.cs index 9605026ae..9d9a73bee 100644 --- a/src/Stryker.Core/Stryker.Core.UnitTest/Reporters/Json/JsonReporterTests.cs +++ b/src/Stryker.Core/Stryker.Core.UnitTest/Reporters/Json/JsonReporterTests.cs @@ -45,15 +45,15 @@ public void Test1() [TestMethod] public void JsonMutantPositionLine_ThrowsArgumentExceptionWhenSetToLessThan1() { - _ = Should.Throw(() => new Position().Line = -1); - _ = Should.Throw(() => new Position().Line = 0); + Should.Throw(() => new Position().Line = -1); + Should.Throw(() => new Position().Line = 0); } [TestMethod] public void JsonMutantPositionColumn_ThrowsArgumentExceptionWhenSetToLessThan1() { - _ = Should.Throw(() => new Position().Column = -1); - _ = Should.Throw(() => new Position().Column = 0); + Should.Throw(() => new Position().Column = -1); + Should.Throw(() => new Position().Column = 0); } [TestMethod] @@ -197,7 +197,7 @@ public void JsonReporter_OnAllMutantsTestedShouldWriteJsonToFile() var report = JsonReportSerialization.DeserializeJsonReportAsync(fileContents).Result; - _ = report.ShouldNotBeNull(); + report.ShouldNotBeNull(); report.Thresholds.ShouldContainKeyAndValue("high", 80); report.Thresholds.ShouldContainKeyAndValue("low", 60); diff --git a/src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs b/src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs index c0af08562..63e61d6d2 100644 --- a/src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs +++ b/src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs @@ -156,17 +156,18 @@ private List AnalyzeAndIdentifyProjects(List projectL var normalizedProjectUnderTestNameFilter = !string.IsNullOrEmpty(options.SourceProjectName) ? options.SourceProjectName.Replace("\\", "/") : null; while (!list.Empty) { - _ = Parallel.ForEach(list.Consume(), + Parallel.ForEach(list.Consume(), new ParallelOptions { MaxDegreeOfParallelism = options.DevMode ? 1 : Math.Max(options.Concurrency, 1) }, entry => - { - var buildResult = GetProjectAndAddIt(options, manager, entry, normalizedProjectUnderTestNameFilter, mutableProjectsAnalyzerResults); - - foreach (var reference in ScanReferences(mode, buildResult)) { - list.Add((reference, null)); + var buildResult = GetProjectAndAddIt(options, manager, entry, normalizedProjectUnderTestNameFilter, mutableProjectsAnalyzerResults); + + foreach (var reference in ScanReferences(mode, buildResult)) + { + list.Add((reference, null)); + } } - }); + ); } } catch (AggregateException ex) @@ -191,10 +192,7 @@ private IEnumerable GetProjectAndAddIt(IStrykerOptions options, var isTestProject = buildResult.IsTestProject(); if (isTestProject) { - buildResult = - [ - SelectAnalyzerResult(buildResult, entry.framework) - ]; + buildResult = [SelectAnalyzerResult(buildResult, entry.framework)]; } if (isTestProject || normalizedProjectUnderTestNameFilter == null || @@ -244,7 +242,7 @@ private IAnalyzerResults AnalyzeSingleProject(IProjectAnalyzer project, IStryker if (options.DevMode) { // clear the logs for the next project - _ = _buildalyzerLog.GetStringBuilder().Clear(); + _buildalyzerLog.GetStringBuilder().Clear(); } var projectLogName = Path.GetRelativePath(options.WorkingDirectory, project.ProjectFile.Path); _logger.LogDebug("Analyzing {ProjectFilePath}", projectLogName); @@ -265,7 +263,7 @@ private IAnalyzerResults AnalyzeSingleProject(IProjectAnalyzer project, IStryker { _logger.LogWarning("The MsBuild log is below."); _logger.LogInformation(_buildalyzerLog.ToString()); - _ = _buildalyzerLog.GetStringBuilder().Clear(); + _buildalyzerLog.GetStringBuilder().Clear(); } _nugetRestoreProcess.RestorePackages(options.SolutionPath, options.MsBuildPath ?? buildResult.First().MsBuildPath()); @@ -313,27 +311,27 @@ private void LogAnalyzerResult(IAnalyzerResults analyzerResults, IStrykerOptions } var log = new StringBuilder(); // dump all properties as it can help diagnosing build issues for user project. - _ = log.AppendLine("**** Buildalyzer result ****"); + log.AppendLine("**** Buildalyzer result ****"); - _ = log.AppendLine($"Project: {analyzerResults.First().ProjectFilePath}"); + log.AppendLine($"Project: {analyzerResults.First().ProjectFilePath}"); foreach (var analyzerResult in analyzerResults) { - _ = log.AppendLine($"TargetFramework: {analyzerResult.TargetFramework}"); - _ = log.AppendLine($"Succeeded: {analyzerResult.Succeeded}"); + log.AppendLine($"TargetFramework: {analyzerResult.TargetFramework}"); + log.AppendLine($"Succeeded: {analyzerResult.Succeeded}"); var properties = analyzerResult.Properties ?? new Dictionary(); foreach (var property in importantProperties) { - _ = log.AppendLine($"Property {property}={properties.GetValueOrDefault(property) ?? "\"'undefined'\""}"); + log.AppendLine($"Property {property}={properties.GetValueOrDefault(property) ?? "\"'undefined'\""}"); } foreach (var sourceFile in analyzerResult.SourceFiles) { - _ = log.AppendLine($"SourceFile {sourceFile}"); + log.AppendLine($"SourceFile {sourceFile}"); } foreach (var reference in analyzerResult.References) { - _ = log.AppendLine($"References: {Path.GetFileName(reference)} (in {Path.GetDirectoryName(reference)})"); + log.AppendLine($"References: {Path.GetFileName(reference)} (in {Path.GetDirectoryName(reference)})"); } foreach (var property in properties) @@ -343,11 +341,11 @@ private void LogAnalyzerResult(IAnalyzerResults analyzerResults, IStrykerOptions continue; // already logged } - _ = log.AppendLine($"Property {property.Key}={property.Value.Replace(Environment.NewLine, "\\n")}"); + log.AppendLine($"Property {property.Key}={property.Value.Replace(Environment.NewLine, "\\n")}"); } - _ = log.AppendLine(); + log.AppendLine(); } - _ = log.AppendLine("**** End Buildalyzer result ****"); + log.AppendLine("**** End Buildalyzer result ****"); _logger.LogTrace(log.ToString()); } @@ -464,7 +462,7 @@ private SourceProjectInfo BuildSourceProjectInfo(IStrykerOptions options, _logger, FileSystem), - _ => throw new NotSupportedException($"Language not supported: {language}") + > throw new NotSupportedException($"Language not supported: {language}") }); var inputFiles = builder.Build(); @@ -509,12 +507,12 @@ private string FindProjectFile(string path) case > 1: { var sb = new StringBuilder(); - _ = sb.AppendLine("Expected exactly one .csproj file, found more than one:"); + sb.AppendLine("Expected exactly one .csproj file, found more than one:"); foreach (var file in projectFiles) { - _ = sb.AppendLine(file); + sb.AppendLine(file); } - _ = sb.AppendLine().AppendLine("Please specify a test project name filter that results in one project."); + sb.AppendLine().AppendLine("Please specify a test project name filter that results in one project."); throw new InputException(sb.ToString()); } case 0: @@ -528,11 +526,11 @@ private string FindProjectFile(string path) private static StringBuilder BuildReferenceChoice(IEnumerable projectReferences) { var builder = new StringBuilder(); - _ = builder.AppendLine("Choose one of the following references:").AppendLine(""); + builder.AppendLine("Choose one of the following references:").AppendLine(""); foreach (var projectReference in projectReferences) { - _ = builder.Append(" ").AppendLine(projectReference.Replace("\\", "/")); + builder.Append(" ").AppendLine(projectReference.Replace("\\", "/")); } return builder; } diff --git a/src/Stryker.Core/Stryker.Core/MutationTest/MutationTestProcess.cs b/src/Stryker.Core/Stryker.Core/MutationTest/MutationTestProcess.cs index 4e05c50fc..a789580dc 100644 --- a/src/Stryker.Core/Stryker.Core/MutationTest/MutationTestProcess.cs +++ b/src/Stryker.Core/Stryker.Core/MutationTest/MutationTestProcess.cs @@ -42,14 +42,14 @@ public class MutationTestProcess : IMutationTestProcess public static void DeclareMutationProcessForLanguage(Language language) where T : IMutationProcess { - var constructor = typeof(T).GetConstructor(new[] { typeof(IStrykerOptions) }); + var constructor = typeof(T).GetConstructor([typeof(IStrykerOptions)]); if (constructor == null) { throw new NotSupportedException( $"Failed to find a constructor with the appropriate signature for type {typeof(T)}"); } - LanguageMap[language] = y => (IMutationProcess)constructor.Invoke(new object[] { y }); + LanguageMap[language] = y => (IMutationProcess)constructor.Invoke([y]); } public MutationTestProcess(MutationTestInput input, @@ -109,7 +109,7 @@ private void TestMutants(IEnumerable mutantsToTest) var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = _options.Concurrency }; - _ = Parallel.ForEach(mutantGroups, parallelOptions, mutants => + Parallel.ForEach(mutantGroups, parallelOptions, mutants => { var reportedMutants = new HashSet(); @@ -172,7 +172,7 @@ private void OnMutantTested(IMutant mutant, ISet reportedMutants) } _reporter?.OnMutantTested(mutant); - _ = reportedMutants.Add(mutant); + reportedMutants.Add(mutant); } private static bool MutantsToTest(IEnumerable mutantsToTest) @@ -204,7 +204,7 @@ private IEnumerable> BuildMutantGroupsForTest(IReadOnlyCollection< // we deal with mutants needing full testing first blocks.AddRange(mutantsToGroup.Where(m => m.AssessingTests.IsEveryTest) .Select(m => new List { m })); - _ = mutantsToGroup.RemoveAll(m => m.AssessingTests.IsEveryTest); + mutantsToGroup.RemoveAll(m => m.AssessingTests.IsEveryTest); mutantsToGroup = mutantsToGroup.Where(m => m.ResultStatus == MutantStatus.Pending).ToList();