rubocop-rails icon indicating copy to clipboard operation
rubocop-rails copied to clipboard

New cop to check for 3-state booleans

Open fatkodima opened this issue 3 years ago • 4 comments

https://thoughtbot.com/blog/avoid-the-threestate-boolean-problem

fatkodima avatar Aug 23 '20 09:08 fatkodima

This style looks good to me. Can you open a PR to the Rails Style Guide, first? https://github.com/rubocop-hq/rails-style-guide/pulls

For implementation, it is necessary to consider a applied migration files.

koic avatar Aug 28 '20 04:08 koic

using a default value in a large table will cause a complete rewrite.

https://github.com/ankane/strong_migrations#adding-a-column-with-a-default-value

In Postgres 11+, MySQL 8.0.12+, and MariaDB 10.3.2+, this no longer requires a table rewrite and is safe.

silva96 avatar Sep 01 '20 17:09 silva96

For implementation, it is necessary to consider a applied migration files.

@koic We can only check schema.rb file and find offenses right?

tejasbubane avatar Nov 24 '20 21:11 tejasbubane

Some use structure.sql. Also, schema.rb is not necessarily committed, even if exists on developer machines it might not be present on CI unless you run migrations before rubocop which would be a pretty weird requirement.

Checking migrations is the only way I can think of.

pirj avatar Nov 24 '20 22:11 pirj