-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eliminate many incorrect unused-namespaces warnings
Two main categories of problems fixed here are (a) better parsing of ns forms to correctly reconstruct namespace name when they are given in 'nested' form, and (b) no longer ignore macro invocations when looking for uses of vars in a namespace. There is still at least one bug where uses of Vars in syntax-quoted forms are not recognized as uses of a namespace, leading to some remaining incorrect unused-namespace warnings, including one that is checked in as part of the Eastwood test suite, marked with a "TBD" in a comment as needing fixing. On crucible, these changes cause raw number of unused-namespaces warnings to go down from 618 to 390.
- Loading branch information
1 parent
d09ac2e
commit b587874
Showing
5 changed files
with
105 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
(ns testcases.unusednss | ||
(:use testcases.unusednss2) | ||
(:require [clojure [string :as s]] | ||
[clojure [repl :as r]] | ||
[clojure.data :as d])) | ||
|
||
;; clojure.repl should be considered used because of the macro | ||
;; invocation r/doc in foo1. | ||
|
||
(defn foo1 [x] | ||
(r/doc x)) | ||
|
||
|
||
;; TBD: clojure.data should be considered used because of the function | ||
;; call d/diff in macro foo2. However, as of right now Eastwood does | ||
;; not search through syntax-quoted forms for uses of namespaced vars. | ||
|
||
(defmacro foo2 [x y] | ||
`(d/diff ~x ~y)) | ||
|
||
|
||
;; testcases.unusednss2 should be considered used because of the use | ||
;; of atom1 in foo3. | ||
|
||
(defn foo3 [n] | ||
(swap! atom1 conj n)) | ||
|
||
|
||
;; Should be no warning for this require, because it is outside of ns | ||
;; form. | ||
|
||
(defn foo4 [ns] | ||
(require ns)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(ns testcases.unusednss2) | ||
|
||
(def atom1 (atom [])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters