Skip to content

Add pre-commit hooks to run code checks #248

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

Closed
1 of 2 tasks
vbuberen opened this issue Feb 22, 2020 · 8 comments · Fixed by #408
Closed
1 of 2 tasks

Add pre-commit hooks to run code checks #248

vbuberen opened this issue Feb 22, 2020 · 8 comments · Fixed by #408
Labels
enhancement New feature or improvement to the library Pending PR The resolution for the issue is in PR

Comments

@vbuberen
Copy link
Collaborator

⚠️ Is your feature request related to a problem? Please describe

It seems that contributors often have to do multiple commits, since their contributions have issues with styling etc.

💡 Describe the solution you'd like

It might be more convenient to run ktlintCheck and detekt tasks as a pre-commit hook. With these changes contributors could be sure that their code passes Chucker checks and also make our library build process a little more eco-friendly, since we won't have to spin up Travis CI that often 🌲

📄 Additional context

We might also include test step as well.

🙋 Do you want to develop this feature yourself?

  • Yes
  • No
@vbuberen vbuberen added the enhancement New feature or improvement to the library label Feb 22, 2020
@cortinico
Copy link
Member

++ for pre-commit hooks. Are you planning to use some tool to distribute them @vbuberen or how do we architect this?

@vbuberen
Copy link
Collaborator Author

I wanted to do something simple to not introduce any additional tool.
Something like standard hooks should work fine.

@cortinico
Copy link
Member

I wanted to do something simple to not introduce any additional tool.
Something like standard hooks should work fine.

Yes my point was more that hooks are not part of the git repo (they're not applied when the repo is cloned). So we need some sort of tools to install them on the first build or similar.

@ColtonIdle
Copy link

ktlint-gradle might be able to help

https://github.com/jlleitschuh/ktlint-gradle

addKtlintFormatGitPreCommitHook

I think they recommended (overheard in kotlinglang slack) adding that to the clean task in your gradle project so that it gets added to everyones machine.

@vbuberen
Copy link
Collaborator Author

vbuberen commented Aug 2, 2020

Thanks for sharing. Looks interesting.

@cortinico
Copy link
Member

I'm adding a note for this in the README 👍

@vbuberen
Copy link
Collaborator Author

vbuberen commented Aug 3, 2020

I am currently playing around with pre-commit hook, which is installed from clean task as suggested, which runs both detekt and ktlintCheck commands. Let's install it automatically, since I don't hope that people will actually read these recommendations.

@ghost ghost added the Pending PR The resolution for the issue is in PR label Aug 4, 2020
@vbuberen
Copy link
Collaborator Author

vbuberen commented Aug 4, 2020

Closed by #408

@vbuberen vbuberen closed this as completed Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to the library Pending PR The resolution for the issue is in PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants