From 04ed561549df0e5fe718763ac8c7be6166df4328 Mon Sep 17 00:00:00 2001 From: voytech Date: Wed, 14 Feb 2018 18:36:02 +0100 Subject: [PATCH 1/5] Linter errors vector is now being returned by bikeshed after finishing its work --- src/bikeshed/core.clj | 50 ++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/src/bikeshed/core.clj b/src/bikeshed/core.clj index a56fee3..c4a2ec3 100644 --- a/src/bikeshed/core.clj +++ b/src/bikeshed/core.clj @@ -32,6 +32,9 @@ ([map]) ([map first])) +(defn add-issue [details issue] + (swap! details conj issue)) + (defn file-with-extension? "Returns true if the java.io.File represents a file whose name ends with one of the Strings in extensions." @@ -114,10 +117,15 @@ {(str namespace-name) (and (boolean doc) (not= "" doc))})) +(defn- linting-error-details-for-files [details files error-message] + (doseq [long-line-file all-long-lines] + (add-issue details {:file long-line-file + :description (str "Line length exceeds " max-line-length)}))) + (defn long-lines "Complain about lines longer than characters. max-line-length defaults to 80." - [source-files & {:keys [max-line-length] :or {max-line-length 80}}] + [details source-files & {:keys [max-line-length] :or {max-line-length 80}}] (printf "\nChecking for lines longer than %s characters.\n" max-line-length) (let [indexed-lines (fn [f] (with-open [r (io/reader f)] @@ -133,11 +141,12 @@ (do (println "Badly formatted files:") (println (join "\n" all-long-lines)) + (linting-error-details-for-files details all-long-lines (str "Line length exceeds " max-line-length)) true)))) (defn trailing-whitespace "Complain about lines with trailing whitespace." - [source-files] + [details source-files] (println "\nChecking for lines with trailing whitespace.") (let [indexed-lines (fn [f] (with-open [r (io/reader f)] @@ -152,11 +161,12 @@ (println "No lines found.") (do (println "Badly formatted files:") (println (join "\n" trailing-whitespace-lines)) + (linting-error-details-for-files trailing-whitespace-lines (str "Remove trailing whitespace lines")) true)))) (defn trailing-blank-lines "Complain about files ending with blank lines." - [source-files] + [details source-files] (println "\nChecking for files ending in blank lines.") (let [get-last-line (fn [f] (with-open [r (io/reader f)] @@ -167,11 +177,12 @@ (println "No files found.") (do (println "Badly formatted files:") (println (join "\n" bad-files)) + (linting-error-details-for-files bad-files (str "Remove blank line at the end of file.")) true)))) (defn bad-roots "Complain about the use of with-redefs." - [source-files] + [details source-files] (println "\nChecking for redefined var roots in source directories.") (let [indexed-lines (fn [f] (with-open [r (io/reader f)] @@ -186,11 +197,19 @@ (println "No with-redefs found.") (do (println "with-redefs found in source directory:") (println (join "\n" bad-lines)) + (doseq [entry bad-lines] + (let [file ((clojure.string/split entry #":") 0) + col ((clojure.string/split entry #":") 1) + line ((clojure.string/split entry #":") 2)] + (add-issue details {:file file + :line line + :column col + :description "Found with-redefs invokation"}))) true)))) (defn missing-doc-strings "Report the percentage of missing doc strings." - [project verbose] + [details project verbose] (println "\nChecking whether you keep up with your docstrings.") (try (let [source-files (mapcat #(-> % io/file @@ -255,7 +274,7 @@ (defn- check-all-arguments "Check if the arguments for functions collide with function from clojure/core" - [project] + [details project] (println "\nChecking for arguments colliding with clojure.core functions.") (let [core-functions (-> 'clojure.core ns-publics keys) source-files (mapcat #(-> % io/file @@ -291,23 +310,24 @@ "Bikesheds your project with totally arbitrary criteria. Returns true if the code has been bikeshedded and found wanting." [project {:keys [check? verbose max-line-length]}] - (let [all-files (visible-project-files project :source-paths :test-paths) + (let [details (atom []) + all-files (visible-project-files project :source-paths :test-paths) source-files (visible-project-files project :source-paths) results {:long-lines (when (check? :long-lines) (if max-line-length - (long-lines all-files + (long-lines details all-files :max-line-length max-line-length) - (long-lines all-files))) + (long-lines details all-files))) :trailing-whitespace (when (check? :trailing-whitespace) - (trailing-whitespace all-files)) + (trailing-whitespace details all-files)) :trailing-blank-lines (when (check? :trailing-blank-lines) - (trailing-blank-lines all-files)) + (trailing-blank-lines details all-files)) :var-redefs (when (check? :var-redefs) - (bad-roots source-files)) + (bad-roots details source-files)) :bad-methods (when (check? :docstrings) - (missing-doc-strings project verbose)) + (missing-doc-strings details project verbose)) :name-collisions (when (check? :name-collisions) - (check-all-arguments project))} + (check-all-arguments details project))} failures (->> results (filter second) (map first) @@ -318,4 +338,4 @@ (do (println "\nThe following checks failed:\n *" (str/join "\n * " failures) "\n") - failures)))) + {:failures failures :details @details})))) From 32dab94725bae8f213610f74655b72d6782547f8 Mon Sep 17 00:00:00 2001 From: voytech Date: Wed, 14 Feb 2018 19:34:04 +0100 Subject: [PATCH 2/5] detailed linter error format improvement --- src/bikeshed/core.clj | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/src/bikeshed/core.clj b/src/bikeshed/core.clj index c4a2ec3..665ba41 100644 --- a/src/bikeshed/core.clj +++ b/src/bikeshed/core.clj @@ -117,11 +117,6 @@ {(str namespace-name) (and (boolean doc) (not= "" doc))})) -(defn- linting-error-details-for-files [details files error-message] - (doseq [long-line-file all-long-lines] - (add-issue details {:file long-line-file - :description (str "Line length exceeds " max-line-length)}))) - (defn long-lines "Complain about lines longer than characters. max-line-length defaults to 80." @@ -133,15 +128,15 @@ (keep-indexed (fn [idx line] (when (> (count line) max-line-length) - (trim (join ":" [(.getAbsolutePath f) (inc idx) line])))) + {:file (.getAbsolutePath f) :line (inc idx) :content line})) (line-seq r))))) all-long-lines (flatten (map indexed-lines source-files))] (if (empty? all-long-lines) (println "No lines found.") (do (println "Badly formatted files:") - (println (join "\n" all-long-lines)) - (linting-error-details-for-files details all-long-lines (str "Line length exceeds " max-line-length)) + (println (join "\n" (mapv #(trim (str (:file %) ":" (:line %) ":" (:content %))) all-long-lines))) + (add-issue details {:description (str "Line length exceeds " max-line-length) :type :long-lines :details all-long-lines}) true)))) (defn trailing-whitespace @@ -154,14 +149,14 @@ (keep-indexed (fn [idx line] (when (re-seq #"\s+$" line) - (trim (join ":" [(.getAbsolutePath f) (inc idx) line])))) + {:file (.getAbsolutePath f) :line (inc idx) :content line})) (line-seq r))))) trailing-whitespace-lines (flatten (map indexed-lines source-files))] (if (empty? trailing-whitespace-lines) (println "No lines found.") (do (println "Badly formatted files:") - (println (join "\n" trailing-whitespace-lines)) - (linting-error-details-for-files trailing-whitespace-lines (str "Remove trailing whitespace lines")) + (println (join "\n" (mapv #(trim (str (:file %) ":" (:line %) ":" (:content %))) trailing-whitespace-lines))) + (add-issue details {:description "Remove trailing whitespace lines" :type :trailing-whitespace :details trailing-whitespace-lines}) true)))) (defn trailing-blank-lines @@ -171,13 +166,13 @@ (let [get-last-line (fn [f] (with-open [r (io/reader f)] (when (re-matches #"^\s*$" (last (line-seq r))) - (.getAbsolutePath f)))) + {:file (.getAbsolutePath f)}))) bad-files (filter some? (map get-last-line source-files))] (if (empty? bad-files) (println "No files found.") (do (println "Badly formatted files:") - (println (join "\n" bad-files)) - (linting-error-details-for-files bad-files (str "Remove blank line at the end of file.")) + (println (join "\n" (mapv #(trim (:file %)) bad-files))) + (add-issue details {:description "Remove blank line at the end of file." :type :trailing-blank-lines :details bad-files}) true)))) (defn bad-roots @@ -190,21 +185,14 @@ (keep-indexed (fn [idx line] (when (re-seq #"\(with-redefs" line) - (trim (join ":" [(.getAbsolutePath f) (inc idx) line])))) + {:file (.getAbsolutePath f) :line (inc idx) :content line})) (line-seq r))))) bad-lines (flatten (map indexed-lines source-files))] (if (empty? bad-lines) (println "No with-redefs found.") (do (println "with-redefs found in source directory:") - (println (join "\n" bad-lines)) - (doseq [entry bad-lines] - (let [file ((clojure.string/split entry #":") 0) - col ((clojure.string/split entry #":") 1) - line ((clojure.string/split entry #":") 2)] - (add-issue details {:file file - :line line - :column col - :description "Found with-redefs invokation"}))) + (println (join "\n" (mapv #(trim (str (:file %) ":" (:line %) ":" (:content %))) bad-lines))) + (add-issue details {:description "Found with-redefs invokations" :type :var-redefs :details bad-lines}) true)))) (defn missing-doc-strings From b08fc7df107a29d0919458a21ee3199ac43cb99b Mon Sep 17 00:00:00 2001 From: voytech Date: Wed, 14 Feb 2018 22:11:58 +0100 Subject: [PATCH 3/5] Started updating README.md file --- README.md | 13 +++++++++++++ src/bikeshed/core.clj | 24 ++++++++++++++++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7ea2025..c09768c 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,19 @@ You can also add the `:bikeshed` option map directly to your `project.clj`: :dependencies [[clj-http "3.3.0"]]) ``` +## Using Bikeshed Processing Results + +In order to allow third party library consumers to decide on issue reporting approach, bikeshed returns a record containing processing details: + +Results can look as follows: + +```clj +{:failures ("name-collisions"), :details [{:description "Arguments colliding with core functions", :type :name-collisions, :details [{:file #'bikeshed.core/colliding-arguments, :content "map', 'first'"}]}]} +``` +As You can see the record contains two root entries: +- failures - which is a brief summary on what linting methods have failed. +- details - which contain processing details. This entry can contain a lot of data depending on linting method being invoked. General convention is that it contains a vector of reported issues and each issue in that vector is composed of: file, content (which may vary depending on function), line (optional). + ## License Copyright © 2012 Matthew Lee Hinman & Sonian diff --git a/src/bikeshed/core.clj b/src/bikeshed/core.clj index 665ba41..6c71de7 100644 --- a/src/bikeshed/core.clj +++ b/src/bikeshed/core.clj @@ -262,7 +262,7 @@ (defn- check-all-arguments "Check if the arguments for functions collide with function from clojure/core" - [details project] + [collisions project] (println "\nChecking for arguments colliding with clojure.core functions.") (let [core-functions (-> 'clojure.core ns-publics keys) source-files (mapcat #(-> % io/file @@ -273,12 +273,15 @@ (map (fn [function] (let [args (wrong-arguments function core-functions)] (when (seq args) - (if (= 1 (count args)) - (println (str function ": '" (first args) "'") - "is colliding with a core function") - (println (str function ": '" - (clojure.string/join "', '" args) "'") - "are colliding with core functions"))) + (do + (if (= 1 (count args)) + (println (str function ": '" (first args) "'") + "is colliding with a core function") + (println (str function ": '" + (clojure.string/join "', '" args) "'") + "are colliding with core functions")) + (swap! collisions conj {:file function + :content (str (clojure.string/join "', '" args) "'")}))) (count args)))) (apply +) (pos?)))) @@ -315,7 +318,12 @@ :bad-methods (when (check? :docstrings) (missing-doc-strings details project verbose)) :name-collisions (when (check? :name-collisions) - (check-all-arguments details project))} + (let [collisions (atom []) + result (check-all-arguments collisions project)] + (add-issue details {:description "Arguments colliding with core functions" + :type :name-collisions + :details @collisions}) + result))} failures (->> results (filter second) (map first) From 7e214ca387b2a403c74a9e6a1bdb0495af6547bb Mon Sep 17 00:00:00 2001 From: voytech Date: Thu, 15 Feb 2018 00:00:41 +0100 Subject: [PATCH 4/5] Included missing docstrings function results into result map --- README.md | 2 +- src/bikeshed/core.clj | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index c09768c..232d7d6 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ In order to allow third party library consumers to decide on issue reporting app Results can look as follows: ```clj -{:failures ("name-collisions"), :details [{:description "Arguments colliding with core functions", :type :name-collisions, :details [{:file #'bikeshed.core/colliding-arguments, :content "map', 'first'"}]}]} +{:failures ("name-collisions"), :details [{:description "Arguments colliding with core functions", :type :name-collisions, :issues [{:file #'bikeshed.core/colliding-arguments, :content "map', 'first'"}]}]} ``` As You can see the record contains two root entries: - failures - which is a brief summary on what linting methods have failed. diff --git a/src/bikeshed/core.clj b/src/bikeshed/core.clj index 6c71de7..f3b5a03 100644 --- a/src/bikeshed/core.clj +++ b/src/bikeshed/core.clj @@ -136,7 +136,7 @@ (do (println "Badly formatted files:") (println (join "\n" (mapv #(trim (str (:file %) ":" (:line %) ":" (:content %))) all-long-lines))) - (add-issue details {:description (str "Line length exceeds " max-line-length) :type :long-lines :details all-long-lines}) + (add-issue details {:description (str "Line length exceeds " max-line-length) :type :long-lines :issues all-long-lines}) true)))) (defn trailing-whitespace @@ -156,7 +156,7 @@ (println "No lines found.") (do (println "Badly formatted files:") (println (join "\n" (mapv #(trim (str (:file %) ":" (:line %) ":" (:content %))) trailing-whitespace-lines))) - (add-issue details {:description "Remove trailing whitespace lines" :type :trailing-whitespace :details trailing-whitespace-lines}) + (add-issue details {:description "Remove trailing whitespace lines" :type :trailing-whitespace :issues trailing-whitespace-lines}) true)))) (defn trailing-blank-lines @@ -172,7 +172,7 @@ (println "No files found.") (do (println "Badly formatted files:") (println (join "\n" (mapv #(trim (:file %)) bad-files))) - (add-issue details {:description "Remove blank line at the end of file." :type :trailing-blank-lines :details bad-files}) + (add-issue details {:description "Remove blank line at the end of file." :type :trailing-blank-lines :issues bad-files}) true)))) (defn bad-roots @@ -192,7 +192,7 @@ (println "No with-redefs found.") (do (println "with-redefs found in source directory:") (println (join "\n" (mapv #(trim (str (:file %) ":" (:line %) ":" (:content %))) bad-lines))) - (add-issue details {:description "Found with-redefs invokations" :type :var-redefs :details bad-lines}) + (add-issue details {:description "Found with-redefs invokations" :type :var-redefs :issues bad-lines}) true)))) (defn missing-doc-strings @@ -200,7 +200,8 @@ [details project verbose] (println "\nChecking whether you keep up with your docstrings.") (try - (let [source-files (mapcat #(-> % io/file + (let [issues (atom []) + source-files (mapcat #(-> % io/file ns-find/find-clojure-sources-in-dir) (flatten (get-all project :source-paths))) all-namespaces (->> source-files @@ -239,11 +240,14 @@ (when verbose (println "\nNamespaces without docstrings:") (doseq [[ns-name _] (sort no-ns-doc)] - (println ns-name))) + (println ns-name) + (swap! issues conj {:file " " :content (str "Namespace without docstrings: " ns-name)}))) (when verbose (println "\nMethods without docstrings:") (doseq [[method _] (sort no-docstrings)] - (println method))) + (println method) + (swap! issues conj {:file " " :content (str "Method without docstrings: " method)}))) + (add-issue details {:description "No docstrings" :type :docstrings :issues @issues}) (or (-> no-docstrings count pos?) (-> no-ns-doc count pos?))) (catch Throwable t @@ -318,11 +322,11 @@ :bad-methods (when (check? :docstrings) (missing-doc-strings details project verbose)) :name-collisions (when (check? :name-collisions) - (let [collisions (atom []) + (let [collisions (atom []) result (check-all-arguments collisions project)] (add-issue details {:description "Arguments colliding with core functions" :type :name-collisions - :details @collisions}) + :issues @collisions}) result))} failures (->> results (filter second) @@ -331,7 +335,7 @@ (map name))] (if (empty? failures) (println "\nSuccess") - (do (println "\nThe following checks failed:\n *" - (str/join "\n * " failures) - "\n") - {:failures failures :details @details})))) + (println "\nThe following checks failed:\n *" + (str/join "\n * " failures) + "\n")) + {:failures failures :details @details})) From 7496b0359a568c42e62f7fcc6960ad57ab223b58 Mon Sep 17 00:00:00 2001 From: voytech Date: Thu, 15 Feb 2018 15:32:35 +0100 Subject: [PATCH 5/5] Line length in core.clj improvements. Better result record sample in README.md --- README.md | 15 ++++++- src/bikeshed/core.clj | 94 ++++++++++++++++++++++++++++--------------- 2 files changed, 76 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 232d7d6..a3a7950 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,20 @@ In order to allow third party library consumers to decide on issue reporting app Results can look as follows: ```clj -{:failures ("name-collisions"), :details [{:description "Arguments colliding with core functions", :type :name-collisions, :issues [{:file #'bikeshed.core/colliding-arguments, :content "map', 'first'"}]}]} +{:failures + ("long-lines" "var-redefs" "name-collisions"), + :details [ + {:description "Line length exceeds 80", :type :long-lines, :issues ( + {:file "C:\\PROGRAMMING\\github\\lein-bikeshed\\src\\bikeshed\\core.clj", :line 301, :content " (let [join-args #(str (clojure.string/join \"' '\" %) \"'\")]"} + {:file "C:\\PROGRAMMING\\github\\lein-bikeshed\\src\\bikeshed\\core.clj", :line 349, :content " :max-line-length max-line-length)"} + {:file "C:\\PROGRAMMING\\github\\lein-bikeshed\\src\\bikeshed\\core.clj", :line 352, :content " (trailing-whitespace details all-files))"} + {:file "C:\\PROGRAMMING\\github\\lein-bikeshed\\src\\bikeshed\\core.clj", :line 354, :content " (trailing-blank-lines details all-files))"} + {:file "C:\\PROGRAMMING\\github\\lein-bikeshed\\src\\bikeshed\\core.clj", :line 358, :content " (missing-doc-strings details project verbose))"})} + {:description "Found with-redefs calls", :type :var-redefs, :issues ( + {:file "C:\\PROGRAMMING\\github\\lein-bikeshed\\src\\bikeshed\\core.clj", :line 18, :content " (with-redefs [+ -]"} + {:file "C:\\PROGRAMMING\\github\\lein-bikeshed\\src\\bikeshed\\core.clj", :line 201, :content " (when (re-seq #\"\\(with-redefs\" line)"})} + {:description "Arguments colliding with core functions", :type :name-collisions, :issues [ + {:file #'bikeshed.core/colliding-arguments, :content "map' 'first'"}]}]} ``` As You can see the record contains two root entries: - failures - which is a brief summary on what linting methods have failed. diff --git a/src/bikeshed/core.clj b/src/bikeshed/core.clj index f3b5a03..dc5d9ee 100644 --- a/src/bikeshed/core.clj +++ b/src/bikeshed/core.clj @@ -117,6 +117,9 @@ {(str namespace-name) (and (boolean doc) (not= "" doc))})) +(defn- format-issue [issue] + (trim (str (:file issue) ":" (:line issue) ":" (:content issue)))) + (defn long-lines "Complain about lines longer than characters. max-line-length defaults to 80." @@ -128,15 +131,20 @@ (keep-indexed (fn [idx line] (when (> (count line) max-line-length) - {:file (.getAbsolutePath f) :line (inc idx) :content line})) + {:file (.getAbsolutePath f) + :line (inc idx) + :content line})) (line-seq r))))) all-long-lines (flatten (map indexed-lines source-files))] (if (empty? all-long-lines) (println "No lines found.") (do (println "Badly formatted files:") - (println (join "\n" (mapv #(trim (str (:file %) ":" (:line %) ":" (:content %))) all-long-lines))) - (add-issue details {:description (str "Line length exceeds " max-line-length) :type :long-lines :issues all-long-lines}) + (println (join "\n" (mapv format-issue all-long-lines))) + (add-issue details {:description (str "Line length exceeds " + max-line-length) + :type :long-lines + :issues all-long-lines}) true)))) (defn trailing-whitespace @@ -149,14 +157,18 @@ (keep-indexed (fn [idx line] (when (re-seq #"\s+$" line) - {:file (.getAbsolutePath f) :line (inc idx) :content line})) + {:file (.getAbsolutePath f) + :line (inc idx) + :content line})) (line-seq r))))) trailing-whitespace-lines (flatten (map indexed-lines source-files))] (if (empty? trailing-whitespace-lines) (println "No lines found.") (do (println "Badly formatted files:") - (println (join "\n" (mapv #(trim (str (:file %) ":" (:line %) ":" (:content %))) trailing-whitespace-lines))) - (add-issue details {:description "Remove trailing whitespace lines" :type :trailing-whitespace :issues trailing-whitespace-lines}) + (println (join "\n" (mapv format-issue trailing-whitespace-lines))) + (add-issue details {:description "Remove trailing whitespace lines" + :type :trailing-whitespace + :issues trailing-whitespace-lines}) true)))) (defn trailing-blank-lines @@ -172,7 +184,9 @@ (println "No files found.") (do (println "Badly formatted files:") (println (join "\n" (mapv #(trim (:file %)) bad-files))) - (add-issue details {:description "Remove blank line at the end of file." :type :trailing-blank-lines :issues bad-files}) + (add-issue details {:description "Remove blank line at the end" + :type :trailing-blank-lines + :issues bad-files}) true)))) (defn bad-roots @@ -185,14 +199,18 @@ (keep-indexed (fn [idx line] (when (re-seq #"\(with-redefs" line) - {:file (.getAbsolutePath f) :line (inc idx) :content line})) + {:file (.getAbsolutePath f) + :line (inc idx) + :content line})) (line-seq r))))) bad-lines (flatten (map indexed-lines source-files))] (if (empty? bad-lines) (println "No with-redefs found.") (do (println "with-redefs found in source directory:") - (println (join "\n" (mapv #(trim (str (:file %) ":" (:line %) ":" (:content %))) bad-lines))) - (add-issue details {:description "Found with-redefs invokations" :type :var-redefs :issues bad-lines}) + (println (join "\n" (mapv format-issue bad-lines))) + (add-issue details {:description "Found with-redefs calls" + :type :var-redefs + :issues bad-lines}) true)))) (defn missing-doc-strings @@ -241,13 +259,19 @@ (println "\nNamespaces without docstrings:") (doseq [[ns-name _] (sort no-ns-doc)] (println ns-name) - (swap! issues conj {:file " " :content (str "Namespace without docstrings: " ns-name)}))) + (swap! issues conj {:file " " + :content (str "Namespace without docstrings: " + ns-name)}))) (when verbose (println "\nMethods without docstrings:") (doseq [[method _] (sort no-docstrings)] (println method) - (swap! issues conj {:file " " :content (str "Method without docstrings: " method)}))) - (add-issue details {:description "No docstrings" :type :docstrings :issues @issues}) + (swap! issues conj {:file " " + :content (str "Method without docstrings: " + method)}))) + (add-issue details {:description "No docstrings" + :type :docstrings + :issues @issues}) (or (-> no-docstrings count pos?) (-> no-ns-doc count pos?))) (catch Throwable t @@ -272,7 +296,11 @@ source-files (mapcat #(-> % io/file ns-find/find-clojure-sources-in-dir) (flatten (get-all project :source-paths))) - all-publics (mapcat read-namespace source-files)] + all-publics (mapcat read-namespace source-files) + add-collision (fn [func args] + (let [join-args #(str (clojure.string/join "' '" %) "'")] + (swap! collisions conj {:file func + :content (join-args args)})))] (->> all-publics (map (fn [function] (let [args (wrong-arguments function core-functions)] @@ -284,12 +312,19 @@ (println (str function ": '" (clojure.string/join "', '" args) "'") "are colliding with core functions")) - (swap! collisions conj {:file function - :content (str (clojure.string/join "', '" args) "'")}))) + (add-collision function args))) (count args)))) (apply +) (pos?)))) +(defn check-name-collisions [details project] + (let [collisions (atom []) + result (check-all-arguments collisions project)] + (add-issue details {:description "Arguments colliding with core functions" + :type :name-collisions + :issues @collisions}) + result)) + (defn visible-project-files "Given a project and list of keys (such as `:source-paths` or `:test-paths`, return all source files underneath those directories." @@ -308,26 +343,21 @@ (let [details (atom []) all-files (visible-project-files project :source-paths :test-paths) source-files (visible-project-files project :source-paths) - results {:long-lines (when (check? :long-lines) - (if max-line-length - (long-lines details all-files - :max-line-length max-line-length) - (long-lines details all-files))) + results {:long-lines (when (check? :long-lines) + (if max-line-length + (long-lines details all-files + :max-line-length max-line-length) + (long-lines details all-files))) :trailing-whitespace (when (check? :trailing-whitespace) (trailing-whitespace details all-files)) :trailing-blank-lines (when (check? :trailing-blank-lines) (trailing-blank-lines details all-files)) - :var-redefs (when (check? :var-redefs) - (bad-roots details source-files)) - :bad-methods (when (check? :docstrings) - (missing-doc-strings details project verbose)) - :name-collisions (when (check? :name-collisions) - (let [collisions (atom []) - result (check-all-arguments collisions project)] - (add-issue details {:description "Arguments colliding with core functions" - :type :name-collisions - :issues @collisions}) - result))} + :var-redefs (when (check? :var-redefs) + (bad-roots details source-files)) + :bad-methods (when (check? :docstrings) + (missing-doc-strings details project verbose)) + :name-collisions (when (check? :name-collisions) + (check-name-collisions details project))} failures (->> results (filter second) (map first)