Rails 7.2 㧠rails new
ããéã«æè¼ããã rubocop-rails-omakase ã«ã¤ãã¦ããããã©ã®ãããªãã®ã§ãã©ã®ããã«ä½¿ããã¨ãæå¾
ããã¦ããããæ¸ãè¨ãã¦ããã¾ãã
rubocop-rails-omakase 㯠DHH ãèè ã¨ãªã Ruby ã³ã¼ãã£ã³ã°ã¹ã¿ã¤ã«ã«ã¼ã«ã§ãã
ä¸æ¬¡æ å ±ã¯ããã¾ã§ä½è ã§ãã DHH çºä¿¡ã®ãã®ã¨ãã¦ãããããã§ãããç§èªèº«ã rubocop-rails-omakase ã Rails 7.2 ã® RuboCop é¢é£æ©è½ã«ã³ã³ããªãã¥ã¼ã·ã§ã³ãã¦ãããã¨ããããæ¯è¼çãªãªã¸ã³ã«è¿ããã¨ãè¿°ã¹ããã¨ãã§ããã¨æãã¾ããã¾ã RuboCop ã®ã³ããã¿ã¼ããã¦ããããããã¶ã RuboCop ã®ä¸çã«ã¡ãã£ã¨è©³ããæ¹ã§ãããã
ã¨ã¯ããããããããªèãæ¹ãããé åã§ãããã¨ãæ¿ç¥ãã¦ãããããã²ã¨ã¤ã®èãæ¹ã¨ãã¦ãåèãã ããã
- ãªããã®è¨äºãæ¸ãã«è³ã£ãã
- rubocop-rails-omakaseã¯gofmtã®ãããªãã®ã§ã¯ãªã
- rubocop-rails-omakaseã¯ã¹ã¿ã¼ãå°ç¹
- rubocop-rails-omakaseã«ç½®ãæãã§ããªãã®ï¼
- rails/railsãªãã¸ããªã¨ã®é¢ä¿æ§
- çµå±rubocop-rails-omakaseã¨ã©ãåãåãã°ããã®ï¼
- rubocop-rails-omakaseã¨ã¯ä½ãï¼
ãªããã®è¨äºãæ¸ãã«è³ã£ãã
Rails 7.2 㧠rubocop-rails-omakase ãæ¨æºæè¼ããããã¨ã«ä¼´ããããã¾ã§ããã¸ã§ã¯ãã§è²ã¦ã .rubocop.yml ã rubocop-rails-omakase ã«ç½®ãæããã¨ãããã®ãããã¤ãè¦ã¦ãã¦ãã¾ãã妥å½ãªçç±ãããã°ãããã§ãªãçç±ãããããèãæ¹ãæ´çãã¦ããæå³ã§æ¸ãã«æãè³ãã¾ããã
rubocop-rails-omakaseã¯gofmtã®ãããªãã®ã§ã¯ãªã
ã¾ã rubocop-rails-omakase ã®ç¹å¾´ã¯ã軽é㪠Ruby ã³ã¼ãã£ã³ã°ã«ã¼ã«ã«ãªã£ã¦ãã¾ããRuboCop ã®ããã©ã«ãã«ã¼ã«ãééç´ã§ãããã¨ã¨å¯¾æ¯çã§ãã
RuboCop ã®æ§æã«ã¯ã³ã¤ã³ã®è¡¨ã¨è£ã®ãããªåãé¢ããªãåçãããã軽éã«ã¼ã«ã¯ãããããªãåé¢ãæ¤ç¥ãã¦ãããããã£ãåé¡ãçºè¦ããããªã¼ãã³ã¬ã¯ãã§ãã¾ããããã®å対ãç¶ãã§ãè¦ã¤ãããåé¡ä»¥å¤ã®ä½è¨ãªææ¡ã¾ã§ããããã®ã RuboCop ã®ããã©ã«ãã«ã¼ã«ã§ãã
ã¤ã¾ã rubocop-rails-omakase ã¯éã®å¼¾ä¸¸ã¨ããããã§ããä¸è½ã¨ãããã®ã§ãããã¾ããã
rubocop-rails-omakaseã¯ã¹ã¿ã¼ãå°ç¹
ããããã¾ã§èªåã§èªåãã¡ã«ãã£ãããã .rubocop.yml ãã¡ã³ããã³ã¹ãã¦ããããã¸ã§ã¯ãã§ããã°ãåºæ¬çã«ã¯ãã® .rubocop.yml ãã¡ã³ããã³ã¹ããã®ãããããã§ãã
rubocop-rails-omakase 㯠Rails ãæä¾ãã Linter, Formatter ã®ã¹ã¿ã¼ãå°ç¹ã®æ§æã§ããããã§ã«ã¹ã¿ã¼ãå°ç¹ã®å ã«è¡ã£ã¦ããã«ã¼ã«ã使ã£ã¦ããã°ãããã使ãç¶ããã°è¯ãããã§ãã
Rails 7.2 ã¸ã®ã¢ããã°ã¬ã¼ãã«ãã£ã¦ãã¹ã¿ã¼ãããããç´ãã¨ããã®ã¯çã«ããªã£ãã¢ããã¼ãã«ã¯ãªããªãã§ãããã
rubocop-rails-omakaseã«ç½®ãæãã§ããªãã®ï¼
ãããããã¾ã§èªåãã¡ã§è²ã¦ã¦ããæ¢åã® .rubocop.yml ããã rubocop-rails-omakase ã®æ¹ãã¯ã¼ã«ã ããã¨ããå ´åã¯ç½®ãæããã®ã¯ã²ã¨ã¤ã®ã¢ããã¼ãã§ããã¡ãã£ã¨æ²ããæ°ããã¾ããã
ãã®å ´åã¯ããã¡ããããã¾ã§æ¤ç¥ã§ãã¦ãããã®ããªã¼ãã³ã¬ã¯ãã§ãããã®ã¯ rubocop-rails-omakase ãã¼ã¹ã«å¼·å¶ããç´ãããã®ã¨ããããã大éã®ã¹ã¿ã¤ã«å¤æ´ diff ãå ¥ã£ã Pull Request ã¨åãåããã¨ã«ãªãã¾ãããã®ããèªåãã¡ã§æ¢ã«ã«ã¼ã«ãçµã¿ä¸ãã¦ããå ´åã¯ãå人çã«ã¯ãã¾ããå§ãããªãã³ã¼ã¹ã§ãã
éã«ãããã Linter, Formatter ãå°å ¥ãããã¨ããå ´åã¯ãã¹ã¿ã¼ãå°ç¹ã®ã²ã¨ã¤ã«ãªãã¨æãã¾ã (rubocop-rails-omakase ã§æ°ã«å ¥ããªãã«ã¼ã«ã¯ã«ã¹ã¿ãã¤ãºã§ãã¾ã) ã
rails/railsãªãã¸ããªã¨ã®é¢ä¿æ§
rubocop-rails-omakase 㯠rails/rails ãªãã¸ããªã® .rubocop.yml ã¨ç°ãªãã³ã¼ãã£ã³ã°ã«ã¼ã«ã§ããRails ãã¬ã¼ã ã¯ã¼ã¯ã¨ Rails ã¢ããªã±ã¼ã·ã§ã³ãå°ç¹ããã¨ããèããããã¨ããã¨ãã³ã¼ãã£ã³ã°ã¹ã¿ã¤ã«ã®ã«ã¼ã«ã¨ããå´é¢ã§ãããã¯ç¹ãã£ã¦ãã¾ããã
rubocop-rails-omkase ã®ã«ã¼ã«ã¯åºå®ããã¦ãã¾ãããrails/rails ã® .rubocop.yml è¨å®ã¯æã«è§¦ãã¦æ´æ°ããã¾ãã
ãã¬ã¼ã ã¯ã¼ã¯ã¨ã¢ããªã±ã¼ã·ã§ã³ã§ã«ã¼ã«ãæãããå ´åã¯ãrails/rails ãªãã¸ããªã®ã«ã¼ã«ããã¬ã¼ã¹ãã¦ãã rubocop-rails_config ã®å©ç¨ãªã©ãæ¤è¨ãã¦ãã ããã
ã¾ãããã®ãããªçç±ãã rubocop-rails-omakase 㯠rubocop-rails_config (ã¨ãããç¶æ¿ããã¹ã¿ã¤ã«) ãç½®ãæãããã®ã§ãããã¾ããã
çµå±rubocop-rails-omakaseã¨ã©ãåãåãã°ããã®ï¼
rails new
ã®å¾ã® bin/rubocop
ã®å®è¡ã«å¯¾ãã¦ãä½ããã® .rubocop.yml ã®è¨å®ãå¿
è¦ã§ãããèªåãã¡ãã«ã¼ã«ãæã£ã¦ããªãå ´åã®ã¹ã¿ã¼ãã©ã¤ã³ã¨ãã¦ã軽éãªã«ã¼ã«ã»ããã¨ãã¦ä½¿ãã¾ã (ãããã« RuboCop ã®ããã©ã«ãã«ã¼ã«ã Rails ã¢ããªã±ã¼ã·ã§ã³ã¦ã¼ã¶ã¼å
¨ä½ã®ããã©ã«ã ã¨ããã®ã¯ééæããã¨æãã¾ã) ãrubocop-rails-omakase ã®ã«ã¼ã«ã»ããã¨ãã¦ãæ°ã«å
¥ãã°ãã®ã¾ã¾ä½¿ãç¶ãããã¨ãã§ãã¾ããããã®è¨å®ãå
ã«æ´æ°ãã¦ãããã¨ãã§ãã¾ãããã®ãããã®åãåãæ¹ã«ã¤ãã¦ã¯ rubocop-rails-omakase ã® README ã«è©³ããã§ãã
ã¾ãã³ã¼ãã£ã³ã°ã«ã¼ã«ã®æ´æ°ã¯ã¦ã¼ã¶ã¼ã®ããã¸ã§ã¯ããµã¤ãã§ã®ã¿è¡ããããã¨ãæå¾ ããã¦ãã¾ããrubocop-rails-omakase ã¯ç¾æç¹ã§ã«ã¼ã«ãåºå®ããã¦ãããã¦ã¼ã¶ã¼ããã®ã³ã¼ãã£ã³ã°ã«ã¼ã«ã®ãã£ã¼ãããã¯ãæå¾ ããã¦ãã¾ããã
ä¾ãã°ãé
åãªãã©ã«ã«ã¤ã㦠[ foo, bar, baz ]
ã¨ãã£ããã¬ã¼ã¹ã®å
å´ã«ã¹ãã¼ã¹ãå¼·è¦ããè¨å®ã§ãç§ãè¦ãéã Ruby ã§ã¯ç¾ç¶ãã¤ããªãã£ã®ã³ã¼ãã£ã³ã°ã«ã¼ã«ã§ãããããã¯æå³çãªè¨å®ã§ããæ°ã«å
¥ããªããã°ã¦ã¼ã¶ã¼å´ã§ã«ã¼ã«ãæ´æ°ãã¾ãããã
ã¾ãæ¢ã«èªåãã¡ã®ã«ã¼ã«ãçµã¿ä¸ãã¦ããã°ããã使ãç¶ããã°è¯ããã¹ã¿ã¼ãå°ç¹ã®rubocop-rails-omakseã¸ã®åãæ¿ãã¯åºæ¬çã«èããªãã¦è¯ãã¨æã£ã¦ãã¾ã (ãä»äºã§ã¯ä»ã«èããã¹ããã¨ããã£ã±ããã) ã
rubocop-rails-omakaseã¨ã¯ä½ãï¼
端çã«ããã¨ãstandard, rubocop-rails_config, rubocop-github, rubocop-airbnb ãªã©æ°ããã«ã¹ã¿ã ã«ã¼ã«ã»ããã®ã²ã¨ã¤ã§ããRuby ã®ã³ã¼ãã£ã³ã°ã«ã¼ã«ã¯ gofmt
ã®ããã«å¤§çµ±ä¸ã§ãããã®ã§ã¯ãªãã¨ããå²å¦ã RuboCop ã«ããããã«ãå¤æ§æ§ã®ã²ã¨ã¤ã¨ãã¦æããã®ãè¯ãã¨æãã¾ãã
rubocop-rails-omakase ã¯ã軽éãªéå§å°ç¹ãããã©ã«ãã¨ãã¦æä¾ããã¦ããã¨ãããããããã¨ã¦ã DHH ãããæãã§ããã¾ã Ruby ã® Linter, Formatter ã¨ãã¦ãã©ã®ãããªã«ã¼ã«ã»ããã¨ãã¦è²ã¦ã¦ãããã¦ã¼ã¶ã¼ãµã¤ãã« omakase ããã¦ãããããã The Rails Doctrine ã¿ãããªãã¨æã£ã¦ãã¾ãã
ãã®ãããã®è©±ã¯å æ¥ã® Ruby ã»ããã¼ æ±äº¬ã§ã触ãã¦ããã¾ãã®ã§ããããã°ãããã¦ãåç §ãã ããã
ãããªæãã§ä»æ¥ã¯ããã¾ã§ãããã¯ãç¶ãã¾ãããã