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

chore: add specs to the codebase #74

Merged
merged 19 commits into from
Mar 30, 2020
Merged

Conversation

raszi
Copy link
Contributor

@raszi raszi commented Mar 22, 2020

No description provided.


(defn- sample-tag [pulls]
(-> (spec/sample ::core-spec/tag)
(assoc :pulls pulls)))
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

tests.edn Outdated Show resolved Hide resolved
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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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)]
Copy link
Contributor

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.

Copy link
Contributor Author

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.

imrekoszo
imrekoszo previously approved these changes Mar 29, 2020
@raszi
Copy link
Contributor Author

raszi commented Mar 29, 2020

I caught a really nice issue with generative testing which was reported before grimradical/clj-semver#7

@thenonameguy
Copy link
Collaborator

I caught a really nice issue with generative testing which was reported before grimradical/clj-semver#7

That's really cool.

@thenonameguy
Copy link
Collaborator

Please consider using explicitly defined function applications instead of partial:
My arguments:

imrekoszo
imrekoszo previously approved these changes Mar 29, 2020
Copy link
Contributor

@imrekoszo imrekoszo left a 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>
@raszi
Copy link
Contributor Author

raszi commented Mar 29, 2020

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.

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.

raszi and others added 2 commits March 29, 2020 22:39
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)))))
Copy link
Collaborator

@thenonameguy thenonameguy Mar 29, 2020

Choose a reason for hiding this comment

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

Suggested change
(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 [])
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Collaborator

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.

Copy link
Contributor

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.

Copy link
Collaborator

@thenonameguy thenonameguy left a 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 :)

@thenonameguy thenonameguy merged commit 29dcaab into ekataglobal:master Mar 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants