Closed vemv closed 3 years ago
Not ready yet:
defecord constructor syntax (#formatting_stack.strategies.foo.Foo[:a]
) inherently uses read-eval. This alone shouldn't prevent a file from being formatted/linted.
Instead one could detect if there's #=
in a given file (using e.g. rewrite-clj), and bind *read-eval*
accordingly.
Personally I'm not that interested in forbidding read-eval anymore. Or at least under a direct approach. It just gives too many problems IME - read-eval is sprinkled throughout Clojure internals so disabling it can be problematic.
Another approach would be linting this 'syntactically' i.e. with rewrite-clj.
Brief
Forbid read-eval syntax in formatted/linted files
This particularly targets Eastwood (since it's the only member of our stack that evals code, and therefore can run read-eval syntax) and tools.reader (which we internally use for various purposes).
It also is bound at
formatting-stack.core
level in case any other mechanisms happen to be sensitive.Fixes nedap/formatting-stack#158
QA plan
project
orbranch
formattertest
and nottest-resources
, since ns parsing (and refresh-dirs parsing) is part of how our Eastwood integration worksstrategy
.Author checklist
#=()
syntax. However#=
is not part of the Clojure API: it's absent from https://clojure.org/reference/reader#_dispatch , https://clojure.org/guides/weird_characters#=()
is a problem. My experience was that#=()
can be detected and fixed.Reviewer checklist