joker

Discuss all things joker, the Clojure interpreter/linter on top of Go. https://github.com/candid82/joker
rende11 2019-01-04T16:20:27.004900Z

Hello! How can I lint all files in dir?

rende11 2019-01-04T16:21:06.005400Z

Like

joker --lint ./src

rende11 2019-01-05T09:50:52.006700Z

But I have another problem - I receive some warnings but exit code is 0

rende11 2019-01-05T10:00:37.006900Z

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

rende11 2019-01-05T10:00:59.007100Z

but it's empty

echo $OUTPUT

jcburley 2019-01-05T15:08:11.007300Z

OUTPUT=$(...) captures stdout, but not stderr, unless you put a 2>&1 in there near the end, to redirect stderr to stdout.

jcburley 2019-01-05T15:18:03.007500Z

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
$

rende11 2019-01-05T17:07:16.007700Z

Thx! Now I use

if [ $(find ./src -type f -exec joker --lint {} \; 2>&1 | wc -l) -ne 0] ....

jcburley 2019-01-05T17:08:30.008Z

That seems reasonable, since joker --lint should produce no output (stdout nor stderr) if there are no issues with the code.

jcburley 2019-01-04T16:25:18.005500Z

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 \{} \;

rende11 2019-01-04T19:49:51.005700Z

Error: Cannot provide arguments to code while linting it.

seancorfield 2019-01-04T20:42:47.005900Z

There shouldn't be a \ before {}

jcburley 2019-01-04T22:41:01.006100Z

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
[...]

jcburley 2019-01-04T22:41:21.006300Z

(That's in the Clojure source directory -- some of the files actually crash Joker!)