-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
Correct various :arglists #334
Conversation
This still has a Getting the |
Often, these functions assume a "context" coming from a `->` call. This context should be reflected in the :arglists - otherwise they stop being truthful and various tooling will display incorrect information.
Whoops, amended. The typo (cxt <-> ctx) hindered the grepping 😄
I actually tried to apply some fine-grained reasoning here. The reasoning being: something like Most fragments aren't like that: they are fragments that need a preceding fragment. e.g. Disclaimer, I might be wrong here and there as I cannot claim comprehensive expertise of SQL syntax. My changes were driven from whenever Eastwood pointed out that the arglist was technically wrong. Assuming the CI improvements from #331 , it seems a plausible path to begin by having technically correct arglists, and later keep progressing with more fine-grained arglists driven by insights that may grow organically. |
Remember that HoneySQL helpers are (mostly) "order insensitive": dev=> (-> (h/with-columns [:id :int :null])
#_=> (h/create-table :fruit)
#_=> (cond-> :some-cond (h/with-columns [:description :text]))
#_=> (sql/format))
["CREATE TABLE fruit (id INT NULL, description TEXT)"] This is important when building SQL programmatically: that's why all of the helpers have an optional I am concerned about a goal of "satisfy Eastwood" here as opposed to "accurately document argument lists" for (IDE) tooling -- I don't consider these to be entirely well-aligned -- which is why, right now, the helper I've run into this sort of problem before with Eastwood -- I think it was with |
* Updated Eastwood to 0.5.1 * Added set -Eeo pipefail to run-tests.sh (I don't like -x) * Run CI on PR * Add shellcheck to steps I'm not going to run Eastwood on tests at this point (see my comments in #334 for reasons).
TIL!
👍
To be clear I don't consider satisfying a linter a goal in itself. Instead I consider it a tool for achieving a technically correct arglist that can help me when using Honey (I do from time to time depending on the job at hand). Often these actually end up improving things domain-wise; a great practical example was mcohen01/amazonica#445 which made arglists correct and far richer than before. In our case, if an arg, which in fact can be used, is omitted from the :arglists, then I can get confused about the meaning of each argument in said arglist (because I won't know if the declared arg refers to the query, or to the specific thing). So, it seems pretty achievable to add the optional - ([x])
+ ([x] [query x]) That would seem technically correct and would keep things usable (since one, as a user, can choose to omit the new arglist). Perhaps by keeping the new arglist in last position and/or naming the Finally, a ns docstring could describe whatever convention is decided. Armed with these we could avoid pseudo :arglists which I'm not atm convinced are an usual practice (clojure.core can rename arglists but keeps them technically correct AFAICT. e.g.) |
Is And then we have stuff like this (for ([name doc-string? attr-map? [params*] prepost-map? body]
[name doc-string? attr-map? ([params*] prepost-map? body) + attr-map?]) Does Eastwood understand that As I said, I'll keep this open while I think about it some more but I'm much less concerned about Eastwood liking the |
OK, I went digging into my notes about Eastwood and You linked to Here's one of the issues raised early on about Eastwood using The current state of Eastwood's built-in configuration to address this is here: https://github.com/jonase/eastwood/tree/master/resource/eastwood/config (in three files). This just feels wrong-headed to me so I'm not going to pander to Eastwood on this -- clj-kondo/LSP do "the right thing" and allow for arbitrary |
Whoops, I unawarely chose a particularly tricky case (I didn't notice it used Anyway, :arglists using "regex" notation are only a fraction of honeysql's. So I don't think that consideration alone is enough to forget about the issue altogether. Again, I'm not pushing for a fix just for satisfying a linter. Other tooling (like cider-nrepl) also makes use of :arglists. Omitting Hope these considerations help! |
It's a useful discussion to have, so I appreciate it. It's inherently "hard" for deliberately variadic functions that can accept pretty much "anything" -- but I expect I'll continue to tune |
Re: |
That's great!
I meant this - it simply uses arglists for displaying them along the docstring etc
I've witnessed many factual errors in various codebases related to :arglists, detected by Eastwood. Namely, :arglists can fall out of sync relative to their originally intended usage. So a tool that give true positives is useful. The occasional presence of false positives dosen't necessarily void that usefulness (and I plan to fix those FPs as described in jonase/eastwood#399). |
Often, these functions assume a "context" coming from a
->
call.This context should be reflected in the :arglists - otherwise they stop being truthful and various tooling will display incorrect information.
It would also allow Eastwood to successfully lint tests.