code-reviews

sveri 2015-07-02T14:07:40.000631Z

Hi, I just hacked something together to find out if any string from a file given a list of strings, is contained in any .java file in a folder: https://gist.github.com/sveri/701aa9f1cd1af12a37d7 As much as this solution works, as much I don't like it. Any other ideas on how to approach that? PS: an example is in the bottom of the gist

rwtnorton 2015-07-02T15:03:44.000632Z

@sveri, line 15 could take advantage of the alias io. I was expecting to see another re-matches for search-string-in-file. I am wondering if the shape of search-package-in-source could use (--> ... ) leading up to a filter at the end. Clean and easy to read.

crisptrutski 2015-07-02T15:07:55.000633Z

@sveri #(= nil %) could just be nil?, but even better (remove #(= nil %) (map #(search-string-in-file % file) libs))) to (remove #(search-string-in-file % file) libs)..

crisptrutski 2015-07-02T15:09:02.000634Z

and (if (and needle haystack (.contains (.toLowerCase haystack) (.toLowerCase needle))) fp nil) could be replaced just with that condition, just need a truthy return

crisptrutski 2015-07-02T15:11:05.000635Z

and the (reduce (fn [a b] (conj a b)) [] ...)) patterns could be (into [] …) i believe

crisptrutski 2015-07-02T15:14:08.000636Z

search-string-in-file is also slurping the file for each search term, might want to memoize or capture that in a closure (curry search-string-in-file to take the file first, this also lets #(search-string-in-file % file) get unwrapped to (search-string-in-file file)