-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
66 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Workleap.DotNet.CodingStandards" Version="0.1.0" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,5 +63,4 @@ class Sample | |
Assert.False(data.HasError("IDE1006")); | ||
Assert.False(data.HasWarning("IDE1006")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
tests/Workleap.DotNet.CodingStandards.Tests/Helpers/SarifFile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
using System.Text.Json.Serialization; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Workleap.DotNet.CodingStandards.Tests.Helpers; | ||
|
||
internal sealed class SarifFile | ||
{ | ||
[JsonPropertyName("runs")] | ||
public SarifFileRun[] Runs { get; set; } | ||
public SarifFileRun[]? Runs { get; set; } | ||
|
||
public IEnumerable<SarifFileRunResult> AllResults() => Runs.SelectMany(r => r.Results); | ||
public IEnumerable<SarifFileRunResult> AllResults() => this.Runs?.SelectMany(r => r.Results ?? []) ?? []; | ||
|
||
public bool HasError() => AllResults().Any(r => r.Level == "error"); | ||
public bool HasError(string ruleId) => AllResults().Any(r => r.Level == "error" && r.RuleId == ruleId); | ||
public bool HasWarning(string ruleId) => AllResults().Any(r => r.Level == "warning" && r.RuleId == ruleId); | ||
public bool HasNote(string ruleId) => AllResults().Any(r => r.Level == "note" && r.RuleId == ruleId); | ||
public bool HasError() => this.AllResults().Any(r => r.Level == "error"); | ||
public bool HasError(string ruleId) => this.AllResults().Any(r => r.Level == "error" && r.RuleId == ruleId); | ||
public bool HasWarning(string ruleId) => this.AllResults().Any(r => r.Level == "warning" && r.RuleId == ruleId); | ||
public bool HasNote(string ruleId) => this.AllResults().Any(r => r.Level == "note" && r.RuleId == ruleId); | ||
} |
4 changes: 2 additions & 2 deletions
4
tests/Workleap.DotNet.CodingStandards.Tests/Helpers/SarifFileRun.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
using System.Text.Json.Serialization; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Workleap.DotNet.CodingStandards.Tests.Helpers; | ||
|
||
internal sealed class SarifFileRun | ||
{ | ||
[JsonPropertyName("results")] | ||
public SarifFileRunResult[] Results { get; set; } | ||
public SarifFileRunResult[]? Results { get; set; } | ||
} |
10 changes: 5 additions & 5 deletions
10
tests/Workleap.DotNet.CodingStandards.Tests/Helpers/SarifFileRunResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
using System.Text.Json.Serialization; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Workleap.DotNet.CodingStandards.Tests.Helpers; | ||
|
||
internal sealed class SarifFileRunResult | ||
{ | ||
[JsonPropertyName("ruleId")] | ||
public string RuleId { get; set; } | ||
public string? RuleId { get; set; } | ||
|
||
[JsonPropertyName("level")] | ||
public string Level { get; set; } | ||
public string? Level { get; set; } | ||
|
||
[JsonPropertyName("message")] | ||
public SarifFileRunResultMessage Message { get; set; } | ||
public SarifFileRunResultMessage? Message { get; set; } | ||
|
||
public override string ToString() | ||
{ | ||
return $"{Level}:{RuleId} {Message}"; | ||
return $"{this.Level}:{this.RuleId} {this.Message}"; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
tests/Workleap.DotNet.CodingStandards.Tests/Helpers/SarifFileRunResultMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
using System.Text.Json.Serialization; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Workleap.DotNet.CodingStandards.Tests.Helpers; | ||
|
||
internal sealed class SarifFileRunResultMessage | ||
{ | ||
[JsonPropertyName("text")] | ||
public string Text { get; set; } | ||
public string? Text { get; set; } | ||
|
||
public override string ToString() | ||
{ | ||
return Text; | ||
return this.Text ?? ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters