Skip to content

Commit

Permalink
Merge pull request #89 from upenn-cis1xx/reword-match
Browse files Browse the repository at this point in the history
  • Loading branch information
KeenWill authored Aug 15, 2023
2 parents 9292d92 + 764eebb commit 59b0ea4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/style/verbose.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ end
module NestedMatch : EXPRCHECK = struct
type ctxt = Parsetree.expression_desc Pctxt.pctxt
let fix = "using let statements or helper methods / rethinking logic"
let violation = "using nested match statements more than three layers deep"
let violation = "using nested match statements three or more layers deep"
let check st (E {location; source; pattern} : ctxt) =
begin match pattern with
(* Layer one *)
Expand Down
12 changes: 12 additions & 0 deletions test/examples/verbose.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ let f () = if x then
else y


(* No Flagging here - only 2 match levels deep *)
let f () =
let l = [] in
begin match l with
| [] ->
begin match l with
| [] -> true
| _ -> false
end
| _ -> true
end

(* Nested matched bad as well *)

let f () =
Expand Down
32 changes: 16 additions & 16 deletions test/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ let%expect_test _ =
lint_and_hint to_lint;
[%expect{|
(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, line 75, columns: 8-57
File ./examples/verbose.ml, line 87, columns: 8-57
Warning:
Usage of the `&&` is redundant
You wrote:
Expand All @@ -167,7 +167,7 @@ let%expect_test _ =
simplifying further

(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, line 74, columns: 8-57
File ./examples/verbose.ml, line 86, columns: 8-57
Warning:
Usage of the `&&` is redundant
You wrote:
Expand All @@ -176,7 +176,7 @@ let%expect_test _ =
simplifying further

(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, line 73, columns: 8-40
File ./examples/verbose.ml, line 85, columns: 8-40
Warning:
Usage of the `&&` is redundant
You wrote:
Expand All @@ -185,7 +185,7 @@ let%expect_test _ =
simplifying further

(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, line 72, columns: 8-24
File ./examples/verbose.ml, line 84, columns: 8-24
Warning:
Usage of the `&&` is redundant
You wrote:
Expand All @@ -194,7 +194,7 @@ let%expect_test _ =
simplifying further

(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, line 71, columns: 8-30
File ./examples/verbose.ml, line 83, columns: 8-30
Warning:
Usage of the `&&` is redundant
You wrote:
Expand All @@ -203,7 +203,7 @@ let%expect_test _ =
simplifying further

(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, line 70, columns: 8-26
File ./examples/verbose.ml, line 82, columns: 8-26
Warning:
Usage of the `&&` is redundant
You wrote:
Expand All @@ -212,7 +212,7 @@ let%expect_test _ =
simplifying further

(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, line 69, columns: 8-57
File ./examples/verbose.ml, line 81, columns: 8-57
Warning:
Usage of the `||` is redundant
You wrote:
Expand All @@ -221,7 +221,7 @@ let%expect_test _ =
simplifying further

(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, line 68, columns: 8-57
File ./examples/verbose.ml, line 80, columns: 8-57
Warning:
Usage of the `||` is redundant
You wrote:
Expand All @@ -230,7 +230,7 @@ let%expect_test _ =
simplifying further

(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, line 67, columns: 8-40
File ./examples/verbose.ml, line 79, columns: 8-40
Warning:
Usage of the `||` is redundant
You wrote:
Expand All @@ -239,7 +239,7 @@ let%expect_test _ =
simplifying further

(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, line 66, columns: 8-24
File ./examples/verbose.ml, line 78, columns: 8-24
Warning:
Usage of the `||` is redundant
You wrote:
Expand All @@ -248,7 +248,7 @@ let%expect_test _ =
simplifying further

(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, line 65, columns: 8-30
File ./examples/verbose.ml, line 77, columns: 8-30
Warning:
Usage of the `||` is redundant
You wrote:
Expand All @@ -257,7 +257,7 @@ let%expect_test _ =
simplifying further

(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, line 64, columns: 8-26
File ./examples/verbose.ml, line 76, columns: 8-26
Warning:
Usage of the `||` is redundant
You wrote:
Expand All @@ -266,7 +266,7 @@ let%expect_test _ =
simplifying further

(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, line 50, columns: 8-85
File ./examples/verbose.ml, line 62, columns: 8-85
Warning:
using nested if statements more than three layers deep
You wrote:
Expand All @@ -275,9 +275,9 @@ let%expect_test _ =
using let statements or helper methods / rethinking logic

(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, lines 32-43, columns: 2-5
File ./examples/verbose.ml, lines 44-55, columns: 2-5
Warning:
using nested match statements more than three layers deep
using nested match statements three or more layers deep
You wrote:
match l with
| [] ->
Expand Down Expand Up @@ -325,7 +325,7 @@ let%expect_test _ =
using `::` instead

(* ------------------------------------------------------------------------ *)
File ./examples/verbose.ml, line 50, columns: 0-80
File ./examples/verbose.ml, line 62, columns: 0-80
Warning:
exceeding the 80 character line limit
You wrote:
Expand Down

0 comments on commit 59b0ea4

Please sign in to comment.