Fork me on GitHub
#clj-kondo
<
2022-11-21
>
Ory Band09:11:14

Hi. Is there a Clojure utility (or clj-kondo feature) that calculates "cognitive complexity"? there's something similiar in Rust lang that made me think https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity

borkdude09:11:48

There is no such thing in clj-kondo

Ory Band12:11:31

any other utility that does something like this in the ecosystem? does even make sense since clojure code tends to be more "condensed" ?

borkdude12:11:06

Not familiar with such a tool myself

tatut12:11:10

so it’s just cyclomatic complexity? (the past names referred to in that page suggests so)

Ory Band14:11:34

i guess? i too remember there are multiple naming for something like this. i remember in python there was a tool that checks how nested your code is i'm not even sure it makes sense in clojure due to scenarios like comp f g h and map of filter and threading etc etc

tatut14:11:36

afaict composition doesn’t increase the complexity as it measures the number of different execution paths that are possible

tatut14:11:02

found some pretty ancient code https://github.com/lokori/uncomplexor/blob/master/src/leiningen/uncomplexor.clj it should be doable to make a calculation like that with clj-kondo and issue a warning if a certain threshold is exceeded

skylize21:11:43

According to https://ask.clojure.org/index.php/11627/the-pipe-char-considered-valid-symbol-constituent-character, and re-verified by @alexmiller moments ago in thread linked below, a pipe char | is not valid as an identifier char even though the parser will accept it. It reserved for future use at the language level. I think clj-kondo should report it as an error.

:foo|bar   ; invalid
foo|bar    ; invalid
https://clojurians.slack.com/archives/CBE668G4R/p1669064417292719?thread_ts=1669063722.432239&amp;cid=CBE668G4R