overcommit is a fully configurable git hook manager. This article explains some hooks which work in the following timings:
Pre-Commit
RuboCop: A Ruby static code analyzer
Brakeman: Vulnerability scanner
HamlLint: Style Checker for HAML
YamlSyntax: Style Checker for YAML
BundleCheck: Dependency Check
RailsSchemaUpToDate: Migration Check
HardTabs: Checks for hard tabs in files
PrePush
RSpec: Unit & Integration TEST
BundleInstall: bundle install checker
๐ป Short Brief
If you want to create new Rails app project, you can use rails5_application_template which includes the following configurations. Itโs so easy, so I recommend to use the template!
๐ Gemfile
You should add the following gems and execute bundle install:
# A static analysis security vulnerability scanner gem 'brakeman', require:false
# Syntax checker for HAML gem 'haml-lint', require:false
# Syntax checker for CSS gem 'ruby_css_lint', require:false
# A Ruby static code analyzer gem 'rubocop', require:false end
๐ Configuration of overcommit
I tried some hook tools and selected some effective tool. If you agree with my recommended tools, please write the following configuration to .overcommit.yml:
# Checks for hard tabs in files HardTabs: enabled:true on_warn:fail
PrePush: # Unit & Integration TEST RSpec: enabled:true command:['bundle','exec','rspec','spec'] on_warn:fail
BundleInstall: enabled:true on_warn:fail
๐ Configuration for RuboCop
In my opinion, I really love a tool to improve my productivity. So, I choose the configuration in RuboCop to improve programmerโs productivity. You can write the following configuration to .rubocop.yml:
After finishing to set the above configuration, the hooks in git-commit or git-push will work. Letโs enjoy programming!
๐ Tips
If you want to ignore, a warning of overcommit, please add OVERCOMMIT_DISABLE=1 to your command like this:
OVERCOMMIT_DISABLE=1 GIT_COMMAND
๐ฅ Recommended VPS Service
VULTR provides high performance cloud compute environment for you.
Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour).
In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!