Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #386] Support (while true) pattern #391

Merged
merged 1 commit into from
May 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cases/testcases/while_true/green.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(ns testcases.while-true.green)

(defn foo []
(while true
(println 1)))
5 changes: 5 additions & 0 deletions cases/testcases/while_true/red.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(ns testcases.while-true.red)

(defn foo []
(while 1
(println 1)))
2 changes: 2 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

* Support `(is false)` pattern
* Closes https://github.com/jonase/eastwood/issues/384
* Support `(while true)` pattern
* Closes https://github.com/jonase/eastwood/issues/386

#### Bugfixes

Expand Down
7 changes: 7 additions & 0 deletions resource/eastwood/config/clojure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
:within-depth 2
:reason "Allow as-> to have constant tests without warning"})

(disable-warning
{:linter :constant-test
:if-inside-macroexpansion-of #{'clojure.core/while}
:within-depth 3
:qualifier true
:reason "Allow `(while true)` idiom"})

(disable-warning
{:linter :wrong-arity
:function-symbol 'clojure.core/eduction
Expand Down
11 changes: 11 additions & 0 deletions test/eastwood/lint_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,17 @@ relative to a specific macroexpansion"
#{'testcases.let.green} {:some-warnings false}
#{'testcases.let.red} {:some-warnings true})))

(deftest while-true-test
(testing "The `(while true)` idiom is supported"
(are [input expected] (testing input
(is (= (assoc expected :some-errors false)
(-> eastwood.lint/default-opts
(assoc :namespaces input)
(eastwood.lint/eastwood))))
true)
#{'testcases.while-true.green} {:some-warnings false}
#{'testcases.while-true.red} {:some-warnings true})))

(deftest is-false-test
(testing "The `(is false)` idiom is supported"
(are [input expected] (testing input
Expand Down