internal Result CreateResult(PylintLogEntry defect) { defect = defect ?? throw new ArgumentNullException(nameof(defect)); Result result = new Result { RuleId = $"{defect.MessageId}({defect.Symbol})", Message = new Message { Text = defect.Message }, }; switch (defect.Type) { case "error": case "fatal": result.Level = FailureLevel.Error; break; case "warning": case "convention": result.Level = FailureLevel.Warning; break; case "refactor": default: result.Level = FailureLevel.Note; break; } ; var region = new Region { StartColumn = int.Parse(defect.Column), StartLine = int.Parse(defect.Line) }; var fileUri = new Uri($"{defect.FilePath}", UriKind.RelativeOrAbsolute); var physicalLocation = new PhysicalLocation { ArtifactLocation = new ArtifactLocation { Uri = fileUri }, Region = region }; var location = new Location { PhysicalLocation = physicalLocation }; result.Locations = new List <Location> { location }; return(result); }
public void PylintConverter_CreateResult_CreatesExpectedResult() { var converter = new PylintConverter(); PylintLogEntry PylintLog = CreateTestLogEntry(); Result actualResult = converter.CreateResult(PylintLog); Result expectedResult = CreateResult(); Result.ValueComparer.Equals(actualResult, expectedResult).Should().BeTrue(); }