Skip to content

Commit 95d8940

Browse files
authored
Merge pull request #50 from mbarbin/diagnostic-via-ppx
Serialize to reviewdog via ppx yojson conv
2 parents 0171068 + d927264 commit 95d8940

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+747
-152
lines changed

crs-dev.opam

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ bug-reports: "https://github.com/mbarbin/crs/issues"
1111
depends: [
1212
"dune" {>= "3.17"}
1313
"ocaml" {>= "5.2"}
14-
"ocamlformat" {with-dev-setup & = "0.27.0"}
14+
"ocamlformat" {= "0.27.0"}
1515
"base" {>= "v0.17"}
16-
"bisect_ppx" {with-dev-setup & >= "2.8.3"}
16+
"base_quickcheck" {>= "v0.17"}
17+
"bisect_ppx" {>= "2.8.3"}
1718
"cmdlang" {>= "0.0.9"}
1819
"conf-git"
1920
"conf-hg"
@@ -37,10 +38,12 @@ depends: [
3738
"ppx_expect" {>= "v0.17"}
3839
"ppx_hash" {>= "v0.17"}
3940
"ppx_here" {>= "v0.17"}
40-
"ppx_js_style" {with-dev-setup & >= "v0.17"}
41+
"ppx_js_style" {>= "v0.17"}
4142
"ppx_let" {>= "v0.17"}
4243
"ppx_sexp_conv" {>= "v0.17"}
4344
"ppx_sexp_value" {>= "v0.17"}
45+
"ppx_yojson_conv" {>= "v0.17"}
46+
"ppx_yojson_conv_lib" {>= "v0.17"}
4447
"ppxlib" {>= "0.33"}
4548
"re" {>= "1.12.0"}
4649
"spawn" {>= "v0.17"}

crs-tests.opam

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ depends: [
1212
"ocaml" {>= "5.2"}
1313
"ocamlformat" {= "0.27.0"}
1414
"base" {>= "v0.17"}
15+
"base_quickcheck" {>= "v0.17"}
1516
"cmdlang" {>= "0.0.9"}
1617
"cmdlang-stdlib-runner" {>= "0.0.9"}
1718
"conf-git"
@@ -38,6 +39,8 @@ depends: [
3839
"ppx_let" {>= "v0.17"}
3940
"ppx_sexp_conv" {>= "v0.17"}
4041
"ppx_sexp_value" {>= "v0.17"}
42+
"ppx_yojson_conv" {>= "v0.17"}
43+
"ppx_yojson_conv_lib" {>= "v0.17"}
4144
"ppxlib" {>= "0.33"}
4245
"printbox" {>= "0.12"}
4346
"printbox-md" {>= "0.12"}

crs.opam

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ depends: [
1717
"fpath-base" {>= "0.3.1"}
1818
"loc" {>= "0.2.2"}
1919
"pageantty" {>= "0.0.2"}
20-
"pbrt" {>= "3.1"}
21-
"pbrt_yojson" {>= "3.1"}
2220
"pp" {>= "2.0.0"}
2321
"pplumbing" {>= "0.0.14"}
2422
"ppx_compare" {>= "v0.17"}

dune-project

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@
4242
(>= 0.2.2))
4343
(pageantty
4444
(>= 0.0.2))
45-
(pbrt
46-
(>= 3.1))
47-
(pbrt_yojson
48-
(>= 3.1))
4945
(pp
5046
(>= 2.0.0))
5147
(pplumbing
@@ -95,6 +91,8 @@
9591
(= 0.27.0))
9692
(base
9793
(>= v0.17))
94+
(base_quickcheck
95+
(>= v0.17))
9896
(cmdlang
9997
(>= 0.0.9))
10098
(cmdlang-stdlib-runner
@@ -147,6 +145,10 @@
147145
(>= v0.17))
148146
(ppx_sexp_value
149147
(>= v0.17))
148+
(ppx_yojson_conv
149+
(>= v0.17))
150+
(ppx_yojson_conv_lib
151+
(>= v0.17))
150152
(ppxlib
151153
(>= 0.33))
152154
(printbox
@@ -189,15 +191,13 @@
189191
(ocaml
190192
(>= 5.2))
191193
(ocamlformat
192-
(and
193-
:with-dev-setup
194-
(= 0.27.0)))
194+
(= 0.27.0))
195195
(base
196196
(>= v0.17))
197+
(base_quickcheck
198+
(>= v0.17))
197199
(bisect_ppx
198-
(and
199-
:with-dev-setup
200-
(>= 2.8.3)))
200+
(>= 2.8.3))
201201
(cmdlang
202202
(>= 0.0.9))
203203
conf-git
@@ -243,15 +243,17 @@
243243
(ppx_here
244244
(>= v0.17))
245245
(ppx_js_style
246-
(and
247-
:with-dev-setup
248-
(>= v0.17)))
246+
(>= v0.17))
249247
(ppx_let
250248
(>= v0.17))
251249
(ppx_sexp_conv
252250
(>= v0.17))
253251
(ppx_sexp_value
254252
(>= v0.17))
253+
(ppx_yojson_conv
254+
(>= v0.17))
255+
(ppx_yojson_conv_lib
256+
(>= v0.17))
255257
(ppxlib
256258
(>= 0.33))
257259
(re

lib/crs_cli/src/annotation.ml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module Severity = struct
3838
| Info -> Notice
3939
;;
4040

41-
let to_reviewdog : t -> Reviewdog_rdf.severity = function
41+
let to_reviewdog : t -> Reviewdog.Severity.t = function
4242
| Error -> Error
4343
| Warning -> Warning
4444
| Info -> Info
@@ -117,13 +117,14 @@ let to_github_annotation t : Github_annotation.t =
117117
~message:t.message
118118
;;
119119

120-
let to_reviewdog_diagnostic t : Reviewdog_rdf.diagnostic =
121-
Reviewdog_rdf.make_diagnostic
122-
~message:t.message
123-
~location:(Cr_comment.whole_loc t.cr |> Reviewdog_utils.make_location |> Option.some)
124-
~severity:(Severity.to_reviewdog t.severity)
125-
~suggestions:[]
126-
~original_output:(Cr_comment.reindented_content t.cr)
127-
~related_locations:[]
128-
()
120+
let to_reviewdog_diagnostic t : Reviewdog.Diagnostic.t =
121+
{ Reviewdog.Diagnostic.message = t.message
122+
; location = Cr_comment.whole_loc t.cr |> Reviewdog_utils.make_location
123+
; severity = Some (Severity.to_reviewdog t.severity)
124+
; source = None
125+
; code = None
126+
; suggestions = None
127+
; original_output = Some (Cr_comment.reindented_content t.cr)
128+
; related_locations = None
129+
}
129130
;;

lib/crs_cli/src/annotation.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module Severity : sig
3636
val to_string : t -> string
3737

3838
val to_github : t -> Github_annotation.Severity.t
39-
val to_reviewdog : t -> Reviewdog_rdf.severity
39+
val to_reviewdog : t -> Reviewdog.Severity.t
4040
end
4141

4242
type t [@@deriving sexp_of]
@@ -69,4 +69,4 @@ val with_user_mention : t -> bool
6969
(** Export to supported consumers / backend. *)
7070

7171
val to_github_annotation : t -> Github_annotation.t
72-
val to_reviewdog_diagnostic : t -> Reviewdog_rdf.diagnostic
72+
val to_reviewdog_diagnostic : t -> Reviewdog.Diagnostic.t

lib/crs_cli/src/cmd__tools__reviewdog__annotate_crs.ml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,12 @@ This command searches for CRs in the tree and prints Reviewdog Annotations for t
4949
|> Option.map ~f:Annotation.to_reviewdog_diagnostic)
5050
in
5151
let diagnostic_result =
52-
Reviewdog_rdf.make_diagnostic_result
53-
~diagnostics
54-
~source:(Some Reviewdog_utils.source)
55-
~severity:Info
56-
()
52+
{ Reviewdog.Diagnostic_result.source = Some Reviewdog_utils.source
53+
; severity = Some Info
54+
; diagnostics
55+
}
5756
in
58-
let json = Reviewdog_rdf.encode_json_diagnostic_result diagnostic_result in
59-
print_endline (Yojson.Basic.pretty_to_string ~std:true json);
57+
let json = Reviewdog.Diagnostic_result.yojson_of_t diagnostic_result in
58+
print_endline (Yojson.Safe.pretty_to_string ~std:true json);
6059
())
6160
;;

lib/crs_cli/src/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
pp
3131
pplumbing.err
3232
pplumbing.pp-tty
33-
reviewdog_rdf
33+
reviewdog
3434
stdio
3535
text_table
3636
unix

lib/crs_cli/src/reviewdog_utils.ml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,18 @@
1919
(* <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *)
2020
(********************************************************************************)
2121

22-
let source : Reviewdog_rdf.source =
23-
{ name = "crs"; url = "https://github.com/mbarbin/crs" }
22+
let source : Reviewdog.Source.t =
23+
{ name = "crs"; url = Some "https://github.com/mbarbin/crs" }
2424
;;
2525

2626
let make_position (pos : Lexing.position) =
27-
let line = Int32.of_int_exn pos.pos_lnum in
28-
let column = Int32.of_int_exn (pos.pos_cnum - pos.pos_bol + 1) in
29-
Reviewdog_rdf.make_position ~line ~column ()
27+
{ Reviewdog.Position.line = pos.pos_lnum; column = pos.pos_cnum - pos.pos_bol + 1 }
3028
;;
3129

3230
let make_location (loc : Loc.t) =
3331
let path = Fpath.to_string (Loc.path loc) in
3432
let start_pos = Loc.start loc |> make_position in
3533
let end_pos = Loc.stop loc |> make_position in
36-
let range = Reviewdog_rdf.make_range ~start:(Some start_pos) ~end_:(Some end_pos) () in
37-
Reviewdog_rdf.make_location ~path ~range:(Some range) ()
34+
let range = { Reviewdog.Range.start = start_pos; end_ = Some end_pos } in
35+
{ Reviewdog.Location.path; range = Some range }
3836
;;

lib/crs_cli/src/reviewdog_utils.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
(*_ <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *)
2020
(*_*******************************************************************************)
2121

22-
val source : Reviewdog_rdf.source
23-
val make_location : Loc.t -> Reviewdog_rdf.location
22+
val source : Reviewdog.Source.t
23+
val make_location : Loc.t -> Reviewdog.Location.t

0 commit comments

Comments
 (0)