question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add pre-commit hooks to run code checks

See original GitHub issue

⚠️ 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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vbuberencommented, 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.

1reaction
ColtonIdlecommented, Aug 1, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Supported hooks - pre-commit
cheetah-reorder-imports - This hook reorders imports in cheetah files. cheetah-flake - Lint cheetah code using flake8 and some other checks. github.com/ ...
Read more >
Using pre-commit git hooks to automate code checks - Eric J. Ma
Git hooks are an awesome way to automate checks on your codebase locally before committing them to your code repository. That said, setting...
Read more >
Using Precommit Hooks For Static Code Analysis
In this article we'll discuss how to use Git's pre-commit hooks to run our static code analysis tools on just the set of...
Read more >
Trusting a Git pre-commit hook to Run Checks Automatically
3. Now, create a Git hook Shell script named pre-commit.sh by copying and pasting the code below to your script and save it...
Read more >
Automating Code Checks and Tests with Git Hooks - AntStack
The most common way to add checks to your codebase is to use husky and lint-staged. I have used husky many times to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found