RepoSense icon indicating copy to clipboard operation
RepoSense copied to clipboard

Use Husky pre-push hooks to run linters

Open anubh-v opened this issue 4 years ago • 6 comments

There are often cases when we:

  • Push our work to our remote repo
  • Realise the CI checks failed due to a code style issue
  • Resolve the style issues locally and push to the remote repo again

This process can be avoided if we automatically run the linters before git push is executed. We can use a git hook for this

anubh-v avatar Apr 05 '20 16:04 anubh-v

@jylee-git @fzdy1914 what do you think about this suggestion?

anubh-v avatar Apr 11 '20 02:04 anubh-v

Let's abandon this. I think that it is better if such errors appear on GitHub itself instead of locally as a Git hook, so that it is easier for senior developers to guide newcomers if necessary. In other cases, code style issues are minor and does not affect the review workflow.

Having this hook requires writing a custom script which adds additional maintenance burden.

dcshzj avatar Mar 26 '21 15:03 dcshzj

Pretty sure that when code style issues are detected the CI tests would just fail, and senior developers usually do not look at PR with failed tests. I think a hook which checks for code style would be nice since if I forgot to run the linter before I push, I get reminded of my mistakes immediately instead of 5min later when the CI fails.

gerhean avatar Mar 29 '21 01:03 gerhean

We don't use this technique in our other projects. Which means we can survive without it. But I don't mind giving it a try just to see how it goes. There might be some value if not a lot. Let's keep it, but with a low priority.

damithc avatar Mar 29 '21 02:03 damithc

I think one possible reason why this issue is relevant is because of the different abstraction level for Run environmental checks in integration.yml compared to other linters: https://github.com/reposense/RepoSense/blob/25f4ce29e45c0365c0627c835812fe5e29090eb0/.github/workflows/integration.yml#L155-L156

Most other linters are run in Gradle (lintFrontend and checkstyleAll), so developers are likely to forget about the existence of (and need to run) ./config/gh-actions/run-checks.sh. If we make it a Gradle task (and mention it in the Developer Guide), developers are more likely to know about this particular check.

yhtMinceraft1010X avatar Feb 04 '23 16:02 yhtMinceraft1010X