-
Notifications
You must be signed in to change notification settings - Fork 11
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
chore: add specs to the codebase #74
Conversation
|
||
(defn- sample-tag [pulls] | ||
(-> (spec/sample ::core-spec/tag) | ||
(assoc :pulls pulls))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this threading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was more readable for me this way and I was playing it a lot since generator overrides aren't always working for some reason.
metosin/jsonista {:mvn/version "0.2.4"} | ||
org.clojure/core.async {:mvn/version "0.4.500"} ; clojure spec fixed | ||
metosin/jsonista {:mvn/version "0.2.5"} | ||
org.clojure/core.async {:mvn/version "1.0.567"} ; clojure spec fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there still a need for the comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, but I have not tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's safe to remove
:pull-request pull} | ||
;; TODO - when-let? | ||
(if-let [[_ type scope subject] (re-find angular-pattern title)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no reason why this can't be a when-let.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I believe so. I put that as a TODO because the tests were failing and I could not verify the correctness of the function.
Because of an upstream bug grimradical/clj-semver#7
I caught a really nice issue with generative testing which was reported before grimradical/clj-semver#7 |
That's really cool. |
Please consider using explicitly defined function applications instead of
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it necessary to set ^:no-gen
on so many functions? If yes, was that because those had side effects? If still yes, consider suffixing their names with !
or, possibly even better, factor out the side effects.
Co-Authored-By: Szabó Krisztián <thenonameguy24@gmail.com>
Yes, unfortunately those functions are depending on each other and side effecting. Although your comment is valid and I'll try to extract that part into a separate function and use arguments instead in a separate pull request. |
Co-Authored-By: Szabó Krisztián <thenonameguy24@gmail.com>
@@ -54,14 +66,11 @@ | |||
endpoint (pulls-url config)] | |||
(throttler/throttle-fn (partial issue-request endpoint) ratelimit :second))) | |||
|
|||
(defn- get-pulls [config] | |||
(defn fetch-pulls [config] | |||
(let [call-api (call-api-fn config) | |||
first-request (make-request config) | |||
first-response (call-api first-request) | |||
{links :links first-body :body} first-response | |||
rest-requests (make-requests config links) | |||
rest-responses (pmap call-api rest-requests)] | |||
(into first-body (flatten (map :body rest-responses))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(into first-body (flatten (map :body rest-responses))))) | |
(into first-body (comp (map :body) cat) rest-responses))))) |
Just putting this on your radar: https://clojuredocs.org/clojure.core/cat
This version is a bit more efficient not only because not allocating an intermediate map
lazyseq, but by only flattening on a single level.
@@ -110,8 +108,7 @@ | |||
(conj pulls pull)))) | |||
|
|||
(defn ^:no-gen parse-changes [config {:keys [pulls] :as tag}] | |||
(->> (map (partial parse-pull config) pulls) | |||
(remove nil?) | |||
(->> (keep (partial parse-pull config) pulls) | |||
(reduce filter-reverted []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you rewrite filter-reverted
to be pred-ish (sorta like (defn reverted? [pulls pull] ,,,)
), you could write these 2 lines as (into [] (comp (keep (partial ,,,)) (remove reverted?)) pulls)
, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also comp in the next line then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also though that but filter-reverted
needs to see the full keep
produced seq. Therefore you can't use on it on a single element inside a transducer chain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I didn't realise pulls
is that seq.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few more nits I would address if this was my PR, but functionality-wise this looks good :)
No description provided.