-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functional tests for lint results
- Loading branch information
Showing
12 changed files
with
141 additions
and
4 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(ns eastwood-warning) | ||
|
||
(def x (def y ::z)) |
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 @@ | ||
#{] |
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,4 @@ | ||
(ns kondo-warning) | ||
|
||
(let [unused ::unused] | ||
::return) |
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 kondo-warning | ||
(:require | ||
[clojure.string :as foo])) |
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,28 @@ | ||
(ns functional.formatting-stack.linters.eastwood | ||
(:require | ||
[clojure.test :refer :all] | ||
[formatting-stack.linters.eastwood :as sut] | ||
[formatting-stack.protocols.linter :as linter] | ||
[matcher-combinators.matchers :as m] | ||
[matcher-combinators.test :refer [match?]])) | ||
|
||
(deftest lint! | ||
(let [linter (sut/new {})] | ||
(are [filename expected] (match? expected | ||
(linter/lint! linter [filename])) | ||
;; fixme should return a :reader-exception, currently lost in :note. lint! yields empty list | ||
#_#_ | ||
"test-resources/invalid_syntax.clj" | ||
(m/embeds | ||
[{:level :exception, | ||
:filename "test-resources/invalid_syntax.clj", | ||
:line 3, | ||
:column 2, | ||
:source :eastwood/lint!}]) | ||
|
||
"test-resources/eastwood_warning.clj" | ||
(m/embeds | ||
[{:source :eastwood/def-in-def | ||
:line 3 | ||
:column 13 | ||
:filename "test-resources/eastwood_warning.clj"}])))) |
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,27 @@ | ||
(ns functional.formatting-stack.linters.kondo | ||
(:require | ||
[clojure.test :refer :all] | ||
[formatting-stack.linters.kondo :as sut] | ||
[formatting-stack.protocols.linter :as linter] | ||
[matcher-combinators.matchers :as m] | ||
[matcher-combinators.test :refer [match?]])) | ||
|
||
(deftest lint! | ||
(let [linter (sut/new {:kondo-options {:output {:exclude-files []}}})] | ||
(are [filename expected] (match? expected | ||
(linter/lint! linter [filename])) | ||
"test-resources/invalid_syntax.clj" | ||
(m/embeds | ||
[{:level :error, | ||
:filename "test-resources/invalid_syntax.clj", | ||
:line 1, | ||
:column 2, | ||
:source :kondo/syntax}]) | ||
|
||
"test-resources/kondo_warning.clj" | ||
(m/embeds | ||
[{:source :kondo/unused-binding | ||
:level :warning | ||
:line 3 | ||
:column 7 | ||
:filename "test-resources/kondo_warning.clj"}])))) |
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,21 @@ | ||
(ns functional.formatting-stack.linters.line-length | ||
(:require | ||
[clojure.test :refer :all] | ||
[formatting-stack.linters.line-length :as sut] | ||
[formatting-stack.protocols.linter :as linter] | ||
[matcher-combinators.test :refer [match?]])) | ||
|
||
(deftest lint! | ||
(let [linter (sut/new {:max-line-length 22})] | ||
(are [filename expected] (match? expected | ||
(linter/lint! linter [filename])) | ||
"test-resources/invalid_syntax.clj" | ||
[] | ||
|
||
"test-resources/sample_clj_ns.clj" | ||
[{:source :formatting-stack/line-length | ||
:line 3 | ||
:column 23 | ||
:msg "Line exceeding 22 columns" | ||
:filename "test-resources/sample_clj_ns.clj"}]))) | ||
|
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,21 @@ | ||
(ns functional.formatting-stack.linters.loc-per-ns | ||
(:require | ||
[clojure.test :refer :all] | ||
[formatting-stack.linters.loc-per-ns :as sut] | ||
[formatting-stack.protocols.linter :as linter] | ||
[matcher-combinators.test :refer [match?]])) | ||
|
||
(deftest lint! | ||
(let [linter (sut/new {:max-lines-per-ns 4})] | ||
(are [filename expected] (match? expected | ||
(linter/lint! linter [filename])) | ||
"test-resources/invalid_syntax.clj" | ||
[] | ||
|
||
"test-resources/sample_clj_ns.clj" | ||
[{:source :formatting-stack/loc-per-ns | ||
:line 5 | ||
:column 1 | ||
:msg "Longer than 4 LOC. consider refactoring" | ||
:filename "test-resources/sample_clj_ns.clj"}]))) | ||
|
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,27 @@ | ||
(ns functional.formatting-stack.linters.ns-aliases | ||
(:require | ||
[clojure.test :refer :all] | ||
[formatting-stack.linters.ns-aliases :as sut] | ||
[formatting-stack.protocols.linter :as linter] | ||
[matcher-combinators.test :refer [match?]])) | ||
|
||
(deftest lint! | ||
(let [linter (sut/new {:max-lines-per-ns 4})] | ||
(are [filename expected] (match? expected | ||
(linter/lint! linter [filename])) | ||
"test-resources/invalid_syntax.clj" | ||
[{:source :formatting-stack/report-processing-error | ||
:filename "test-resources/invalid_syntax.clj" | ||
:msg "Encountered an exception" | ||
:level :exception | ||
:exception #(instance? Throwable %)}] | ||
|
||
"test-resources/ns_aliases_warning.clj" | ||
[{:source :formatting-stack/ns-aliases | ||
:line 3 | ||
:column 4 | ||
:warning-details-url "https://stuartsierra.com/2015/05/10/clojure-namespace-aliases" | ||
:msg "[clojure.string :as foo] is not a derived alias" | ||
:filename "test-resources/ns_aliases_warning.clj"}]))) | ||
|
||
(run-tests) |