Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

namespace-aliases could guard against unreadable files #291

Closed
vemv opened this issue Feb 1, 2021 · 1 comment · Fixed by #317
Closed

namespace-aliases could guard against unreadable files #291

vemv opened this issue Feb 1, 2021 · 1 comment · Fixed by #317

Comments

@vemv
Copy link
Member

vemv commented Feb 1, 2021

Brief

namespace-aliases i.e. the defn that backs cljr-slash, breaks if there's any .clj file with invalid syntax in a given project.

There's kind of a legitimate use case for .clj files with invalid syntax:

  • template files, e.g. moustached clojure
  • more importantly, WIP code.

As an aggraviating condition, cljr-slash omits errors, making this issue hard to debug / easy to forget.

So, namespace-aliases could omit files with invalid syntax, instead of throwing exceptions in presence of these files

Steps to reproduce the problem

  • echo "totally-invalid(((((((" > src/sample.clj
  • invoke refactor-nrepl.ns.libspecs/namespace-aliases

Suggestion

In:

{:clj (->> (core/find-in-project (some-fn core/clj-file? core/cljc-file?))

augment the (some-fn ...), with (every-pred readable? (some-fn ...)), where readable? is a defn that tries reading the ns form with tools.reader + tools.namespace.parse, returning false if any exception would have been thrown.

clj-refactor.el and refactor-nrepl version information

Both repos @ master

@bbatsov
Copy link
Member

bbatsov commented Feb 16, 2021

PR welcome!

@vemv vemv self-assigned this Jul 1, 2021
vemv added a commit that referenced this issue Jul 3, 2021
vemv added a commit that referenced this issue Jul 3, 2021
vemv added a commit that referenced this issue Jul 3, 2021
@vemv vemv closed this as completed in #317 Jul 8, 2021
vemv added a commit that referenced this issue Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants