Skip to content

Commit

Permalink
Remove unnecesary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rouke-broersma committed Nov 22, 2024
1 parent ad6d464 commit 5a95da0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public void Test1()
[TestMethod]
public void JsonMutantPositionLine_ThrowsArgumentExceptionWhenSetToLessThan1()
{
_ = Should.Throw<ArgumentException>(() => new Position().Line = -1);
_ = Should.Throw<ArgumentException>(() => new Position().Line = 0);
Should.Throw<ArgumentException>(() => new Position().Line = -1);
Should.Throw<ArgumentException>(() => new Position().Line = 0);
}

[TestMethod]
public void JsonMutantPositionColumn_ThrowsArgumentExceptionWhenSetToLessThan1()
{
_ = Should.Throw<ArgumentException>(() => new Position().Column = -1);
_ = Should.Throw<ArgumentException>(() => new Position().Column = 0);
Should.Throw<ArgumentException>(() => new Position().Column = -1);
Should.Throw<ArgumentException>(() => new Position().Column = 0);
}

[TestMethod]
Expand Down Expand Up @@ -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);

Expand Down
56 changes: 27 additions & 29 deletions src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,18 @@ private List<SourceProjectInfo> AnalyzeAndIdentifyProjects(List<string> 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)
Expand All @@ -191,10 +192,7 @@ private IEnumerable<IAnalyzerResult> GetProjectAndAddIt(IStrykerOptions options,
var isTestProject = buildResult.IsTestProject();
if (isTestProject)
{
buildResult =
[
SelectAnalyzerResult(buildResult, entry.framework)
];
buildResult = [SelectAnalyzerResult(buildResult, entry.framework)];
}

if (isTestProject || normalizedProjectUnderTestNameFilter == null ||
Expand Down Expand Up @@ -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);
Expand All @@ -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());
Expand Down Expand Up @@ -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<string, string>();
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)
Expand All @@ -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());
}

Expand Down Expand Up @@ -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}")

Check failure on line 465 in src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs

View workflow job for this annotation

GitHub Actions / integration-test

Invalid expression term 'throw'

Check failure on line 465 in src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs

View workflow job for this annotation

GitHub Actions / integration-test

Syntax error, '=>' expected

Check failure on line 465 in src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs

View workflow job for this annotation

GitHub Actions / integration-test

Invalid expression term '}'
});

var inputFiles = builder.Build();
Expand Down Expand Up @@ -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:
Expand All @@ -528,11 +526,11 @@ private string FindProjectFile(string path)
private static StringBuilder BuildReferenceChoice(IEnumerable<string> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public class MutationTestProcess : IMutationTestProcess

public static void DeclareMutationProcessForLanguage<T>(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,
Expand Down Expand Up @@ -109,7 +109,7 @@ private void TestMutants(IEnumerable<IMutant> mutantsToTest)

var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = _options.Concurrency };

_ = Parallel.ForEach(mutantGroups, parallelOptions, mutants =>
Parallel.ForEach(mutantGroups, parallelOptions, mutants =>
{
var reportedMutants = new HashSet<IMutant>();

Expand Down Expand Up @@ -172,7 +172,7 @@ private void OnMutantTested(IMutant mutant, ISet<IMutant> reportedMutants)
}

_reporter?.OnMutantTested(mutant);
_ = reportedMutants.Add(mutant);
reportedMutants.Add(mutant);
}

private static bool MutantsToTest(IEnumerable<IMutant> mutantsToTest)
Expand Down Expand Up @@ -204,7 +204,7 @@ private IEnumerable<List<IMutant>> BuildMutantGroupsForTest(IReadOnlyCollection<
// we deal with mutants needing full testing first
blocks.AddRange(mutantsToGroup.Where(m => m.AssessingTests.IsEveryTest)
.Select(m => new List<IMutant> { m }));
_ = mutantsToGroup.RemoveAll(m => m.AssessingTests.IsEveryTest);
mutantsToGroup.RemoveAll(m => m.AssessingTests.IsEveryTest);

mutantsToGroup = mutantsToGroup.Where(m => m.ResultStatus == MutantStatus.Pending).ToList();

Expand Down

0 comments on commit 5a95da0

Please sign in to comment.