Skip to content

Commit

Permalink
fix indentation for more readability
Browse files Browse the repository at this point in the history
  • Loading branch information
dicko2 committed Nov 17, 2024
1 parent cac74f8 commit b9939ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Agoda.CodeCompass.MSBuild.Tests/SarifConversionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class SarifConversionTests
private JsonSerializerSettings _jsonSettings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
Error = HandleDeserializationError

Error = HandleDeserializationError,

Check warning on line 24 in src/Agoda.CodeCompass.MSBuild.Tests/SarifConversionTests.cs

View workflow job for this annotation

GitHub Actions / Build Package

Nullability of reference types in type of parameter 'sender' of 'void SarifConversionTests.HandleDeserializationError(object sender, ErrorEventArgs errorArgs)' doesn't match the target delegate 'EventHandler<ErrorEventArgs>' (possibly because of nullability attributes).
Formatting = Formatting.Indented,
};

[Test]
Expand Down
16 changes: 8 additions & 8 deletions src/Agoda.CodeCompass.MSBuild/SarifReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

public class SarifReporter
{
private static JsonSerializerSettings _jsonSettings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
Error = HandleDeserializationError,

Check warning on line 16 in src/Agoda.CodeCompass.MSBuild/SarifReporter.cs

View workflow job for this annotation

GitHub Actions / Build Package

Nullability of reference types in type of parameter 'sender' of 'void SarifReporter.HandleDeserializationError(object sender, ErrorEventArgs errorArgs)' doesn't match the target delegate 'EventHandler<ErrorEventArgs>' (possibly because of nullability attributes).
Formatting = Newtonsoft.Json.Formatting.Indented,
};
private static void HandleDeserializationError(object sender, ErrorEventArgs errorArgs)
{
// Log the error but don't throw it
Expand All @@ -19,21 +25,15 @@ private static void HandleDeserializationError(object sender, ErrorEventArgs err
}
public static string AddTechDebtToSarif(string sarifContent)
{
var jsonSettings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
Error = HandleDeserializationError

};

// Detect version
var jObject = JObject.Parse(sarifContent);
var version = jObject["version"]?.ToString();

return version switch
{
"1.0.0" => AddTechDebtToSarifV1(sarifContent, jsonSettings),
"2.1.0" => AddTechDebtToSarifV2(sarifContent, jsonSettings),
"1.0.0" => AddTechDebtToSarifV1(sarifContent, _jsonSettings),
"2.1.0" => AddTechDebtToSarifV2(sarifContent, _jsonSettings),
_ => throw new NotSupportedException($"Unsupported SARIF version: {version}")
};
}
Expand Down

0 comments on commit b9939ca

Please sign in to comment.