Fork me on GitHub

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: 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


@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.


@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)..


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


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


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)