rewrite-gradle-plugin icon indicating copy to clipboard operation
rewrite-gradle-plugin copied to clipboard

Support output-location and output-format flag to specify the output file/directory in order to integrate other tools

Open Jenson3210 opened this issue 1 year ago • 1 comments

What problem are you trying to solve?

In order to support other tools to extend the output of the result of the rewriteRun task, we should allow for a report to be written as part of these tasks.

Describe the solution you'd like

SARIF support. potentially later we could add additional formats if required.

Additional context

  • https://sarifweb.azurewebsites.net/
  • https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning
  • https://github.com/reviewdog/reviewdog?tab=readme-ov-file#sarif-format

Are you interested in contributing this feature to OpenRewrite?

Yes! will need some pointers on gradle plugin design possibly

Jenson3210 avatar Oct 10 '24 17:10 Jenson3210

Open questions:

  • Should we move the responsability for sarif to Result. Similar to diff, one could ask result.sariff(), which would return the jsonString or SarifResult objects.
  • Should suggestions include the surrounding context like diff does or should they start at line 1 of change and go till last change?
    • If not, what about nonchanged lines in the middle of 2 changed lines. Typically a diff groups these together. If we make suggestion "per line", it might become a lot of comments and a hard to follow suggestion overview. eg. If the diff is
      -List<String>oldVariableName=this.lines();
      +List<String>list=this.lines();
      
      -oldVariableName.forEach(System.out::println);
      -System.out.println("List contains " + oldVariableName.size + " items.")
      +list.forEach(System.out::println);
      +System.out.println("List contains " + list.size + " items.")
      
      Do we want to see 1 suggestion including the whiteline in the middle or a suggestion per block (2)?

Jenson3210 avatar Oct 15 '24 14:10 Jenson3210