-
Notifications
You must be signed in to change notification settings - Fork 74
WIP: Add Sarif output support to FSharpLint.Console #702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
It might also be possible to make it generate a sarif report from the |
Rebased on top of the latest code (The Paket changes are gone now, so previous comments about that don't apply any more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, use object initializers, please
open FSharpLint.Framework | ||
open System.IO | ||
open System | ||
open Microsoft.CodeAnalysis.Sarif | ||
open Microsoft.CodeAnalysis.Sarif.Writers | ||
open FSharpLint.Console.Output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
open FSharpLint.Framework | |
open System.IO | |
open System | |
open Microsoft.CodeAnalysis.Sarif | |
open Microsoft.CodeAnalysis.Sarif.Writers | |
open FSharpLint.Console.Output | |
open System | |
open System.IO | |
open Microsoft.CodeAnalysis.Sarif | |
open Microsoft.CodeAnalysis.Sarif.Writers | |
open FSharpLint.Framework | |
open FSharpLint.Console.Output |
let driver = ToolComponent() | ||
driver.Name <- "FSharpLint.Console" | ||
driver.InformationUri <- Uri("https://fsprojects.github.io/FSharpLint/") | ||
driver.Version <- string<Version> (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version) | ||
let tool = Tool() | ||
tool.Driver <- driver | ||
let run = Run() | ||
run.Tool <- tool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let driver = ToolComponent() | |
driver.Name <- "FSharpLint.Console" | |
driver.InformationUri <- Uri("https://fsprojects.github.io/FSharpLint/") | |
driver.Version <- string<Version> (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version) | |
let tool = Tool() | |
tool.Driver <- driver | |
let run = Run() | |
run.Tool <- tool | |
let driver = | |
ToolComponent( | |
Name = "FSharpLint.Console", | |
InformationUri = Uri("https://fsprojects.github.io/FSharpLint/"), | |
Version = string<Version> (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version), | |
) | |
let tool = Tool(Driver = driver) | |
let run = Run(Tool = tool) |
let reportDescriptor = ReportingDescriptor() | ||
reportDescriptor.Id <- analyzerResult.RuleIdentifier | ||
reportDescriptor.Name <- analyzerResult.RuleName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let reportDescriptor = ReportingDescriptor() | |
reportDescriptor.Id <- analyzerResult.RuleIdentifier | |
reportDescriptor.Name <- analyzerResult.RuleName | |
let reportDescriptor = ReportingDescriptor( | |
Id = analyzerResult.RuleIdentifier, | |
Name = analyzerResult.RuleName | |
) |
let result = Result() | ||
result.RuleId <- reportDescriptor.Id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let result = Result() | |
result.RuleId <- reportDescriptor.Id | |
let result = Result(RuleId = reportDescriptor.Id) |
let msg = Message() | ||
msg.Text <- analyzerResult.Details.Message | ||
result.Message <- msg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let msg = Message() | |
msg.Text <- analyzerResult.Details.Message | |
result.Message <- msg | |
let msg = Message( | |
Text = analyzerResult.Details.Message, | |
Message = msg | |
) |
let physicalLocation = PhysicalLocation() | ||
|
||
physicalLocation.ArtifactLocation <- | ||
let al = ArtifactLocation() | ||
al.Uri <- codeRoot.MakeRelativeUri(Uri(analyzerResult.Details.Range.FileName)) | ||
al | ||
|
||
physicalLocation.Region <- | ||
let r = Region() | ||
r.StartLine <- analyzerResult.Details.Range.StartLine | ||
r.StartColumn <- analyzerResult.Details.Range.StartColumn + 1 | ||
r.EndLine <- analyzerResult.Details.Range.EndLine | ||
r.EndColumn <- analyzerResult.Details.Range.EndColumn + 1 | ||
r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let physicalLocation = PhysicalLocation() | |
physicalLocation.ArtifactLocation <- | |
let al = ArtifactLocation() | |
al.Uri <- codeRoot.MakeRelativeUri(Uri(analyzerResult.Details.Range.FileName)) | |
al | |
physicalLocation.Region <- | |
let r = Region() | |
r.StartLine <- analyzerResult.Details.Range.StartLine | |
r.StartColumn <- analyzerResult.Details.Range.StartColumn + 1 | |
r.EndLine <- analyzerResult.Details.Range.EndLine | |
r.EndColumn <- analyzerResult.Details.Range.EndColumn + 1 | |
r | |
let physicalLocation = PhysicalLocation( | |
ArtifactLocation = ArtifactLocation(Uri = codeRoot.MakeRelativeUri(Uri(analyzerResult.Details.Range.FileName))), | |
Region = Region( | |
StartLine = analyzerResult.Details.Range.StartLine, | |
StartColumn = (analyzerResult.Details.Range.StartColumn + 1), | |
EndLine = analyzerResult.Details.Range.EndLine, | |
EndColumn = (analyzerResult.Details.Range.EndColumn + 1), | |
) |
let location: Location = Location() | ||
location.PhysicalLocation <- physicalLocation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let location: Location = Location() | |
location.PhysicalLocation <- physicalLocation | |
let location: Location = Location(PhysicalLocation = physicalLocation) |
Rebased to fix conflicts, haven't got to the other comments yet. |
Resolves #554 |
95320fc
to
02456e1
Compare
This is using the Microsoft Sarif.Sdk to write Sarif files.
02456e1
to
1a366ef
Compare
refs #554
I've recently been having a go at running some things at work through the FSharp.Analyzers.SDK analysis tools and pushing the generated Sarif report files into DevOps CI builds, and I thought it might be useful to see if I could get FSharpLint results pushed out in the same way - so, this is a first attempt at adding Sarif report generation into FSharpLint.Console.
Note: The Sarif writer code is currently a lightly modified version of the report code from https://github.com/ionide/FSharp.Analyzers.SDK just to try to get it working, so if the code style and such is wrong that's the reason.