Skip to content

Do not use rubocop server on lefthook calls to rubocop

Chad Woolley requested to merge caw-add-no-server-to-lefthook-rubocop-calls into master

What does this MR do and why?

Do not use rubocop server on lefthook calls to rubocop

  • The rubocop server is incompatible with usage of ENV vars to dynamically control content of the .rubocop.yml config, because changes to ENV vars are not picked up or respected, the server caches the current state of ENV vars when it starts.

For example: https://docs.gitlab.com/ee/development/rubocop_development_guide.html#reveal-existing-rubocop-exceptions

How to verify locally?

echo "# Just a comment" >> app/models/project.rb

git checkout master
export REVEAL_RUBOCOP_TODO=1
bundle exec rubocop --start-server
bundle exec rubocop app/models/project.rb # 1 file inspected, 227 offenses detected, 149 offenses autocorrectable
git commit app/models/project.rb # 1 file inspected, 227 offenses detected, 149 offenses autocorrectable

git checkout caw-add-no-server-to-lefthook-rubocop-calls
bundle exec rubocop --stop-server
bundle exec rubocop --start-server
bundle exec rubocop app/models/project.rb # 1 file inspected, 227 offenses detected, 149 offenses autocorrectable
git commit app/models/project.rb # 1 file inspected, no offenses detected

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports