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

Migrate to tools.reader to solve aliased keyword pains #198

Merged
merged 1 commit into from
Jul 26, 2017

Conversation

aredington
Copy link
Contributor

@aredington aredington commented Jul 26, 2017

Fixes #14

  • Takes dependency on clojure.tools.reader 1.0.2, lein deps :tree remains
    clean for this project.clj
  • Introduces kibit.check.reader namespace for managing all our reading
    concerns.
  • Migrate reading fns from kibit.check to kibit.check.reader
  • Add alias analyzing & util fns to kibit.check.reader
  • Add tests for analyzing fns to kibit.check-reader
  • Add keywords.clj test resource which includes several iterations of
    alias backflips to make sure that some simple edge cases for
    keyword reading are handled.

Notes:

I tested this across our internal projects which we want to integrate kibit into our CI process on, where we use a lot of namespace aliased keywords (largely due to spec)

We had previously had a blind spot past any aliased keyword in any file, so using this branch surfaced many more kibit improvements in our code base. Additionally, kibit ran to completion successfully in both projects.

We still have a blind spot in that some of our ClojureScript code contains #js {:foo :bar} tagged literals that are not properly handled in either clojure.core/read or clojure.tools.reader/read.

Love to hear feedback if people can play with this branch on their own source trees and vet it for correctness.

- Takes dependency on clojure.tools.reader 1.0.2, lein deps :tree remains
   clean for this project.clj
- Introduces kibit.check.reader namespace for managing all our reading
  concerns.
- Migrate reading fns from kibit.check to kibit.check.reader
- Add alias analyzing & util fns to kibit.check.reader
- Add tests for analyzing fns to kibit.check-reader
- Add keywords.clj test resource which includes several iterations of
   alias backflips to make sure that some simple edge cases for
   keyword reading are handled.
@arrdem
Copy link
Collaborator

arrdem commented Jul 26, 2017

👍 this looks excellent. Thanks for taking the time. I have no complaints after my read, but I'll let @danielcompton click the button.

@danielcompton danielcompton merged commit 685593d into clj-commons:master Jul 26, 2017
(ns resources.keywords
(:require [clojure.java.io :as io]))

(defn aliased-keyword-access
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be good to add some auto qualified namespaced keys in the test too: ::foo.


(defn using-a-different-keyword-alias-in-different-ns
[z]
(::str/another-fake-key z))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps in a different file, I'd like to add tests for what a Kibit suggestion would look like, particularly around which namespace/namespace alias is used in an expansion. They don't have to actually be correct expansions, but it would be good to document via test what our expectations are.

@danielcompton
Copy link
Member

danielcompton commented Jul 26, 2017

Hi Alex. Massive thanks to you for putting this together. I really like it, and it works really well. I added a few things that I noted in my review (that was mainly for my own notes), and also added support for alias. I really like the approach you took here, it is easy to extend to handle different namespace aliasing and switching techniques. I'm going to publish a beta now, and release it if no-one has any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants