nedap / formatting-stack

An efficient, smart, graceful composition of Clojure formatters, linters and such.
Eclipse Public License 2.0
99 stars 2 forks source link

Forbid read-eval syntax in formatted/linted files #180

Closed vemv closed 3 years ago

vemv commented 3 years ago

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

Author checklist

Reviewer checklist

vemv commented 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.

vemv commented 3 years ago

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.