Skip to content

Commit

Permalink
(GH-2328) Add support for /severity argument for InspectCode tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien Bousquet committed Dec 6, 2019
1 parent 9168053 commit b9a01db
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,20 @@ public void Should_Set_Verbosity()
// Then
Assert.Equal("\"/verbosity=ERROR\" \"/Working/Test.sln\"", result.Args);
}

[Fact]
public void Should_Set_Severity()
{
// Given
var fixture = new InspectCodeRunFixture();
fixture.Settings.Severity = InspectCodeSeverity.Hint;

// When
var result = fixture.Run();

// Then
Assert.Equal("\"/severity=HINT\" \"/Working/Test.sln\"", result.Args);
}
}

public sealed class TheRunFromConfigMethod
Expand Down
5 changes: 5 additions & 0 deletions src/Cake.Common/Tools/InspectCode/InspectCodeRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ private ProcessArgumentBuilder GetArguments(InspectCodeSettings settings, FilePa
builder.AppendQuoted(string.Format(CultureInfo.InvariantCulture, "/verbosity={0}", settings.Verbosity.ToString().ToUpper(CultureInfo.InvariantCulture)));
}

if (settings.Severity != null)
{
builder.AppendQuoted(string.Format(CultureInfo.InvariantCulture, "/severity={0}", settings.Severity.ToString().ToUpper(CultureInfo.InvariantCulture)));
}

builder.AppendQuoted(solution.MakeAbsolute(_environment).FullPath);

return builder;
Expand Down
5 changes: 5 additions & 0 deletions src/Cake.Common/Tools/InspectCode/InspectCodeSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,10 @@ public sealed class InspectCodeSettings : ToolSettings
/// Gets or sets the verbosity level of the log messages.
/// </summary>
public InspectCodeVerbosity? Verbosity { get; set; }

/// <summary>
/// Gets or sets the minimal severity of issues to report.
/// </summary>
public InspectCodeSeverity? Severity { get; set; }
}
}
33 changes: 33 additions & 0 deletions src/Cake.Common/Tools/InspectCode/InspectCodeSeverity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace Cake.Common.Tools.InspectCode
{
/// <summary>
/// Represents InspectCode's minimal severity report.
/// </summary>
public enum InspectCodeSeverity
{
/// <summary>
/// Severity: INFO.
/// </summary>
Info = 1,

/// <summary>
/// Severity: HINT.
/// </summary>
Hint = 2,

/// <summary>
/// Severity: SUGGESTION.
/// </summary>
Suggestion = 3,

/// <summary>
/// Severity: WARNING.
/// </summary>
Warning = 4,

/// <summary>
/// Severity: ERROR.
/// </summary>
Error = 5
}
}

0 comments on commit b9a01db

Please sign in to comment.