Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- [CLI] Suppress error code from Roslynator when it detects issues in code but runs successfully [PR](https://github.com/dotnet/roslynator/pull/1756)
Comment thread
josefpihrt marked this conversation as resolved.
Outdated

### Fixed

- Fix enum contained flags check for partial matches in [RCS1258](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1258) ([PR](https://github.com/dotnet/roslynator/pull/1740) by @ovska)
Expand Down
7 changes: 4 additions & 3 deletions src/CommandLine/Commands/AnalyzeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ public override async Task<AnalyzeCommandResult> ExecuteAsync(ProjectOrSolution
results = await codeAnalyzer.AnalyzeSolutionAsync(solution, f => IsMatch(f), cancellationToken);
}

return new AnalyzeCommandResult(
(results.Any(f => f.Diagnostics.Length > 0 || f.CompilerDiagnostics.Length > 0)) ? CommandStatus.NotSuccess : CommandStatus.Success,
results);
return new AnalyzeCommandResult(GetCommandStatus(Options, results), results);
}

private static CommandStatus GetCommandStatus(AnalyzeCommandLineOptions options, ImmutableArray<ProjectAnalysisResult> results)
=> (options.ReturnSuccessOnFindings || !results.Any(f => f.Diagnostics.Length > 0 || f.CompilerDiagnostics.Length > 0)) ? CommandStatus.Success : CommandStatus.NotSuccess;
Comment thread
josefpihrt marked this conversation as resolved.
Outdated

protected override void ProcessResults(IList<AnalyzeCommandResult> results)
{
IEnumerable<ProjectAnalysisResult> analysisResults = results.SelectMany(f => f.AnalysisResults);
Expand Down
5 changes: 5 additions & 0 deletions src/CommandLine/Options/AnalyzeCommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public class AnalyzeCommandLineOptions : AbstractAnalyzeCommandLineOptions
HelpText = "Indicates whether suppressed diagnostics should be reported.")]
public bool ReportSuppressedDiagnostics { get; set; }

[Option(
longName: "return-success-on-findings",
Comment thread
josefpihrt marked this conversation as resolved.
Outdated
HelpText = "Indicates whether to return exit code 0 on runs when findings are reported.")]
public bool ReturnSuccessOnFindings { get; set; }
Comment thread
josefpihrt marked this conversation as resolved.
Outdated

internal bool ValidateOutputFormat()
{
return ParseHelpers.TryParseOutputFormat(OutputFormat);
Expand Down