Hello! How can I lint all files in dir?
Like
joker --lint ./src
But I have another problem - I receive some warnings but exit code is 0
I try to parse output
OUTPUT=`$(find ./src -type f -exec joker --lint {} \;)` rvm:ruby-2.5.3
./src/server/core.clj:17:13: Parse warning: arg[1] of core/+ must have type Number, got String
./src/server/core.clj:3:14: Parse warning: unused namespace bidi.bidi
but it's empty
echo $OUTPUT
OUTPUT=$(...)
captures stdout, but not stderr, unless you put a 2>&1
in there near the end, to redirect stderr to stdout.
As far as the exit code, maybe there's some trick to doing it via find -exec
, but that might require something more sophisticated, like this:
$ FILES=$(find . -type f)
$ RC=0; while read P; do joker --lint $P >/dev/null 2>&1 || RC=1; done <<< "$FILES"
$ echo $RC
1
$
Thx! Now I use
if [ $(find ./src -type f -exec joker --lint {} \; 2>&1 | wc -l) -ne 0] ....
That seems reasonable, since joker --lint
should produce no output (stdout nor stderr) if there are no issues with the code.
I don't think Joker supports linting multiple files in one invocation, so perhaps this something like this might be sufficient?:
$ find ./src -type f -name "*.cljc" -exec joker --lint \{} \;
Error: Cannot provide arguments to code while linting it.
There shouldn't be a \
before {}
Works for me (in Bash):
$ find ./src -type f -name "*.clj" -exec joker --lint \{} \;
./src/clj/clojure/genclass.clj:32:23: Parse warning: unused binding: mods
./src/clj/clojure/genclass.clj:66:16: Parse warning: arg[0] of core/replace must have type Associative, got String
./src/clj/clojure/genclass.clj:137:32: Parse warning: arg[0] of core/replace must have type Associative, got String
./src/clj/clojure/genclass.clj:140:47: Parse warning: arg[0] of core/replace must have type Associative, got String
./src/clj/clojure/genclass.clj:140:65: Parse warning: arg[0] of core/replace must have type Associative, got Char
./src/clj/clojure/genclass.clj:140:68: Parse warning: arg[1] of core/replace must have type Seqable, got Char
./src/clj/clojure/genclass.clj:168:20: Parse error: Unable to resolve symbol: into1
./src/clj/clojure/genclass.clj:168:43: Parse warning: unused binding: m
./src/clj/clojure/genclass.clj:208:14: Parse error: Unable to resolve symbol: add-annotations
./src/clj/clojure/genclass.clj:219:26: Parse warning: Wrong number of args (0) passed to core/pop
./src/clj/clojure/genclass.clj:243:26: Parse warning: Wrong number of args (0) passed to core/pop
./src/clj/clojure/genclass.clj:248:24: Parse warning: Wrong number of args (0) passed to core/pop
./src/clj/clojure/genclass.clj:416:8: Parse error: Unable to resolve symbol: reduce1
./src/clj/clojure/genclass.clj:158:9: Parse warning: unused binding: class-type
./src/clj/clojure/genclass.clj:138:9: Parse warning: unused binding: pkg-name
./src/clj/clojure/genclass.clj:507:11: Parse warning: WARNING: gen-class already refers to: #'joker.core/gen-class in namespace user, being replaced by: #'user/gen-class
./src/clj/clojure/genclass.clj:688:11: Parse warning: WARNING: gen-interface already refers to: #'joker.core/gen-interface in namespace user, being replaced by: #'user/gen-interface
./src/clj/clojure/core_proxy.clj:20:7: Parse warning: WARNING: method-sig already refers to: #'joker.core/method-sig in namespace user, being replaced by: #'user/method-sig
[...]
(That's in the Clojure source directory -- some of the files actually crash Joker!)