Skip to content

namespace-aliases could guard against unreadable files #291

Closed
@vemv

Description

@vemv

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions