Rails 7.2 ãã RuboCop ãããã©ã«ãã«ãªããã¨ããã以ä¸ã® PR ã®ã¨ãããä»å¹´ã®æ£æã« DHH ã¨ããã¨ããã¦ä½ã£ãã¡ãã£ã¨ããå°ææ©è½ã®ç´¹ä»ã§ãã
Rails 7.2 ã® config/environments/development.rb ã§ã³ã¡ã³ãã¢ã¦ãããã¦ãã apply_rubocop_autocorrect_after_generate!
ãæå¹ã«ãã㨠bin/rails g
ããã³ã¼ãã«å¯¾ãã¦èªå㧠autocorrect ãæããããã«ãªãã¾ããããã¯ããã©ã«ãã§ã³ã¡ã³ãã¢ã¦ãã«ãã£ã¦ç¡å¹ã«ããã¦ããè¨å®ã§ãã
# config/environments/development.rb Rails.application.configure do (snip) # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. - # config.generators.apply_rubocop_autocorrect_after_generate! + config.generators.apply_rubocop_autocorrect_after_generate! end
rubocop-rails-omakase ããã®ã¾ã¾ä½¿ãã±ã¼ã¹ãã©ã®ç¨åº¦ãããã¯ä»å¾ã ã¨æãã®ã§ãããç¾ç¶ã§å¤æ°æ´¾ã§ããã RuboCop ã®ã«ã¼ã«ãã«ã¹ã¿ã ããããã¯ã»ã¼ã»ã¼ããã©ã«ã使ç¨ãã¦ããæ¹ã¯æå¹ã«ãã¦ããã¨ä¾¿å©ã§ãã
ãªããããã©ã«ãç¡å¹ã®çç±ã¯ rails/rails#51782 ã§ã¯ãbin/rails new
ããã®ããã©ã«ãã§ãã rubocop-rails-omakase ã§ä½¿ãåã«ã¯ autocorrect ãå¿
è¦ãªã³ã¼ãçæããããããã§ã¯ãªãã®ã«ãåé·ãª RuboCop ã®ãã°ã表示ããããã¨ã¨ãRuboCop ã®å¦çã«ããé度é¢ã«ãããã®ã§ãããã®ãã¨ã« rails/rails#51808 㧠RuboCop ã§ã®åé·ãªãã°ã¯è¡ããªãããã«ãã¾ããããå¦çé度ã«é¢ãã¦ã¯ãªãã¨ãå¤æãé£ããé¨åããã£ããããç¹ã«ã³ã¡ã³ãã¢ã¦ããå¤ãææ¡ã¨ã¯ãã¾ããã§ããã
ããã«ãã£ã¦3å¹´åã»ã©åã«ä»¥ä¸ã®è¨äºã«è¨ãã Rails 6.1 以éã§ä»¥ä¸ã®è¨å®ã¯ä¸è¦ã«ãªãããã® apply_rubocop_autocorrect_after_generate!
ãå
¬å¼ã®ãã®ã«ãªãã¾ããã
å人çã«ã¯ bin/rails g
ã¯ãã¹ãå®è¡ãªã©ã«æ¯ã¹ã¦é »ç¹ã«ä½¿ããã®ã§ã¯ãªããããã³ã¼ãçæå¾ã« RuboCop ã®ãªã¼ãã³ã¬ã¯ãé©ç¨ãèªåã§è¡ãããã®å¦çé度ã®ãã¬ã¼ããªãã¯åãå
¥ããããããªã¨æã£ã¦ããã®ã§ãããç¶æ³ãå人差ãããã¨æãã¾ããbin/rails g
å¾ã« RuboCop ã®é©ç¨æ¼ãã®ã¾ã¾ãPR ãéãã¦ãã¾ãæ©ä¼ãããæ¹ã«ã¯ã¨ãããããããã§ã (bin/rails g migration ...
ã§çæãããã¡ã¤ã«ã« frozen string literal ãã¸ãã¯ã³ã¡ã³ãæ¼ããããã) ã
ãããã«ãã¦ã rubocop-rails-omakase ããã®ã¾ã¾ä½¿ããªã©ã®ã¦ã¼ã¹ã±ã¼ã¹ã§ãªããã°ãæå¹ã«ãã¦ããã»ã©æã¯ãªãããªã¨æã£ã¦ãã¾ãã