clojure-emacs / clojure-emacs/clj-refactor.el
cljr--find-source-ns-of-test-ns can choose the wrong namespace when there are multiple matches
- Dominant language
- Emacs Lisp
- Stars
- 785
- Forks
- 110
- PR merge metrics
- No merged PRs in 30d
Description
The sut can choose the wrong namespace when there are multiple partial matches. For example, given a source tree with:
```
src/advent/day1.clj
src/advent/day10.clj
```
Creating a new buffer named `test/advent/day10_test.clj` results in:
```
(ns advent.day10-test
(:require [advent.day1 :as sut]
[clojure.test :as t]))
```
When we'd expect:
```
(ns advent.day10-test
(:require [advent.day10 :as sut]
[clojure.test :as t]))
```
I have a partial fix at https://github.com/orb/clj-refactor.el/commit/a8306c2ff0c81d5930e90afa4a304e2a495bed55. I did not submit a PR because I didn't meet all the contribution requirements yet. However, the basic idea was that instead of finding the first matching file, we'd find the longest matching file.
This solution works well when the `sut` class exists. If, in this example, `src/advent/day10.clj` did not exist yet, it would still choose `advent.day1` as the best match. I don't like that, but I'm not sure how to best fix that and still maintain the flexibility the code is apparently trying to achieve.
Contributor guide
Assessment
This issue has not been assessed yet.