2626 */
2727public final class ReviewDogGenerator {
2828
29+ private static final String SOURCE = "spotless" ;
30+
2931 private ReviewDogGenerator () {
3032 // Prevent instantiation
3133 }
@@ -34,8 +36,8 @@ private ReviewDogGenerator() {
3436 * Generates a ReviewDog compatible JSON line (rdjsonl) for a diff between
3537 * the actual content and the formatted content of a file.
3638 *
37- * @param path The file path
38- * @param actualContent The content as it currently exists in the file
39+ * @param path The file path
40+ * @param actualContent The content as it currently exists in the file
3941 * @param formattedContent The content after formatting is applied
4042 * @return A string in rdjsonl format representing the diff
4143 */
@@ -56,14 +58,12 @@ public static String rdjsonlDiff(String path, String actualContent, String forma
5658 * Generates ReviewDog compatible JSON lines (rdjsonl) for lint issues
5759 * identified by formatting steps.
5860 *
59- * @param path The file path
60- * @param formattedContent The content after formatting is applied
61- * @param steps The list of formatter steps applied
62- * @param lintsPerStep The list of lints produced by each step
61+ * @param path The file path
62+ * @param steps The list of formatter steps applied
63+ * @param lintsPerStep The list of lints produced by each step
6364 * @return A string in rdjsonl format representing the lints
6465 */
65- public static String rdjsonlLints (String path , String formattedContent ,
66- List <FormatterStep > steps , List <List <Lint >> lintsPerStep ) {
66+ public static String rdjsonlLints (String path , List <FormatterStep > steps , List <List <Lint >> lintsPerStep ) {
6767 if (lintsPerStep == null || lintsPerStep .isEmpty ()) {
6868 return "" ;
6969 }
@@ -111,13 +111,23 @@ private static String createUnifiedDiff(String path, String actualContent, Strin
111111 /**
112112 * Formats a single lint issue as a JSON line.
113113 */
114- private static String formatLintAsJson (String path , Lint lint , String stepName ) {
114+ private static String formatLintAsJson (String path , Lint lint , String ruleCode ) {
115115 return String .format (
116- "{\" message\" :{\" path\" :\" %s\" ,\" line\" :%d,\" column\" :1,\" message\" :\" %s: %s\" }}" ,
116+ "{"
117+ + "\" source\" :\" %s\" ,"
118+ + "\" code\" :\" %s\" ,"
119+ + "\" level\" :\" warning\" ,"
120+ + "\" message\" :\" %s\" ,"
121+ + "\" path\" :\" %s\" ,"
122+ + "\" line\" :%d,"
123+ + "\" column\" :%d"
124+ + "}" ,
125+ escapeJson (SOURCE ),
126+ escapeJson (ruleCode ),
127+ escapeJson (lint .getDetail ()),
117128 escapeJson (path ),
118129 lint .getLineStart (),
119- escapeJson (lint .getShortCode ()),
120- escapeJson (lint .getDetail ()));
130+ 1 );
121131 }
122132
123133 /**
0 commit comments