dwyl / hits-elixir

:chart_with_upwards_trend: An Elixir implementation of the "Hits" project (a super-basic "Web Page View Counter")
http://hits.dwyl.io
GNU General Public License v2.0
31 stars 1 forks source link

Setup Pre-Commit Hook to Run Tests & Dogma #10

Open nelsonic opened 7 years ago

nelsonic commented 7 years ago

as a developer I don't want to have to remember to run the linter (dogma) each time I commit my code ... I want it to run automatically! see: https://github.com/dwyl/learn-pre-commit

e.g: https://travis-ci.org/dwyl/hits-elixir/builds/274319451#L689 image where the tests pass but the "dogma" code style fails...! 🙄

nelsonic commented 7 years ago

Hoping someone else has discovered an elegant way of doing this in without resorting to node.js ... https://github.com/dwyl/learn-pre-commit/issues/6#issuecomment-328643295

Cleop commented 6 years ago

How about this one https://github.com/dwyl/elixir-pre-commit @nelsonic?

Currently in the process of adding it although encountering an error with mix credo that I'm having to look into.

image image

nelsonic commented 6 years ago

@Cleop yeah, I just wanted help from someone to implement it. 😉

Cleop commented 6 years ago

Came across these re broken credo on the credo repo: https://github.com/rrrene/credo/issues/463 image https://github.com/rrrene/credo/issues/496 image

Changing the credo line as the second comment suggests got it running successfully on mix credo but failing when I try to do a commit Pass: image Fail with no further explanation: image

More on the same here: https://github.com/rrrene/credo/issues/469

Maybe I'm best off adding my feedback to the credo repo too, despite the fact it's supposedly been fixed there... looks like some other people are still experiencing the problem: image

@nelsonic @SimonLab - what do you think? Just want to make sure I've not overlooked anything?

Cleop commented 6 years ago

I've asked directly on the credo repo here on an update/ advice: https://github.com/rrrene/credo/issues/495#issuecomment-366679851

Cleop commented 6 years ago

Response from @rrene shared these links:

Credo fails with an exit status != 0 if it shows any issues. This enables shell based pipeline workflows (e.g. on CI systems) which test Credo compliance.

These are the scores of exit statuses that credo emits based on any shortcomings in your code: image

Therefore the reason the pre-commit is failing is because we're not exiting with an exit status of 0 because of the amendments that could be made to the code.

So to solve this issue we need to resolve the credo suggestions to give an exit status of 0.