public Result ConvertProblemToSarifResult(AndroidStudioProblem problem)
{
var result = new Result();
result.RuleId = problem.ProblemClass;
string description = AndroidStudioConverter.GetShortDescriptionForProblem(problem);
if (problem.Hints.IsEmpty)
{
result.Message = description;
}
else
{
result.Message = GenerateFullMessage(description, problem.Hints);
}
SetSarifResultPropertiesForProblem(result, problem);
var location = new Location();
location.FullyQualifiedLogicalName = CreateSignature(problem);
string logicalLocationKey = CreateLogicalLocation(problem);
if (logicalLocationKey != location.FullyQualifiedLogicalName)
{
location.LogicalLocationKey = logicalLocationKey;
}
Uri uri;
string file = problem.File;
if (!String.IsNullOrEmpty(file))
{
location.ResultFile = new PhysicalLocation
{
Region = problem.Line <= 0 ? null : Extensions.CreateRegion(problem.Line)
};
if (RemoveBadRoot(file, out uri))
{
location.ResultFile.UriBaseId = PROJECT_DIR;
}
location.ResultFile.Uri = uri;
}
if ("file".Equals(problem.EntryPointType, StringComparison.OrdinalIgnoreCase))
{
if (location.AnalysisTarget != null)
{
location.ResultFile = location.AnalysisTarget;
}
location.AnalysisTarget = new PhysicalLocation();
if (RemoveBadRoot(problem.EntryPointName, out uri))
{
location.AnalysisTarget.UriBaseId = PROJECT_DIR;
}
location.AnalysisTarget.Uri = uri;
}
result.Locations = new List<Location> { location };
return result;
}