@@ -12,7 +12,7 @@ test_fail_could_be_one_liner if {
1212 input.yes
1313 }
1414 ` )
15- r := rule.report with input as module with config.rules as { " custom " : { " one-liner-rule " : { " level " : " error " }}}
15+ r := rule.report with input as module
1616
1717 r == expected_with_location ({
1818 " col" : 2 ,
@@ -32,7 +32,7 @@ test_fail_could_be_one_liner_all_keywords if {
3232 input.yes
3333 }
3434 ` )
35- r := rule.report with input as module with config.rules as { " custom " : { " one-liner-rule " : { " level " : " error " }}}
35+ r := rule.report with input as module
3636
3737 r == expected_with_location ({
3838 " col" : 2 ,
@@ -54,8 +54,8 @@ test_fail_could_be_one_liner_allman_style if {
5454 input.yes
5555 }
5656 ` )
57+ r := rule.report with input as module
5758
58- r := rule.report with input as module with config.rules as {" custom" : {" one-liner-rule" : {" level" : " error" }}}
5959 r == expected_with_location ({
6060 " col" : 2 ,
6161 " row" : 5 ,
@@ -73,8 +73,8 @@ test_success_too_long_for_a_one_liner if {
7373 some_really_long_rule_name_in_fact_53_characters_long == another_long_rule_but_only_45_characters_long
7474 }
7575 ` )
76+ r := rule.report with input as module
7677
77- r := rule.report with input as module with config.rules as {" custom" : {" one-liner-rule" : {" level" : " error" }}}
7878 r == set ()
7979}
8080
@@ -84,8 +84,7 @@ test_success_too_long_for_a_one_liner_configured_line_length if {
8484 some_really_long_rule_name_in_fact_53_characters_long
8585 }
8686 ` )
87- r := rule.report with input as module
88- with config.rules as {" custom" : {" one-liner-rule" : {" level" : " error" , " max-line-length" : 50 }}}
87+ r := rule.report with input as module with config.rules as {" custom" : {" one-liner-rule" : {" max-line-length" : 50 }}}
8988
9089 r == set ()
9190}
@@ -97,7 +96,7 @@ test_success_no_one_liner_comment_in_rule_body if {
9796 1 == 1
9897 }
9998 ` )
100- r := rule.report with input as module with config.rules as { " custom " : { " one-liner-rule " : { " level " : " error " }}}
99+ r := rule.report with input as module
101100
102101 r == set ()
103102}
@@ -108,7 +107,7 @@ test_success_no_one_liner_comment_in_rule_body_same_line if {
108107 1 == 1 # Surely one equals one
109108 }
110109 ` )
111- r := rule.report with input as module with config.rules as { " custom " : { " one-liner-rule " : { " level " : " error " }}}
110+ r := rule.report with input as module
112111
113112 r == set ()
114113}
@@ -120,7 +119,7 @@ test_success_no_one_liner_comment_in_rule_body_line_below if {
120119 # Surely one equals one
121120 }
122121 ` )
123- r := rule.report with input as module with config.rules as { " custom " : { " one-liner-rule " : { " level " : " error " }}}
122+ r := rule.report with input as module
124123
125124 r == set ()
126125}
@@ -131,14 +130,13 @@ test_success_does_not_use_if_v0 if {
131130 1 == 1
132131 }
133132 ` )
134- r := rule.report with input as module with config.rules as { " custom " : { " one-liner-rule " : { " level " : " error " }}}
133+ r := rule.report with input as module
135134
136135 r == set ()
137136}
138137
139138test_success_already_a_one_liner if {
140139 r := rule.report with input as ast.with_rego_v1 (` allow if 1 == 1` )
141- with config.rules as {" custom" : {" one-liner-rule" : {" level" : " error" }}}
142140
143141 r == set ()
144142}
@@ -155,6 +153,20 @@ test_has_notice_if_unmet_capability if {
155153 }}
156154}
157155
156+ # verify fix for https://github.com/StyraInc/regal/issues/1527
157+ test_fail_single_expression_spanning_multiple_lines_already_a_one_liner if {
158+ module := ast.policy (`
159+
160+ foo := bar if baz in {
161+ "foo",
162+ "bar",
163+ }
164+ ` )
165+ r := rule.report with input as module
166+
167+ r == set ()
168+ }
169+
158170expected := {
159171 " category" : " custom" ,
160172 " description" : " Rule body could be made a one-liner" ,
0 commit comments